pepys_import.utils package

Submodules

pepys_import.utils.branding_util module

pepys_import.utils.branding_util.render_text(font, text)[source]
pepys_import.utils.branding_util.show_software_meta_info(version, build_timestamp, db_type, db_name, db_host)[source]
pepys_import.utils.branding_util.show_welcome_banner(banner_text)[source]

pepys_import.utils.config_utils module

pepys_import.utils.config_utils.process(text)[source]

pepys_import.utils.data_store_utils module

exception pepys_import.utils.data_store_utils.MissingDataException[source]

Bases: Exception

pepys_import.utils.data_store_utils.cache_results_if_not_none(cache_attribute)[source]
pepys_import.utils.data_store_utils.chunked_list(lst, size)[source]

Split a list into multiple chunks of length size. Returns a list containing sublists of length size.

If the list doesn’t divide by size exactly, then the last sublist will have a length < size.

pepys_import.utils.data_store_utils.convert_edit_dict_columns(edit_dict, table_object)[source]
pepys_import.utils.data_store_utils.convert_objects_to_ids(items, table_obj)[source]
pepys_import.utils.data_store_utils.create_alembic_version_table(engine, db_type)[source]
pepys_import.utils.data_store_utils.create_spatial_tables_for_postgres(engine)[source]

Create schema pepys and extension for PostGIS

pepys_import.utils.data_store_utils.create_spatial_tables_for_sqlite(engine)[source]

Create geometry_columns and spatial_ref_sys metadata table

pepys_import.utils.data_store_utils.create_stored_procedures_for_postgres(engine)[source]
pepys_import.utils.data_store_utils.import_from_csv(data_store, path, files, change_id)[source]
pepys_import.utils.data_store_utils.import_synonyms(data_store, filepath, change_id)[source]
pepys_import.utils.data_store_utils.is_schema_created(engine, db_type)[source]

Returns True if Pepys Tables are created, False otherwise.

pepys_import.utils.data_store_utils.lowercase_or_none(obj)[source]
pepys_import.utils.data_store_utils.read_version_from_pepys_install(path)[source]
pepys_import.utils.data_store_utils.shorten_uuid(id)[source]

pepys_import.utils.datafile_utils module

pepys_import.utils.datafile_utils.hash_file(path)[source]

Hashes the file using its first megabyte

Parameters

path (String) – Full path of the file

Returns

Hashed value in hexadecimal format

Return type

String

pepys_import.utils.geoalchemy_utils module

pepys_import.utils.import_utils module

pepys_import.utils.import_utils.import_module_(file)[source]

Import modules using file object’s full path and name.

Parameters

file (File) – File object, which has name and full path attributes

pepys_import.utils.import_utils.import_validators(path)[source]

Import validators in the given path.

Parameters

path (String) – Path to the directory that has validators

Returns

pepys_import.utils.import_utils.sort_files(files)[source]

pepys_import.utils.unit_utils module

pepys_import.utils.unit_utils.acceptable_bearing_error(bearing1, bearing2, delta)[source]

Determines if the two bearings are more than a set angle apart, allowing for angles that span zero (North)

Parameters
  • bearing1 (number (degrees)) – The first bearing

  • bearing2 (number (degrees)) – The second bearing

  • delta (number (degrees)) – The acceptable separation

pepys_import.utils.unit_utils.bearing_between_two_points(first_location, second_location)[source]

Calculate the bearing(angle) between two points on the earth (specified in decimal degrees).

Parameters
  • first_location – First location point

  • second_location – Second location point

Returns

angle between two points in degrees

pepys_import.utils.unit_utils.convert_absolute_angle(angle, line_number, errors, error_type)[source]

Converts given absolute angle value to degree and does sanity checks

Parameters
  • angle (String) – Angle value in string format

  • line_number (String) – Line number

  • errors (List) – Error List to save value error if it raises

  • error_type (String) – Type of error

Returns

Returns a tuple of a boolean is_valid flag and the converted angle value

pepys_import.utils.unit_utils.convert_distance(distance, units, line_number, errors, error_type)[source]

Converts the given distance string to a Quantity consisting of a float value and the given units.

Parameters
  • distance (String) – distance value in string format

  • units (String) – units of distance for supplied measurement

  • line_number (String) – Line number

  • errors (List) – Error List to save value error if it raises

  • error_type (String) – Type of error

Returns

Returns a tuple of a boolean is_valid flag, and the converted distance value

pepys_import.utils.unit_utils.convert_frequency(frequency, units, line_number, errors, error_type)[source]

Converts the given frequency string to a Quantity containing a float value and the given units

Parameters
  • frequency (String) – frequency value in string format

  • units (String) – units of frequency for supplied measurement

  • line_number (String) – Line number

  • errors (List) – Error List to save value error if it raises

  • error_type (String) – Type of error

Returns

Returns a tuple of a boolean is_valid flag, and the converted frequency value

pepys_import.utils.unit_utils.convert_speed(speed, units, line_number, errors, error_type)[source]

Parses the given speed value into a float and assigns the given units

Parameters
  • speed (String) – Speed value in string format

  • units (pint unit) – Units of the speed (as a pint unit instance)

  • line_number (String) – Line number

  • errors (List) – Error List to save value error if it raises

  • error_type (String) – Type of error

Returns

Returns a tuple of a boolean is_valid flag, and the converted speed value

pepys_import.utils.unit_utils.distance_between_two_points_haversine(first_location, second_location)[source]

Calculate the great circle distance between two points on the earth (specified in decimal degrees).

Parameters
  • first_location – First location point

  • second_location – Second location point

Returns

distance in kilometers

pepys_import.utils.unit_utils.extract_points(location)[source]

Convert decimal degrees to radians and return

Parameters

location (Location) – A point of location

pepys_import.utils.value_transforming_utils module

pepys_import.utils.value_transforming_utils.format_datetime(datetime)[source]
Converts datetime to an appropriate format. The format is as follows:

YYMMDD HHMMSS.SSS (Date, either 2 of 4 figure date, followed by month then date, and Time)

Parameters

datetime (Datetime.Datetime) – Datetime of the object

Returns

Converted datetime

Return type

str

Module contents