mdpo.io module
mdpo I/O utilities.
- mdpo.io.environ(**env)
Overwrite temporarily some environment variables.
- mdpo.io.filter_paths(filepaths, ignore_paths=frozenset({}))
Filter a list of paths removing those defined in other list of paths.
The paths to filter can be defined in the list of paths to ignore in several forms:
The same string.
Only the file name.
Only their direct directory name.
Their direct directory full path.
- mdpo.io.flatten(xss)
Flatten a iterable of iterables.
- mdpo.io.save_file_checking_file_changed(filepath, content, encoding='utf-8')
Save a file checking if the content has changed.
- Parameters:
filepath (
polib.POFile
) – Path to the file to save.content (str) – Content to save.
encoding (str) – Encoding to use when saving the file.
- Returns:
If the PO file content has been changed.
- Return type:
- mdpo.io.to_file_content_if_is_file(value, encoding='utf-8')
Check if the value passed is a file path or string content.
If is a file, reads its content and returns it, otherwise returns the string passed as is.
- mdpo.io.to_files_or_content(value)
File path/glob/content disambiguator.
Check if the value passed is a glob, a set of files in a list or is string content.
- Parameters:
value (str) – Value to check.
- Returns:
Two values being the first a boolean that indicates if
value
is a list of files (True
) or string content (False
) and the second value is the content, which could be an iterator (if a glob or a list of files is passed or a string).- Return type: