From b052f84230a428fcfeed718b637226c8fca78413 Mon Sep 17 00:00:00 2001 From: Ben Boonstra Date: Wed, 23 Oct 2024 17:40:05 -0500 Subject: [PATCH] Release Candidate 1.3.0 [test] [docs] --- CHANGELOG.md | 4 -- docs/docs/advanced-usage.html | 3 +- docs/docs/technical/config.html | 66 +++++++++++++++++++++++-------- docs/docs/technical/db.html | 41 ++++++++++++++++++- docs/docs/technical/technical.css | 6 +++ docs/docs/technical/technical.js | 12 +++++- effortless/configuration.py | 2 +- setup.py | 2 +- 8 files changed, 109 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d91fda..82567f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,10 +26,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - EffortlessConfig now takes keyword parameters instead of a dictioniary - Use from_dict if you need the old functionality -### Docs - -- TODO - ## [1.2.0.1] - 2024-10-22 ### Added diff --git a/docs/docs/advanced-usage.html b/docs/docs/advanced-usage.html index 6e31250..0609712 100644 --- a/docs/docs/advanced-usage.html +++ b/docs/docs/advanced-usage.html @@ -41,8 +41,7 @@

Configuring the Database

You can futher customize the database with a configuration:

- config = EffortlessConfig() - config.readonly = True + config = EffortlessConfig(readonly=True) db.configure(config) # The database contents are now read-only db.add({"Anything": "will not work"}) # Raises an error diff --git a/docs/docs/technical/config.html b/docs/docs/technical/config.html index f356598..330c720 100644 --- a/docs/docs/technical/config.html +++ b/docs/docs/technical/config.html @@ -23,26 +23,30 @@

EffortlessConfig

Properties

-

requires

+

+ required_fields +

Require fields for each entry in the DB.

- config.requires = ["id"] + config = EffortlessConfig(required_fields=["id"]) db.configure(config) db.add({}) # Error: Field 'id' is required
-

backup

+

+ backup_path +

Make the database automatically back up to the specified path.

- config.backup = "/folder/backups/" + config = EffortlessConfig(backup="/folder/backups/") db.configure(config) db.add({"data": True}) print(os.path.exists("/folder/backups/db.effortless")) @@ -99,26 +103,27 @@

encrypted

-

version

+

version

- The internal version of the database. + The internal version of the database. This is used for + automatic migration between versions of Effortless.

Methods

-

+

__init__

- Creates an EffortlessConfig with the given configuration - options. EffortlessConfig creation will be changed in - 1.3.0. + Creates an EffortlessConfig with any specified + configuration options.

+ +
+ config = EffortlessConfig(compressed=True, required_field=["name"]) +

@@ -126,17 +131,46 @@

Converts the configuration to a dictionary - representation. You can use this to edit a config before - re-applying it. + representation. You can use this to save a config or + edit a config as a dict before re-applying it.

config_dict = config.to_dict() for opt in config_dict: ‎ ... - config = EffortlessConfig(config_dict)
+
+

+ from_dict +

+

+ Converts a dictionary into an EffortlessConfig object. +

+ +
+ config = EffortlessConfig.from_dict({"readonly": True}) +
+
+
+

+ validate_db +

+

+ Checks if the given database follows the configured + rules. Raises ValueError if anything doesn't follow. + This must pass for a new configuration to be applied to + a database. +

+
EffortlessDB diff --git a/docs/docs/technical/db.html b/docs/docs/technical/db.html index c280755..0aa1756 100644 --- a/docs/docs/technical/db.html +++ b/docs/docs/technical/db.html @@ -31,13 +31,22 @@

that holds the configuration settings for the database.

+
+

+ encryption_key +

+

+ The encryption key (password) used to encrypt and + decrypt the database. +

+

Methods

__init__

@@ -46,7 +55,8 @@

Methods

database name. If no name is provided, it defaults to "db". For example, passing in "users" will create a database with the file "users.effortless" in the current - directory. + directory. If an encryption_key is provided, it will be + used to encrypt/decrypt the database.

@@ -205,6 +215,33 @@

Methods

EffortlessConfig object.

+
+

+ encrypt +

+

+ Sets a new encryption key and re-encrypts the database + if necessary. If the database is already encrypted, this + method will attempt to decrypt with both the old and new + keys, then re-encrypt with the new key. +

+
+
+

+ unencrypt +

+

+ Permanently unencrypts the database using the encryption + key if the database is currently encrypted. Raises a + ValueError if an encryption key is not set. +

+

{ + const atValue = method.getAttribute("at"); + if (atValue && atValue.trim() !== "") { + createFormattedAttribute(method, "at", atValue); + } + }); }); diff --git a/effortless/configuration.py b/effortless/configuration.py index 904c943..7588ee9 100644 --- a/effortless/configuration.py +++ b/effortless/configuration.py @@ -146,7 +146,7 @@ def to_dict(self) -> Dict[str, Any]: "compressed": self.compressed, "readonly": self.readonly, } - + @classmethod def from_dict(cls, config_dict: Dict[str, Any]) -> "EffortlessConfig": """ diff --git a/setup.py b/setup.py index 98c362b..aad7828 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="Effortless", - version="1.2.0.1", + version="1.3.0", packages=find_packages(), description="Databases should be Effortless.", long_description=open("README.md").read(),