Config Module
- class pybacked.config.Configuration(name, storage, archive, diff_algorithm, compression_algorithm, compresslevel, hash_algorithm=None)
Class to hold all the data of a specific backup configuration. This can be seen as a collection of global variables which hold configuration data.
- Parameters
name (str) – The name that is given to the configuration. This is mainly a UI element to help the User distinguish between multiple configurations.
storage (str) – The directory on which to perform backups
archive (str) – The directory where for the backup-archive
diff_algorithm (int) – The desired diff method. One of (DIFF_CONT, DIFF_DATE, DIFF_HASH)
compression_algorithm (int) – The desired zip compression algorithm as given by the zipfile module.
compresslevel (int) – The desired zip compression level. Possible Values vary between compression algorithms but are always between in the span of 1-9. More information on the compression level can be found in the python documentation for the zipfile module
hash_algorithm (str, optional) – The desired hashing algorithm (only needed if DIFF_HASH is selected as the diff method). The available options can be found in the __init__.py file.
- get_dict()
Get a dictionary with all fields of the Configuration class represented as fieldname-value pairs.
- Returns
Returns the dictionary of all fields of the Configuration class
- Return type
dict
- pybacked.config.deserialize_config(data)
Create instances of Configuration class from a json-string containging config data.
- Parameters
data (str) – The json string containing the configuration data
- Returns
A list with Configuration class objects.
- Return type
List
- pybacked.config.read_config(filepath)
Read the config from a given config file.
- Parameters
filepath (str) – The path to the config file.
- Returns
The json deserialized list.
- Return type
list
- pybacked.config.serialize_config(config)
Returns the json-serialized string from Configuration object. This string can then be directly written to the .json file.
- Parameters
config (Configuration) – The Configuration object
- Returns
The json-serialized string of the Configuration object
- Return type
str
- pybacked.config.serialize_config_list(config_list)
Serialize a list of configs. This is used so that the user has the option to save multiple configs in a single file.
- Parameters
config_list (list) – A list of Configuration class objects
- Returns
A serialized json string which can directly be written to a config file.
- Return type
str
- pybacked.config.write_config(config_list, filepath)
Get the json string returned by serialize_config_list and write it to a given file.
- Parameters
config_list (list) – A list of Configuration objects
filepath (str) – The path to the config file, which will hold the config information.
- Returns
void
- Return type
None