botlib.object

JSON file backed objectect with dotted access.

Exceptions

ENODATE date cannot be determined.
ENOJSON string cannot be _parsed as JSON.
class Config(*args, **kwargs)[source]

Bases: botlib.object.Default

A Config objectect can read previous cfg from disk.

fromdisk(name)[source]
template(name)[source]
class Default(*args, **kwargs)[source]

Bases: botlib.object.Object

A object with a “default” set. Standard default return is Object().

class Object(*args, **kwargs)[source]

Bases: dict

Dict with dotted access instead of brackets, with json files to sync and load from.

clear()[source]

Clear the ready flag.

grep(val)[source]

Grep for a matching stringified value, return a Object with those matching values.

id(*args, **kwargs)[source]
isSet()[source]

Check whether ready flag is set.

last(*args, **kwargs)[source]
load(path, force=False, skip=[], full=True)[source]

Load a json file into this object. use skip as a list of keys to skip.

loads(s)[source]

Update with deconstructed (dict) json string.

merge(object)[source]
nice(*args, **kwargs)[source]

Return a nicyfied, indent=4, sort_key is True, json dump.

prepare()[source]
Prepare the object and return a string containing the “data” part.
Keyword can be “prefix” when using a subdirectory.
Use “saved” when savestamp need to be different from the “now” timestamp.
printable(keys=[], skip=[], nokeys=False)[source]

Determine from provided keys list and/or from skipping from a skiplist a displayable string from those attributes.

pure(*args, **kwargs)[source]

Return a sliced (no _ keys), indent=4, sort_key is True, json dump.

read(path)[source]

Read a json dump from given path, returning the json string with comments stripped.

ready()[source]

Signal this object as “ready”.

register(key, val, force=False)[source]

Register key, value and throw an exception is value is already set.

save(stime='')[source]

save a static (fix filepath) version of this object.

search(name)[source]

Search this objects keys skipping keys that start with “_”.

sync(*args, **kwargs)
wait(sec=None)[source]

Wait for this object’s ready flag.

dumped(o)[source]
slice(object, keys=[], skip=[], full=False)[source]

return a slice of an object.