snowex_db.utilities module#
Module for storing misc. type functions that don’t warrant a separate module but to provide some use in the code set.
- snowex_db.utilities.assign_default_kwargs(object, kwargs, defaults, leave=[])[source]#
Assign keyword arguments to class attributes. If a key in the default is not in the kwargs then its value becomes the value in the default. Any value found in the defaults is removed from the kwargs
- Args:
object: Object to assign as keys in defaults as attributes kwargs: Dictionary of keyword arguments provided defaults: Dictionary of all class related arguments that are assigned as attributes leave: List of attributes to leave in mod_kwargs
- Returns:
mod_kwargs: kwargs with all keys in the defaults removed from it.
- snowex_db.utilities.find_files(directory, ext, pattern)[source]#
Finds filesnames using the extension and a substring pattern
- Args:
directory: Directory to search ext: File extension to search for pattern: Substring to search for in the file basename
- snowex_db.utilities.find_kw_in_lines(kw, lines, addon_str=' = ')[source]#
Returns the index of a list of strings that had a kw in it
- Args:
kw: Keyword to find in a line lines: List of strings to search for the keyword addon_str: String to append to your key word to help filter
- Return:
i: Integer of the index of a line containing a kw. -1 otherwise
- snowex_db.utilities.get_file_creation_date(file)[source]#
Returns the files creation date as a datetime object. Useful for assuming a date accessed of data for NSIDC citation
- Args:
file:
- Returns:
- result: A datetime object of when the file was created according to
the system
- snowex_db.utilities.get_logger(name, debug=True, ext_logger=None)[source]#
Retrieve a colored logs logger and assign a custom name to it.
- Args:
name: Name of the loggger debug: Boolean for where to show debug statements ext_logger: Recieves a logger object and installs colored logs to it.
- Returns:
log: Logger object with colored logs installed
- snowex_db.utilities.get_site_id_from_filename(filename: str, regex: str) str[source]#
Get the site ID based on the site code in the filename from the pit files