The Pythonic Archive Kit
Project description
PAK: Picklable and Encrypted Recursive Namespace
PAK is a simple, recursive namespace that can be pickled and encrypted.
Installation
pip install pythonic_archive_kit
if you wish to use the full implementation, you can run:
pip install pythonic_archive_kit[encryption]
Updating
pip install --upgrade pythonic_archive_kit
Requirements
Optionally the cryptography package can be installed to use the full implementation.
pip install cryptography
Usage
The PAK class provides a way to create a recursive namespace that can be pickled and encrypted.
Classes
PAK
class PAK(SimpleNamespace):
"""This is the core of the PAK system. It is a recursive namespace that can be pickled and encrypted."""
# ...
Methods
save(data, path, password=None)
def save(data, path, password=None):
"""Save a PAK file to disk."""
# ...
load(path, password=None, create=True)
def load(path, password=None, create=True):
"""Load a PAK file from disk. If create is True, a new PAK file will be created if one does not exist."""
# ...
open_pak(path, password=None, create=True)
@contextlib.contextmanager
def open_pak(path, password=None, create=True):
"""Open a PAK file from disk. If create is True, a new PAK file will be created if one does not exist. Saves the PAK file on exit."""
# ...
Examples
Importing
from pythonic_archive_kit import save_pak, load_pak, open_pak
This will import the standard interface. If cryptography is installed, this will use the main PAK implementation.
If cryptography is not installed, this will use the fallback MiniPAK implementation.
### RPG Save Data
Here's an example of using PAK to save and load player data for an RPG game:
```py
# Save player data
with open_pak("player_data.pak") as player_data:
player_data.stats.level = 10
player_data.inventory.gold = 500
player_data.inventory.items = ["sword", "shield"]
# Load player data
with open_pak("player_data.pak") as player_data:
print(player_data.stats.level) # Output: 10
Project Management
PAK can also be used for managing project data:
# Save project data
with open_pak("project_data.pak") as project:
project.name = "My Awesome Project"
project.tasks = ["design", "implementation", "testing"]
# Load project data
with open_pak("project_data.pak") as project:
print(project.name) # Output: My Awesome Project
Personal Notes
Even for personal note-taking, PAK can be useful:
# Save personal notes
with open_pak("personal_notes.pak") as notes:
notes.journal.day1 = "Visited the park"
notes.reminders = ["Buy groceries", "Call mom"]
# Load personal notes
with open_pak("personal_notes.pak") as notes:
print(notes.journal.day1) # Output: Visited the park
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pythonic_archive_kit-1.0.11.tar.gz.
File metadata
- Download URL: pythonic_archive_kit-1.0.11.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0167776abc77ef91aa29e5b2b834ea7fa9f734221cb3bf73748d85735d0256ce
|
|
| MD5 |
f74bed30c9d6b7740acb4ec5fdde32d8
|
|
| BLAKE2b-256 |
23688927c3d79cd721331683cfc9c33eede17c3f94aa73d95c4fe8d3c537dc22
|
File details
Details for the file pythonic_archive_kit-1.0.11-py2.py3-none-any.whl.
File metadata
- Download URL: pythonic_archive_kit-1.0.11-py2.py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
662473537caca7a7b3c31f9ee11f60a718a4e4f7777e3553448ea556a6c38441
|
|
| MD5 |
3e1dae3e9ad97c5b10a5a2d389f3d316
|
|
| BLAKE2b-256 |
1e75471e9ed16924cc181b3f093f0e4fffbe322554594feeea298b77f4976ea1
|