Skip to content

Commit

Permalink
Release Candidate 1.3.0 [test] [docs]
Browse files Browse the repository at this point in the history
  • Loading branch information
bboonstra committed Oct 23, 2024
1 parent f85559c commit b052f84
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 27 deletions.
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions docs/docs/advanced-usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ <h2>Configuring the Database</h2>
<p>You can futher customize the database with a configuration:</p>
<!-- prettier-ignore -->
<div class="command python">
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
Expand Down
66 changes: 50 additions & 16 deletions docs/docs/technical/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,30 @@ <h1 class="technical-title">EffortlessConfig</h1>
<h3 class="prop-header">Properties</h3>
<div class="properties-container">
<div class="property">
<h4 class="prop-subheader" prop-type="list">requires</h4>
<h4 class="prop-subheader" prop-type="list">
required_fields
</h4>
<p class="prop-description">
Require fields for each entry in the DB.
</p>
<!-- prettier-ignore -->
<div class="command python example-usage">
config.requires = ["id"]
config = EffortlessConfig(required_fields=["id"])
db.configure(config)
db.add({}) # Error: Field 'id' is required
</div>
</div>
<div class="property">
<h4 class="prop-subheader" prop-type="string">backup</h4>
<h4 class="prop-subheader" prop-type="string">
backup_path
</h4>
<p class="prop-description">
Make the database automatically back up to the specified
path.
</p>
<!-- prettier-ignore -->
<div class="command python example-usage">
config.backup = "/folder/backups/"
config = EffortlessConfig(backup="/folder/backups/")
db.configure(config)
db.add({"data": True})
print(os.path.exists("/folder/backups/db.effortless"))
Expand Down Expand Up @@ -99,44 +103,74 @@ <h4 class="prop-subheader" prop-type="bool">encrypted</h4>
</p>
</div>
<div class="property">
<h4 class="prop-subheader" prop-type="v1">version</h4>
<h4 class="prop-subheader" prop-type="string">version</h4>
<p class="prop-description">
The internal version of the database.
The internal version of the database. This is used for
automatic migration between versions of Effortless.
</p>
</div>
</div>
<h2 class="method-header">Methods</h2>
<div class="methods-container">
<div class="method">
<h4
class="method-subheader"
method-parameters="options: dict"
>
<h4 class="method-subheader" method-parameters="properties">
__init__
</h4>
<p class="method-description">
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.
</p>
<!-- prettier-ignore -->
<div class="command python example-usage">
config = EffortlessConfig(compressed=True, required_field=["name"])
</div>
</div>
<div class="method">
<h4 class="method-subheader" method-returns="dict">
to_dict
</h4>
<p class="method-description">
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.
</p>
<!-- prettier-ignore -->
<div class="command python example-usage">
config_dict = config.to_dict()
for opt in config_dict:
‎ ...
config = EffortlessConfig(config_dict)
</div>
</div>
<div class="method">
<h4
class="method-subheader"
at="classmethod"
method-returns="EffortlessConfig"
>
from_dict
</h4>
<p class="method-description">
Converts a dictionary into an EffortlessConfig object.
</p>
<!-- prettier-ignore -->
<div class="command python example-usage">
config = EffortlessConfig.from_dict({"readonly": True})
</div>
</div>
<div class="method">
<h4
class="method-subheader"
method-parameters="db: EffortlessDB"
>
validate_db
</h4>
<p class="method-description">
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.
</p>
</div>
</div>
<div class="button-container">
<a href="db.html" class="tab tab-back">EffortlessDB</a>
Expand Down
41 changes: 39 additions & 2 deletions docs/docs/technical/db.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ <h4 class="prop-subheader" prop-type="EffortlessConfig">
that holds the configuration settings for the database.
</p>
</div>
<div class="property">
<h4 class="prop-subheader" prop-type="string">
encryption_key
</h4>
<p class="prop-description">
The encryption key (password) used to encrypt and
decrypt the database.
</p>
</div>
</div>
<h2 class="method-header">Methods</h2>
<div class="methods-container">
<div class="method">
<h4
class="method-subheader"
method-parameters="db_name: string"
method-parameters="db_name: string, encryption_key: string"
>
__init__
</h4>
Expand All @@ -46,7 +55,8 @@ <h2 class="method-header">Methods</h2>
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.
</p>
<!-- prettier-ignore -->
<div class="command python example-usage">
Expand Down Expand Up @@ -205,6 +215,33 @@ <h2 class="method-header">Methods</h2>
<a href="config.html">EffortlessConfig</a> object.
</p>
</div>
<div class="method">
<h4
class="method-subheader"
method-parameters="new_key: string"
>
encrypt
</h4>
<p class="method-description">
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.
</p>
</div>
<div class="method">
<h4
class="method-subheader"
method-parameters="new_key: string"
>
unencrypt
</h4>
<p class="method-description">
Permanently unencrypts the database using the encryption
key if the database is currently encrypted. Raises a
ValueError if an encryption key is not set.
</p>
</div>
<div class="method">
<h4
class="method-subheader"
Expand Down
6 changes: 6 additions & 0 deletions docs/docs/technical/technical.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
color: var(--background-color);
}

.at {
background-color: var(--secondary-color);
color: var(--background-color);
margin: 0px;
}

@media (max-width: 768px) {
.technical-title {
font-size: 2rem;
Expand Down
12 changes: 11 additions & 1 deletion docs/docs/technical/technical.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ document.addEventListener("DOMContentLoaded", function () {
const formattedAttr = document.createElement("span");
formattedAttr.className = `formatted-attr ${attrName}`;
formattedAttr.textContent = content;
if (attrName === "prop-type") {
if (attrName === "prop-type" || attrName === "at") {
element.insertBefore(formattedAttr, element.firstChild);
} else {
element.appendChild(formattedAttr);
Expand Down Expand Up @@ -44,4 +44,14 @@ document.addEventListener("DOMContentLoaded", function () {
);
}
});

// Add formatted attributes for 'at'
document
.querySelectorAll(".method-subheader[at]")
.forEach((method) => {
const atValue = method.getAttribute("at");
if (atValue && atValue.trim() !== "") {
createFormattedAttribute(method, "at", atValue);
}
});
});
2 changes: 1 addition & 1 deletion effortless/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit b052f84

Please sign in to comment.