mads.object¶
JSON file backed objectect with dotted access.
-
class
Config
(name='', *args, **kwargs)[source]¶ Bases:
mads.object.Default
A Config objectect can read previous config from disk.
-
default
= ''¶
-
path
= 'cfg'¶
-
-
class
Default
(*args, **kwargs)[source]¶ Bases:
mads.object.Object
A object with a “default” set. Standard default return is Object().
Constructor that initializes a variable with Object() as a default.
-
class
Object
(*args, **kwargs)[source]¶ Bases:
dict
Dict with dotted access instead of brackets, with json files to sync and load from.
Construct an Object, dotted dictionairy access instead of brackets.
-
grep
(val)[source]¶ Grep for a matching stringified value, return a Object with those matching values.
-
load
(path=None, force=False, skip=[], full=True)[source]¶ Load a json file into this object. use skip as a list of keys to skip.
-
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.
-
read
(path)[source]¶ Read a json dump from given path, returning the json string with comments stripped.
-
register
(key, val, force=False)[source]¶ Register key, value and throw an exception is value is already set.
-
save
(fn='')[source]¶ Save this object. stime can be provided to give desired save time in the file name.
-
sync
(*args, **kwargs)¶
-