timestamped JSON objects.
OBJ is a package that provides an Object class that can save/load from disk, thus providing persistence to objects.
Files are saved with a timestamp in their filenames, so that searching in a time related manner becomes possible.
Modules are provided to query saved objects as well as to run objects with a thread to manage their state.
OBJ has a “no-clause MIT license” that should be the most liberal free license you can get at the year 2018.
cfg = Config()
cfg.workdir = os.path.join(os.path.expanduser(“~”), “.obj”)
you can change cfg.workdir if you need to save your objects in an other directory then the default directory.
cache(path: str) → Object
load this object from cache or read it from disk.
clear() → None
clear the ready flag.
format(keys=, skip=, nokeys=False, reverse=False) → str
return a displayable string from a list of attributes.
grep(val: str) → Object
return a new Object with the values that match provided val argument.
isSet() → bool
check whether ready flag is set.
load(path: str, force=False, skip=, full=True) → Object
load a json file into this object. use skip as a list of keys to skip.
loads(jsonstring: str) → Object
update with deconstructed (dict) json string.
merge(obj: Object) → Object
merge an object into this on, only set keys that are already present.
nice() → str
return a nicyfied JSON dump.
prepare() → str
prepare the object and return a string containing the “data” part.
pure() → str
return a sliced (no _ keys), indent=4, sort_key is True, json dump
read(path: str) → str
read a json dump from given path, returning the json string with comments stripped.
ready() → bool
signal this object as “ready”.
register(key, val, force=False) → None
register key, value - throw an exception if key is already set.
save(path=”“) → str
save a static (fix filepath) version of this object.
search(name: str) → Object
search this objects keys skipping keys that start with “_”.
sync(path=’‘) → str
sync to disk using provided/created path. this sync() method does the real saving to disk.
upgrade(input: dict) → None
upgrade this object with a dictionary, only setting attributes if they do not exist.
wait(timeout=None) → list
wait for this object’s ready flag and join all thread that have been started in handling this object,
key is already set.
the provided string is not JSON.
attemped to write outside of the workdir.
provided string is not a filename.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size obj-3.tar.gz (14.2 kB)||File type Source||Python version None||Upload date||Hashes View hashes|