Made a ton of changes to the APIs and some new functionality:
- Reworked how resources function. They now use the same mode as the builtin open function does. You can set modes like "r", "w", "a", "r+", "w+", and "a+". They will work as you expect, with the difference that those with a + indicates live-update is enabled, e.g. "r" is read mode, while "r+" is read with live-update enabled.
- The standard JsonResource has been changed to create a backup file that is written to. After the backup file has been written to, the name of the file will be changed to the normal file. This way, there's always a file to read from. In very rare cases, if you kill the writing process, there will not be anything in the file since the file is opened in "w" mode, since append mode works really badly with JSON. We might lose a bit of data in such a case, but we retain most of it since we'll read from the standard file that still exists.
- A Key can now take a set of modifier functions. These work just like validators (see validator.py) in that you create a method to annotate with varvault.modifier() which will allow you to modify the value of the object mapped to the key. This is useful if you want to strip a sequence of characters from a string, or expand vars/user in a path, or to always follow symlinks using os.path.realpath. This can reduce some boilerplate code.
- The VaultFlags have been changed to just Flags and they have been changed to enums which is quite a bit more lightweight than creating new strings for every key.
- The factory functions have been completely changed. There is now only create, and no from_vault. The resource object will handle the from_vault case by using append mode (mores "a", or "a+") instead.
- There's no argument for resource_from or resource_to anymore; just resource. If you want to load a vault from one resource and write to another resource, you'll need to create a resource-object for the resource that you want to load from and load it into the vault manually after creating the vault.
- A function has been added to utils called assert_and_raise. The function takes a condition as a bool and an exception object. It acts as an assert-function that can raise any exception you want (such as KeyError or ValueError) rather than AssertionError.
- Internal logging has been changed to be more robust, though this sadly means it's a bit slower. It's not slow, just slower than it was. But the robustness improvements are worth it to get the logging you expect.
- Added more type-annotations to exposed functions, such as for create under factory.py. This should help users to know how to use the functions better, provided they are using a proper IDE.