-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't consume all provided arguments in new ingestion flow #12
Comments
@zahanm Can you please elaborate on how you were planning to use additional command line arguments to the ingest script? Beancount ingest framework has been spun off to this separate repo and the command line interface redesigned using Click. I would like to enable your use case in the new code, if it does not deviate too much from the design. |
Hi @dnicolodi - thanks for reaching out. I ended up rearchitecting things, and doing most of it by hand. Though I'd be happy to use a new API if it supports a richer ingestion API.
|
Yeah, this is the argument in particular I wanted to pass in. |
Adding commands to the script entry point generated by the ingestion framework is not possible. There is an example in the comments to the PR that implemented it #28, although it may require some adjustments as the API may ended up to be slightly different than the one I had in mind when writing the comment. On the other hand, adding options or arguments to the script entry point generated by the ingestion framework or to the existing commands is not possible because this would also need to add code that does something with the extra arguments. What you can do, however, is to subclass the new class Ingest(beangulp.Ingest):
def __init__(self, importers, hooks=None):
self.importers = importers
self.hooks = hooks
@click.group()
@click.option('--config', ...)
@click.version_option()
@click.pass_context
def main(ctx, config):
"""Import data from and file away documents from financial institutions."""
ctx.obj = self
ctx.obj.config = config
main.add_command(beangulp._extract)
main.add_command(beangulp._file)
main.add_command(beangulp._identify)
self.main = main this is completely untested, but I think you get the spirit. Things could be reorganized a bit to avoid having to copy the whole |
Original report by Zahan Malkani (Bitbucket: Zahan, GitHub: zahanm).
An issue with the implementation in
https://bitbucket.org/blais/beancount/commits/0c66d90c2173fd5fcc83d10c8297800d70a81c9b
which itself addresses the questions raised in beancount/beancount#75
is this:
you can't provide custom arguments to your own import script, because once you call
ingest(..)
- it is unhappy that it doesn't recognize some of the arguments.A simple fix would be to
parse_known_args
instead, which I'll do in a PR shortly - once I figure out how to make a PR on bitbucket.The text was updated successfully, but these errors were encountered: