mnp.utils
Module Contents
Classes
Child of list to make a weak referencable list. See https://docs.python.org/3/library/weakref.html This is used to make weak references to the species model lists. |
|
For coloring cli outputs, thanks to: https://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output |
Functions
Copy log file from temporary storing location to cover location Returns ——- |
|
Clear all files temporarly stored Returns ——- |
|
Taken from https://github.com/django/django/blob/master/django/utils/text.py Convert to ASCII if ‘allow_unicode’ is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren’t alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores. |
|
Store a section from the configuration to a pkl file in a temporary location |
|
create scenario cover based on the cover design |
|
Save a section in the parameters to a csv file with key value pairs. |
|
list source and destination paths of input rasters and tables. |
|
copy input file |
|
Make geospatial profile from one of the HSI input rasters. |
Data
API
- mnp.utils.LOG_FILE_NAME = 'log_file.txt'
- mnp.utils.TEMP_DIR = 'mkdtemp(...)'
- class mnp.utils.List
Bases:
listChild of list to make a weak referencable list. See https://docs.python.org/3/library/weakref.html This is used to make weak references to the species model lists.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class mnp.utils.CustomFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)
Bases:
logging.FormatterFor coloring cli outputs, thanks to: https://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output
Initialization
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.
Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting,
str.format()({}) formatting orstring.Templateformatting in your format string.Changed in version 3.2: Added the
styleparameter.- grey = '\x1b[38;20m'
- yellow = '\x1b[38;5;214m'
- red = '\x1b[31;20m'
- bold_red = '\x1b[31;1m'
- cyan = '\x1b[38;5;33m'
- reset = '\x1b[0m'
- time = '%(asctime)s'
- levelname = '%(levelname)s'
- funcname = '%(funcName)s'
- message = '%(message)s'
- FORMATS = None
- format(record)
- mnp.utils.get_logger()
- mnp.utils.log_start_completed(func)
- mnp.utils.log_file_to_cover(folders: dict)
Copy log file from temporary storing location to cover location Returns ——-
- mnp.utils.clear_temp()
Clear all files temporarly stored Returns ——-
- mnp.utils.slugify(value, allow_unicode=False)
Taken from https://github.com/django/django/blob/master/django/utils/text.py Convert to ASCII if ‘allow_unicode’ is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren’t alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores.
- mnp.utils.config_info_to_temp(configuration: configparser.ConfigParser, section: str, key: str, dest: str) bool
Store a section from the configuration to a pkl file in a temporary location
configuration: output from read_ini
- mnp.utils.create_directories(folders: dict) None
create scenario cover based on the cover design
directory tree in cover root
- mnp.utils.config_section_to_cover(configuration: configparser.ConfigParser, section: str, cover_dir: str)
Save a section in the parameters to a csv file with key value pairs.
- mnp.utils.add_dynamics_to_config(configuration: configparser.ConfigParser)
- mnp.utils.list_sources_destinations(input_pathway, folders: dict, configuration: configparser.ConfigParser) tuple
list source and destination paths of input rasters and tables.
- configuration
The configuration for this mnp run as provided by user
- folders
Dictionary of folders in cover for this mnp run
- input_pathwayInputPathway
Class defining which input steps to take
([src1, src2, .. src_n], [dest1, dest2, .. dest_n])
- mnp.utils.copy_input_file(source: str, destination: str)
copy input file
- destinationstr
Path of the destination file
- sourcestr
Path for the source file
- mnp.utils.geo_profile_from_hsi(folders: dict)
Make geospatial profile from one of the HSI input rasters.