beancount.ingest.importers.mixins

beancount.ingest.importers.mixins.config

Base class that implements configuration and a filing account.

class beancount.ingest.importers.mixins.config.ConfigMixin(**kwds)
REQUIRED_CONFIG = None
beancount.ingest.importers.mixins.config.validate_config(config, schema, importer)

Check the configuration account provided by the user against the accounts required by the source importer.

Parameters
  • config – A config dict of actual values on an importer.

  • schema – A dict of declarations of required values.

Raises

ValueError – If the configuration is invalid.

Returns

A validated configuration dict.

beancount.ingest.importers.mixins.filing

Base class that implements filing account.

It also sports an optional prefix to prepend to the renamed filename. Typically you can put the name of the institution there, so you get a renamed filename like this:

YYYY-MM-DD.institution.Original_File_Name.pdf

class beancount.ingest.importers.mixins.filing.FilingMixin(**kwds)
file_account(file)

Return an account associated with the given file.

Note: If you don’t implement this method you won’t be able to move the files into its preservation hierarchy; the bean-file command won’t work.

Also, normally the returned account is not a function of the input file–just of the importer–but it is provided anyhow.

Parameters

file – A cache.FileMemo instance.

Returns

The name of the account that corresponds to this importer.

file_name(file)

Return the optional renamed account filename.

name()

Include the filing account in the name.

beancount.ingest.importers.mixins.identifier

Base class that implements identification using regular expressions.

class beancount.ingest.importers.mixins.identifier.IdentifyMixin(**kwds)
identify(file)

Return true if this importer matches the given file.

Parameters

file – A cache.FileMemo instance.

Returns

A boolean, true if this importer can handle this file.

beancount.ingest.importers.mixins.identifier.identify(remap, converter, file)

Identify the contents of a file.

Parameters

remap – A dict of ‘part’ to list-of-compiled-regexp objects, where each item is a specification to match against its part. The ‘part’ can be one of ‘mime’, ‘filename’ or ‘content’.

Returns

A boolean, true if the file is not rejected by the constraints.