Serialize Python modules and packages
Project description
Paker
Paker is module for serializing and deserializing Python modules and packages. It was inspired by httpimporter.
How it works
Paker dumps entire package structure to JSON dict. When loading package back, package is recreated with its submodules and subpackages.
Installation
From PyPI
pip install paker
From source
git clone https://github.com/desty2k/paker.git
cd paker
pip install .
Usage
In these examples we will use paker to serialize mss package.
CLI
To dump module to JSON dict use dump
command:
paker dump mss
To recreate module from JSON dict use load
:
paker load mss.json
In Python script
import paker
import logging
file = "mss.json"
logging.basicConfig(level=logging.NOTSET)
# install mss using `pip install mss`
# serialize module
with open(file, "w+") as f:
paker.dump("mss", f, indent=4)
# now you can uninstall mss using `pip uninstall mss -y`
# load package back from dump file
with open(file, "r") as f:
loader = paker.load(f)
import mss
with mss.mss() as sct:
sct.shot()
# remove loader and clean the cache
loader.unload()
# this will throw error
import mss
Bugs
Loading modules from .pyd
files does not work.
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
paker-0.3.3.tar.gz
(7.3 kB
view hashes)
Built Distribution
paker-0.3.3-py3-none-any.whl
(8.8 kB
view hashes)