Here are some examples of transformations that you might want to carry out on some of the directives: Many syntax extensions can be carried out by transforming the list of directives into a new list in the plug-ins processing stage. Writing Plug-ins Īs you saw in the previous section, loading a Beancount file essentially produces a list of directives. It also allows the author of the input file to selectively enable various optional features that way. The list of user plugins to run is part of the load stage because that allows programs that monitor the file for changes to reload it and reapply the same list of plugins. All processing within Beancount is performed functional-style by processing lists of entries that are assumed immutable 1. These entries are dumb read-only objects (Python namedtuples) and have no methods that modify their contents explicitly. Beancount’s own filtering and reporting programs directly process those, and so can you too. The list of entries generated by this pipeline are of the various types defined in, and in a typical input file, most of them will be of type Transaction. Run the resulting entries through a validation stage, to ensure that directives synthesized or modified by the plugins conform to some invariants that the codebase depends on. The list of plugins to run is composed of a set of default plugin modules that implement some of the built-in features of Beancount, followed by the list provided by the user from the “plugin” options in the input file. This effectively allows the plugin to filter the entries. For each plugin, load the plugin module and call its functions with the list of entries and the options_map from the previous stage, replacing the current list by the ones returned by the plugin. At every stage, new errors generated are collected. Once created, this will never be modified thereafter.Įrrors: A list of error objects, if any occurred. Options_map: A Python dict of the option values from the input file. This list of entries will get transformed and refined by the various subsequent stages. This prepares the entries for processing. Moreover, Transaction directives that occur on the same date as other directives are always guaranteed to be sorted after them. The output of this stage isĮntries: A list of tuples (defined in ) corresponding to each directive exactly as it appeared in the file, and sorted by date and line number. Internally, the single point of entry to load an input file is the _file() function, which accepts an input file and carries out a list of transformation steps, as in this diagram: You need to know a little bit about how Beancount processes its input files. These are the main two methods for extending Beancount’s features and for writing your own custom reports. #Beancounter addon how toIt also provides information on how to write your own “plugins,” which are just Python functions that you can configure to transform your transactions or synthesize ones programmatically. This document provides examples and guidelines on how to write scripts that use the contents of your ledger. A Proposal for an Improvement on Inventory Booking.A Comparison of Beancount and Ledger Hledger.Running Beancount and Generating Reports.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |