utils#

swmmio.version_control.utils.bi_is_current(build_instr_file)[source]#

check if a given build instruction file has any parent models whose date modified does not match the date modified of the parent INP file

swmmio.version_control.utils.bi_latest_parent_date_modified(vc_dir, parentname)[source]#

given a path to a version control directory of build instructions and the name of the parent model, return the parent model’s revision date

swmmio.version_control.utils.copy_rpts_hsf(from_dir: str, to_dir: str, search_dir: str)[source]#

Walk through a directory and find all .rpt and hot start (.hsf) files and copy them to another location based on the relative path from the to_dir.

Parameters:
from_dirstr

The source directory from which the relative path is derived.

to_dirstr

The destination directory where the files will be copied.

search_dirstr

The directory to search for .rpt and .hsf files.

Notes

This function is useful for copying model results written on a local drive to a network drive.

Examples

>>> to_directory = r'P:\02_Projects\SouthPhila\SE_SFR\MasterModels'
>>> from_dir = r'F:\models\SPhila\MasterModels_170104'
>>> search_dir = r'F:\models\SPhila\MasterModels_170104\Combinations'
>>> copy_rpts_hsf(from_dir, to_dir, search_dir)
swmmio.version_control.utils.modification_date(filename, string=True)[source]#

get modification datetime of a file credit: Christian Oudard ‘stackoverflow.com/questions/237079/how-to-get-file-creation-modification- date-times-in-python’

swmmio.version_control.utils.newest_file(directory)[source]#

return the newest file (most recent) in a given directory. Beware that people report the min / max to do different things per OS…

swmmio.version_control.utils.read_meta_data(filepath)[source]#
swmmio.version_control.utils.write_inp_section(file_object, allheaders, sectionheader, section_data, pad_top=True, na_fill='')[source]#

given an open file object, list of header sections, the current section header, and the section data in a Pandas Dataframe format, this function writes the data to the file object.

swmmio.version_control.utils.write_meta_data(file_object, metadicts)[source]#