File system operation utils¶
-
moulinette.utils.filesystem.
read_file
(file_path)[source]¶ Read a regular text file
- Keyword argument:
- file_path – Path to the text file
-
moulinette.utils.filesystem.
read_json
(file_path)[source]¶ Read a json file
- Keyword argument:
- file_path – Path to the json file
-
moulinette.utils.filesystem.
read_yaml
(file_path)[source]¶ Safely read a yaml file
- Keyword argument:
- file_path – Path to the yaml file
-
moulinette.utils.filesystem.
read_toml
(file_path)[source]¶ Safely read a toml file
- Keyword argument:
- file_path – Path to the toml file
-
moulinette.utils.filesystem.
write_to_file
(file_path, data, file_mode='w')[source]¶ Write a single string or a list of string to a text file. The text file will be overwritten by default.
- Keyword argument:
- file_path – Path to the output file data – The data to write (must be a string or list of string) file_mode – Mode used when writing the file. Option meant to be used by append_to_file to avoid duplicating the code of this function.
-
moulinette.utils.filesystem.
append_to_file
(file_path, data)[source]¶ Append a single string or a list of string to a text file.
- Keyword argument:
- file_path – Path to the output file data – The data to write (must be a string or list of string)
-
moulinette.utils.filesystem.
write_to_json
(file_path, data)[source]¶ Write a dictionnary or a list to a json file
- Keyword argument:
- file_path – Path to the output json file data – The data to write (must be a dict or a list)
-
moulinette.utils.filesystem.
mkdir
(path, mode=511, parents=False, uid=None, gid=None, force=False)[source]¶ Create a directory with optional features
Create a directory and optionaly set its permissions to mode and its owner and/or group. If path refers to an existing path, nothing is done unless force is True.
- Keyword arguments:
- path – The directory to create
- mode – Numeric path mode to set
- parents – Make parent directories as needed
- uid – Numeric uid or user name
- gid – Numeric gid or group name
- force – Force directory creation and owning even if the path exists
-
moulinette.utils.filesystem.
chown
(path, uid=None, gid=None, recursive=False)[source]¶ Change the owner and/or group of a path
- Keyword arguments:
- uid – Numeric uid or user name
- gid – Numeric gid or group name
- recursive – Operate on path recursively