Commit graph

23 commits

Author SHA1 Message Date
Brett Smith
18800b249d config: Let user specify books dir with ~. 2020-05-17 14:52:23 -04:00
Brett Smith
aa488effb0 books.Loader: New loading strategy based on load_file. RT#11034.
Building a string and loading it means Beancount can never cache any
load. It only caches top-level file loads because options in the
top-level file can change the semantics of included entries.

Instead use load_file as much as possible, and filter entries as
needed.
2020-05-16 10:29:06 -04:00
Brett Smith
1e09339b32 config: Make payment threshold configurable. 2020-05-16 09:51:02 -04:00
Brett Smith
072937eff5 books.Loader: New loading strategy.
The old loading strategy didn't load options, which yielded some
spurious errors. It also created awkward duplication of plugin
information in the code as well as the books.

Implement a new loading strategy that works by reading one of the
"main files" under the books/ subdirectory and includes entries
for additional FYs beyond that.

This is still not ideal in a lot of ways. In particular, Beancount can't
cache any results, causing any load to be slower than it theoretically could
be. I expect more commits to follow. But some of them might require
restructuring the books, and that should happen separately.
2020-05-05 14:31:08 -04:00
Brett Smith
3000aeee09 config: Add Config.books_loader() method. 2020-04-21 13:35:56 -04:00
Brett Smith
51137815d3 config: fiscal_year_begin returns a FiscalYear. 2020-04-21 09:07:14 -04:00
Brett Smith
894f044093 config: Add Config.fiscal_year_begin() method. 2020-04-20 14:31:22 -04:00
Brett Smith
7f45788235 config: Start configuration file with books path.
Ultimately I would like to make it possible to configure the software
entirely through this file, rather than the hodgepodge system we have
now. But that can come later.
2020-04-12 22:27:52 -04:00
Brett Smith
8fa9a0ffe6 tests: Set XDG_CONFIG_HOME for safety. 2020-04-12 22:24:34 -04:00
Brett Smith
a156617b4d config: Add Config.config_file_path() method. 2020-04-10 10:53:39 -04:00
Brett Smith
24813a9b81 config: Ignore non-absolute XDG_CACHE_HOME.
Per the spec.
2020-04-10 08:34:55 -04:00
Brett Smith
c7fbf5b5d5 config: s/XDG_CACHE_DIR/XDG_CACHE_HOME/g
Per the spec.
2020-04-10 08:24:34 -04:00
Brett Smith
5f85d9c747 config: Add Config.payment_threshold() method.
This just returns a constant for now, but we know it may need to be
configurable in the future.  Other code can start using this now
to be configurable in the future.
2020-03-29 10:21:37 -04:00
Brett Smith
33cb734b19 config: Create cache database files with 0o600 mode.
I wasn't too worried about this earlier because the cache mainly stores
a bunch of numbers, but there's a little more than that: the generated
URLs also include original attachment filenames, which might be sensitive
(referencing people's names, bank names, etc.). Tighten security
accordingly.
2020-03-27 10:55:30 -04:00
Brett Smith
a8407c7b6a rtutil: Add RTLinkCache class to cache links to disk.
This will greatly reduce RT requests across multiple runs
and speed up link checking/conversion.
2020-03-27 07:35:45 -04:00
Brett Smith
1155212376 config: Add Config.cache_dir_path method. 2020-03-25 15:15:38 -04:00
Brett Smith
96ef7c9cbb test_config: Make update_environ more robust against failures. 2020-03-25 14:04:47 -04:00
Brett Smith
d8b0a56fb4 tests: Set a default CONSERVANCY_REPOSITORY for testing. 2020-03-25 14:03:25 -04:00
Brett Smith
c4ce59da75 config: Add Config.rt_wrapper method.
This returns a cached version of the new rtutil.RT class,
so that a single process can easily grab references to one
instance with one cache of ticket/attachment data, etc.
2020-03-24 23:30:31 -04:00
Brett Smith
f09f029fc4 config: Add Config.rt_client method. 2020-03-24 09:08:08 -04:00
Brett Smith
8d3816a8fd config: Add Config.rt_credentials method.
This loads settings from the same environment variables and ~/.rtrc
file as the rt CLI.

Note that it does *not* support RTCONFIG and the config file
searching, because right now that seems like more work for more
trouble to me.
2020-03-23 15:19:15 -04:00
Brett Smith
5140ca64f6 tests: Clean the environment before running tests.
As we start reading more sensitive user configuration (like RT credentials),
this fixture makes it simpler to ensure that the tests never read the user's
real configuration, which could lead to problems like passwords in tracebacks.
2020-03-23 12:01:02 -04:00
Brett Smith
71531913d5 config: Start module.
Ultimately all values that come from user configuration will be generated
here.
2020-03-19 14:31:21 -04:00