Varvault

Latest version: v6.0.2

Safety actively analyzes 625891 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 4

6.0.2

Made bug fixes to how automatic-decorator works to allow it to catch exceptions when running in a thread. The exceptions will be exposed and raised when using await_running_tasks.

6.0.1

Changes:
* There was a bug when annotating functions with `automatic` while the key(s) are already in the vault. The change will aim to only dispatch the function that is annotated rather than all functions, since that is what is desired anyway.
* Lowered the logging level for some messages related to threaded automatics from INFO to DEBUG.

6.0.0

Changes:
* Renamed `vaulter` to `manual` since "vaulter" isn't a real word and "manual" describes it better since it's called manually.
* Renamed `input_keys` to `input`, and renamed `return_keys` to `output`.
* Added a big new feature which is a new form of decorator: `automatic`. This decorator works pretty much the same as `manual` does, but will trigger automatically when all input keys exist in the vault and can be viewed as a subscriber. This means that no manual execution of the decorated function is necessary. A subscriber can also run in a thread if you want, meaning you can easily run things in parallel when the conditions are met and just let things happen when they can happen. You can define a conditional for functions defined as `automatic`. A conditional is meant to be a lambda that takes 0 arguments that checks something that evaluates to True. You can use this to, for example, check if a string value in the vault matches something.
* Added a new flag called `output_key_replaces_input_key` and it works as you might expect. A `manual` or `automatic` decorated function with 1 input key and 1 output key with this flag will delete the input key from the vault and insert the output key, meaning the input key will be gone from the vault and effectively replaced by the new key (or at least that's the idea). This can be useful when creating a datastructure that isn't final, but you still want to use `automatic` and trigger on this structure once it's created. With this key you can have intermediate keys before the final one.

5.0.2

Bugfixes:
* Correctly type-annotated the return variable for `VarVault.get` when getting the variable for a single key to be `Any` instead of `object`

5.0.1

* Made some fixes to `Vault.get` to use the `overload` decorator so IDEs doesn't get confused with what implementations are available.
* Made a fix for when using validators and modifiers together when adding values to the vault using `insert`. In this case, it would validate without modifying the value. It would also validate the value twice, which shouldn't be necessary. It does mean that `MiniVault.build` doesn't validate the keys, but that's fine because you still cannot write a faulty value for key to the vault.

5.0.0

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.

Page 1 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.