autofile.model¶
defines the filesystem model
- class autofile.model.DataFile(name, writer_=<function DataFile.<lambda>>, reader_=<function DataFile.<lambda>>)¶
file manager for a given datatype
- Parameters
name (str) – the file name
writer (callable[object->str]) – writes data to a string
reader (callable[str->object]) – reads data from a string
removable (bool) – Is this file removable?
- path(dir_pth)¶
file path
- Parameters
dir_pth (str) – directory path
- Returns
datafile path
- Return type
str
- exists(dir_pth)¶
does this file exist?
- Parameters
dir_pth (str) – directory path
- Returns
existance of datafile
- Return type
bool
- write(val, dir_pth)¶
write data to this file
- Parameters
val (int/float/str/tuple) – value to be written
dir_pth (str) – directory path
- read(dir_pth)¶
read data from this file
- Parameters
dir_pth (str) – directory path
- Returns
datafile contents
- Return type
int/float/str/tuple
- remove(dir_pth)¶
remove this file
(only possible if removable attribute is set to True)
- Parameters
dir_pth (str) – directory path
- class autofile.model.DataSeries(prefix, map_, nlocs, depth, loc_dfile=None, root_ds=None, removable=False)¶
directory manager mapping locator values to a directory series
- Parameters
map – maps nlocs locators to a segment path consisting of depth directories
info_map – maps nlocs locators to an information object, to be written in the data directory
- add_data_files(dfile_dct)¶
add DataFiles to the DataSeries
- path(locs=())¶
absolute directory path
- exists(locs=())¶
does this directory exist?
- remove(locs=())¶
remove this directory
(only possible if removable attribute is set to True)
- create(locs=())¶
create a directory at this prefix
- existing(root_locs=(), relative=False, ignore_bad_formats=True)¶
return the list of locators for existing paths
- json_path(json_layer=None)¶
json file path
- json_exists(json_layer=None)¶
does this file exist?
- json_existing(locs=(), json_layer=None)¶
returns a list of locations (aka keys) in the json file
- map(locs)¶
returns a list of mapped locations
- add_json_entries(entry_dct)¶
add DataFiles to the DataSeries
- json_create(json_layer=None)¶
json file creation
- root_locator_count()¶
count the number of root locator values recursively
- class autofile.model.DataSeriesFile(dseries, dfile)¶
file manager mapping locator values to files in a directory series
- path(locs=())¶
absolute file path
- exists(locs=())¶
does this file exist?
- write(val, locs=())¶
write data to this file
- read(locs=())¶
read data from this file
- remove(locs=())¶
remove this file
(only possible if removable attribute is set to True)
- class autofile.model.JSONObject(name, json_prefix=(None, None), removable=False, writer_=<function JSONObject.<lambda>>, reader_=<function JSONObject.<lambda>>)¶
json manager
- add_layer(key)¶
add a key to the json loc list
- exists(key, path)¶
check existance of a json
- read(key, path)¶
read a key out of a json file
- read_all(keys, path)¶
read a key out of a json file for
many keys
- write(val, key, path)¶
write a value for a key in a json
- write_all(vals, all_keys, path)¶
write values for multiple keys in a json
- class autofile.model.JSONEntry(jseries, jobject)¶
json manager for a given datatype
- exists(key='database_entry', mapping=True)¶
does this entry exist?
- existing(key=())¶
returns the keys nested under this key
- write(val, key='database_entry', mapping=True)¶
write data to this file
- write_all(vals, keys='database_entry', mapping=True)¶
write data to this file
- read(key='database_entry', mapping=True)¶
read data from this file
- read_all(keys='database_entry', mapping=True)¶
read data from this file
- autofile.model.read_json(path)¶
read a json
- autofile.model.write_json(json_data, path)¶
write a json
- autofile.model.items(path)¶
what are the parent keys in this json file