general_tools package¶
Submodules¶
general_tools.file_utils module¶
-
general_tools.file_utils.
add_contents_to_zip
(zip_file, path, include_root=False)[source]¶ Zip the contents of <path> into <zip_file>.
Parameters: - zip_file (str|unicode) – The file name of the zip file
- path (str|unicode) – Full path of the directory to zip up
- include_root (bool) – If true, the zip file will start with the directory of the path parameter
-
general_tools.file_utils.
add_file_to_zip
(zip_file, file_name, arc_name=None, compress_type=None)[source]¶ Zip <file_name> into <zip_file> as <arc_name>.
Parameters: - zip_file (str|unicode) – The file name of the zip file
- file_name (str|unicode) – The name of the file to add, including the path
- arc_name (str|unicode) – The new name, with directories, of the file, the same as filename if not given
- compress_type (str|unicode) –
-
general_tools.file_utils.
copy_tree
(src, dst, symlinks=False, ignore=None)[source]¶ Recursively copy a directory and all subdirectories.
Parameters same as shutil.copytree
Parameters: - src –
- dst –
- symlinks –
- ignore –
Returns:
-
general_tools.file_utils.
get_files
(directory, relative_paths=False, include_directories=False, topdown=False, extensions=None, exclude=None)[source]¶
-
general_tools.file_utils.
load_json_object
(file_name, default=None)[source]¶ Deserialized JSON file <file_name> into a Python dict. :param str|unicode file_name: The name of the file to read :param default: The value to return if the file is not found
-
general_tools.file_utils.
load_yaml_object
(file_name, default=None)[source]¶ Deserialized YAML file <file_name> into a Python dict. :param str|unicode file_name: The name of the file to read :param default: The value to return if the file is not found
-
general_tools.file_utils.
make_dir
(dir_name, linux_mode=493, error_if_not_writable=False)[source]¶ Creates a directory, if it doesn’t exist already.
If the directory does exist, and <error_if_not_writable> is True, the directory will be checked for writability.
Parameters: - dir_name (str|unicode) – The name of the directory to create
- linux_mode (int) – The mode/permissions to set for the new directory expressed as an octal integer (ex. 0o755)
- error_if_not_writable (bool) – The name of the file to read
-
general_tools.file_utils.
unzip
(source_file, destination_dir)[source]¶ Unzips <source_file> into <destination_dir>.
Parameters: - source_file (str|unicode) – The name of the file to read
- destination_dir (str|unicode) – The name of the directory to write the unzipped files
-
general_tools.file_utils.
write_file
(file_name, file_contents, indent=None)[source]¶ Writes the <file_contents> to <file_name>.
If <file_contents> is not a string, it is serialized as JSON.
Parameters: - file_name (str|unicode) – The name of the file to write
- file_contents (str|unicode|object) – The string to write or the object to serialize
- indent (int) – Specify a value if you want the output formatted to be more easily readable
general_tools.print_utils module¶
general_tools.smartquotes module¶
general_tools.url_utils module¶
-
general_tools.url_utils.
get_languages
()[source]¶ Returns an array of over 7000 dictionaries.
Structure: [
- {
- cc: [“DJ”, “US”, “CA”], pk: 2, lr: “Africa”, ln: “Afaraf”, ang: “Afar”, gw: false, ld: “ltr”, alt: [“Afaraf”, “Danakil”], lc: aa
]