auralib | Aura's Python Library
auralib is mostly a way for me to reuse some functions I use a lot in my projects, and a learning exercise. Feel free to use these for your own projects if you want though.
Install
-
Install Python 3.x
-
Open a command prompt window and enter:
pip install auralib
Modules & Functions
aura_cmd.py
run_command() runs a command line command. Options to use shell and print output.
run_command(
command: str | list[str],
print_output: bool = False,
use_shell: bool = False
) -> None
aura_config.py
read_config() reads a configuration file in INI format and returns it as a dictionary, with data types formatted according to the first character of keys (b: boolean, d: dictionary, f: float, i: integer, l: list, o: set s: string, t: tuple). It allows you to use a variable value to start file paths at the current working directory; option keys must begin or end with specified strings. It also has options to preserve/ignore the case of keys, enable debug logging, and specify custom values for boolean and current working directory variables.
read_config(
file_path: str,
preserve_key_case: bool = False,
comment_prefixes: tuple[str] = (";", "#", "//"),
inline_comment_prefixes: tuple[str] = (";", "#", "//"),
root_dir_key: tuple[str] | str = ("PATH", "Path", "path"),
root_dir_value: str = "[ROOT]",
root_path: str | None = None,
bool_case_sens: bool = False,
bool_true: tuple[str] | str = ("TRUE", "True", "true", "T", "t", "1"),
bool_false: tuple[str] | str = ("FALSE", "False", "false", "F", "f", "0")
) -> dict[str, dict[str]]
aura_files.py
copy_file() copies a file from one path to another. You can optionally forcibly copy all possible metadata and overwrite an existing file.
copy_file(
source_path: str,
destination_path: str,
force_metadata: bool = False,
force_overwrite: bool = False
) -> None
copy_folder() copies a directory from one path to another. Optionally, you may forcibly copy all possible metadata and overwrite an existing directory.
copy_folder(
source_path: str,
destination_path: str,
force_metadata: bool = True,
force_overwrite: bool = False
) -> None
delete_file() deletes a file.
delete_file(
file_path: str | tuple[str]
) -> None
delete_folder() deletes a directory.
delete_folder(
file_path: str | tuple[str]
) -> None
get_base_path() gets only the directory elements from a path to a file. Eg: c:\example\folders
get_base_path(
file_path: str
) -> str
get_file_name() gets only the file element from a path. Includes the extension by default, but you can disable this. Eg: file.txt, file
get_file_name(
file_path: str
include_extension: bool = True
) -> str
get_file_extension() gets only the file extension from a path to a file. Includes the . by default, but you can disable this. Eg: .txt, txt
get_file_extension(
file_path: str
include_dot: bool = True
) -> str
get_root_path() gets the current working directory path.
get_root_path() -> str
has_extension() checks if a path or string ends with an extension or one of a list/tuple of extensions.
has_extension(
file_path: str,
extensions: str | list[str] | tuple[str]
) -> bool
is_file() checks if a file exists at a path.
is_file(
file_path: str
) -> bool
is_file_with_extension() checks in a file exists at a path and ends with an extension or one of a list/tuple of extensions.
is_file_with_extension(
file_path: str,
extensions: str | list[str] | tuple[str]
) -> bool
is_folder() checks if a folder exists at a path.
is_folder(
file_path: str
) -> bool
move_files() moves a single file or a list/tuple of files into a specified folder. If moving a single file you can specify a file name, allowing renaming, however this is not supported with multiple files.
move_files(
source_path: str | list[str] | tuple[str],
destination_path: str,
force_overwrite: bool = False
) -> None
move_folders() moves a single folder or a list/tuple of folders into a specified folder.
move_folders(
source_path: str | list[str] | tuple[str],
destination_path: str
) -> None
rename_file() renames a single file to a new name, including extension. Optionally, you may specify a full file path to move the file as well.
rename_file(
file_path: str,
new_name: str
) -> None
rename_folder() renames a single folder to a new name. Optionally, you may specify a full file path to move the folder as well.
rename_folder(
file_path: str,
new_name: str
) -> None
aura_json.py
escape_json_string() replaces common dangerous characters in a string with their json-escaped equivalents, allowing them to be used in json files.
escape_json_string(
string: str
) -> str
aura_skyrim.py
is_bethesda_plugin() checks if a string ends in .esp, .esm, or .esl. By default it also checks if the string is a path to a file.
is_bethesda_plugin(
file_path: str,
check_if_file: bool = True
) -> bool
aura_type.py
get_type() gets the type of some data and returns it as a string.
get_type(
data: any
) -> str
str_to_bool() turns a string into a boolean. Uses a list of values to consider as true/false that you can optionally override.
str_to_bool(
string: str,
case_sensitive: bool = False,
true_values: list[str] | tuple[str] | str = ("TRUE", "True", "true", "T", "t", "1"),
false_values: list[str] | tuple[str] | str = ("FALSE", "False", "false", "F", "f", "0")
) -> bool
str_to_dict() turns a string into a dictionary.
str_to_dict(
string: str
) -> bool
str_to_float() turns a string into a float.
str_to_float(
string: str
) -> bool
str_to_int() turns a string into a integer.
str_to_int(
string: str
) -> bool
str_to_list() turns a string into a list.
str_to_list(
string: str
) -> bool
str_to_set() turns a string into a set.
str_to_set(
string: str
) -> bool
str_to_tuple() turns a string into a tuple.
str_to_tuple(
string: str
) -> bool
aura_xml.py
escape_xml_string() replaces common dangerous characters in a string with their xml-escaped equivalents, allowing them to be used in xml files.
escape_xml_string(
string: str,
fomod: bool = False
) -> str
License
Metadata
Release files for auralib 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| auralib-0.0.4.tar.gz | 11.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| auralib-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.6 kB
Release files / auralib-0.0.4.tar.gz
| Download URL | auralib-0.0.4.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b92520ac8ef6506af1b82fe9a10f8e9173f044de078addfb0d48c5a5e755e3a8
|
|
BLAKE2b-256 checksum How to use checksums |
cbea8ef3ccbfabd95b3799ede5459c61bc1771e5e1ad922ba1bc0a235f4a0539
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / auralib-0.0.4-py3-none-any.whl
| Download URL | auralib-0.0.4-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e00af17beee2146a802154e519d8134fc8d01a186ccc6acfc27b934b23637e3f
|
|
BLAKE2b-256 checksum How to use checksums |
62edc511d6e5d4083084748002b29ed7968923b24aa7d1951e94e175c756a7c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|