luptai.common package

Module contents

Home of misc modules that are used across the LUPTAI Core.

Subpackages

luptai.common.extract_and_save module

luptai.common.geometry_snapping module

luptai.common.gtfs_translation module

luptai.common.logger module

Low effort logging utility to convert print statements to logging output.

Inferior to ordinary logging as we lose the reference to the original line number / file the message was emitted from. Given that these were converted print statements (where we didn’t have this anyway) that’s not a huge loss

Probably fixable in python 3.8 with the stacklevel parameter (https://stackoverflow.com/questions/19615876/showing-the-right-funcname-when-wrapping-logger-functionality-in-a-custom-class) Alternatively, could write an sprint function, or print with StringIo and use the usual logger calls, where the argument is sprint(*args)

log_debug_from_print_syntax(*args, sep=' ', end='\n', file=None, **kwargs)

Convenience method to convert debug print statements into logging output with a single find-replace.

log_error_from_print_syntax(*args, sep=' ', end='\n', file=None, **kwargs)

Convenience method to convert debug print statements into logging output with a single find-replace.

log_warning_from_print_syntax(*args, sep=' ', end='\n', file=None, **kwargs)

Convenience method to convert debug print statements into logging output with a single find-replace.

luptai.common.pathlib module

Python 2/3 compatibility of pathlib module.

mkdir_p(dir)

Make a directory and all it’s parents without making a fuss.

luptai.common.ptm_translation module

luptai.common.spatialite_tools module

Common operations for working with Spatialite.

add_mod_spatialite_path()

Ensure that the spatialite dll is on the path.

engine_listener(dbapi_conn, _connection_record)

Set up a listener to augment sqlalchemy connections with spatialite and foreign_key support.

initialise_spatial_cols(db_path, geom_col_dict, srid)

Add spatial columns to the given database.

Typically, geom_col_dict has entries of the form (table_name, geom_type) Optionally, it can be of the form (table_name, geom_name, geom_type) for the case where there are multiple geometry columns attached to the table_name and they do not use the default name geom_col_name. Second argument to list should be of type SpatialiteGeomType = Literal[“POINT”, “MULTIPOINT”, “POLYGON”, “MULTIPOLYGON”]

spatial_connection(db_path)

Conveniently get a spatialite db connection as a context manager.

spatialise_db(db_path)

Ensure that the spatialite dll is on the path and the given db is spatial enabled.