The Pythonic Archive Kit
Project description
PAK: Picklable and Encrypted Recursive Namespace
PAK is a Python library that provides a simple, recursive namespace that can be pickled and encrypted. It allows you to manage structured data with ease.
Features
-
Recursive Namespace: PAK offers a recursive namespace that can be used like a dictionary or an object. This allows for flexible and structured data management.
-
Pickling: PAK objects can be easily serialized using Python's built-in
pickle
module, making it convenient for saving and loading data. -
Encryption (Optional): PAK supports optional encryption of data using the
cryptography
package. This ensures the security of your PAK files. -
Magic Folder Integration: With the magic folder feature, you can dynamically import and manage PAK files from a specified folder.
Installation
You can install PAK using pip:
pip install pythonic_archive_kit
For the full implementation with encryption, use:
pip install pythonic_archive_kit[encryption]
Usage
Set the Magic Folder
Before importing any PAKs, you must set the magic folder using the set_magic_folder
function:
from pythonic_archive_kit import set_magic_folder
# Set the magic folder location
set_magic_folder("my_magic_folder")
Basic Usage
Now that you've set the magic folder, you can use PAK as follows:
from pythonic_archive_kit import PAK, save_pak, load_pak, open_pak
# Create a PAK object
pak = PAK()
pak.foo = "bar"
pak["baz"] = "qux"
# Save and load PAK objects
save_pak(pak, "example.pak")
loaded_pak = load_pak("example.pak")
Encryption (Optional)
To use encryption, ensure you have the cryptography
package installed. You can encrypt PAK data by providing a password:
from pythonic_archive_kit import save_pak, load_pak
# Save an encrypted PAK file
save_pak(pak, "encrypted.pak", password="mypassword")
# Load the encrypted PAK file
loaded_pak = load_pak("encrypted.pak", password="mypassword")
Examples
Here are some examples of how PAK can be used in different scenarios, including game development, project management, and personal note-taking.
RPG Save Data
# 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
# 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
# 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
Magic Folder Integration
The magic folder is .magic
by default. You can optionally set the magic folder, and can seamlessly work with PAK files located in that folder. Here's an example:
from pythonic_archive_kit.magic import set_magic_folder
# Set the magic folder location
set_magic_folder("my_magic_folder")
# once set you can use PAK files as follows
from pythonic_archive_kit.magic import my_pak
# Access PAK files with attribute-style syntax
my_pak.example_data = "Hello, PAK!"
# PAK files are automatically managed
In this example, my_pak
is automatically associated with a PAK file located in the magic folder. You can use it just like any other PAK object.
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
Hashes for pythonic_archive_kit-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 144d92bd79129bac5b6f4231d53ef4744d2468c07c0944f59022a7abf1bf7903 |
|
MD5 | 7b277ec2219923a40ce6c40ae877935b |
|
BLAKE2b-256 | f2eb065e55e3c2ae8fab3b4103d24100a58fc24065a10f4002d0f483e4b8cf02 |
Hashes for pythonic_archive_kit-1.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 640fbc152a6712d4b03be2b7a83547da1dc8d56aaa08c5755d6c74ecf0bb7edb |
|
MD5 | d25adfa0c4e50ae42d291d56b055fbb2 |
|
BLAKE2b-256 | dd4385724490dcee06a1de3007de75a1fef60e84289b053e9ecd1303ceb7bf59 |