pepys_import.resolvers package¶
Submodules¶
pepys_import.resolvers.command_line_input module¶
A basic function which creates a menu with title and choices.
- Parameters
cancel –
title (String) – Heading text
choices (List of strings) – Options to choose
completer (
prompt_toolkit.completion.FuzzyWordCompleter) – Optional argument that shows possible options while typing.validate_method (Function) – Possible validator function
- Returns
Entered choice
- Return type
String
pepys_import.resolvers.command_line_resolver module¶
- class pepys_import.resolvers.command_line_resolver.CommandLineResolver[source]¶
Bases:
pepys_import.resolvers.data_resolver.DataResolver- add_to_platforms(data_store, platform_name, identifier, platform_type, nationality, privacy, change_id)[source]¶
This method resolves platform type, nationality and privacy. It asks user whether to create a platform with resolved values or not. If user enters Yes, it returns all necessary data to create a platform. If user enters No, it resolves values again.
- Parameters
data_store (DataStore) – A
DataStoreobjectplatform_name (String) – Name of
Platformnationality (Nationality) – Name of
Nationalityplatform_type (PlatformType) – Name of
PlatformTypeprivacy (Privacy) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
- add_to_sensors(data_store, sensor_name, sensor_type, host_id, privacy, change_id)[source]¶
This method resolves sensor type and privacy. It returns existing or resolved sensor type and privacy entities.
- Parameters
data_store (DataStore) – A
DataStoreobjectsensor_name (Sensor) – Name of
Sensorsensor_type (SensorType) – Type of
Sensorprivacy (Privacy) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
- fuzzy_search_platform(data_store, platform_name, identifier, platform_type, nationality, privacy, change_id)[source]¶
This method parses all platforms in the DB, and uses fuzzy search when user is typing. If user enters a new value, it adds to Synonym or Platforms according to user’s choice. If user selects an existing value, it returns the selected Platform entity.
- Parameters
data_store (DataStore) – A
DataStoreobjectplatform_name (String) – Name of
Platformnationality (Nationality) – Name of
Nationalityplatform_type (PlatformType) – Name of
PlatformTypeprivacy (Privacy) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
- fuzzy_search_reference(data_store, change_id, data_type, db_class, field_name, help_id, search_help_id, text_name=None)[source]¶
This method parses any reference data according to the given parameters, and uses fuzzy search when user is typing. If user enters a new value, it adds to the related reference table or searches for an existing entity again. If user selects an existing value, it returns the selected entity.
- Parameters
data_store (DataStore) – A
DataStoreobjectchange_id (UUID) – ID of the
Changeobjectdata_type (String) – For which data type the reference is resolved(Platform, Sensor or Datafile)
db_class (SQLAlchemy Declarative Base Class) – Class of a Reference Table
field_name (String) – Name of the resolved data
text_name (String) – Printed name of the resolved data
help_id (Integer) – Integer ID of the help text for resolve reference
search_help_id (Integer) – Integer ID of the help text for fuzzy search reference
- Returns
- fuzzy_search_sensor(data_store, sensor_name, sensor_type, host_id, privacy, change_id)[source]¶
This method parses all sensors in the DB, and uses fuzzy search when user is typing. If user enters a new value, it adds to Sensor table or searches for an existing sensor again. If user selects an existing value, it returns the selected Sensor entity.
- Parameters
data_store (DataStore) – A
DataStoreobjectsensor_name (Sensor) – Name of
Sensorsensor_type (SensorType) – Type of
Sensorprivacy (Privacy) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
- reset_per_file_settings()[source]¶
Implementation method should do anything needed to reset per-file settings, such as whether to treat all platforms as unknown.
- resolve_datafile(data_store, datafile_name, datafile_type, privacy, change_id)[source]¶
This method resolves datafile type and privacy. It asks user whether to create a datafile with resolved values or not. If user enters Yes, it returns all necessary data to create a datafile. If user enters No, it resolves values again
- Parameters
data_store (DataStore) – A
DataStoreobjectdatafile_name (String) – Name of :class`Datafile`
datafile_type (String) – Type of :class`Datafile`
privacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
- resolve_missing_info(question, default_value, min_value=None, max_value=None, allow_empty=False)[source]¶
Implementation method should return the data for the given property name as asked for in the question
- Parameters
property_name – The name of the property asked for
question – The question to resolve
default_value – The default value to use if unresolved
min_value – The minimum value allowed for the result, optional
max_value – The maximum value allowed for the result, optional
allow_empty – Whether to allow an empty value (e.g. to accept default), optional
- Returns
The missing information requested
- resolve_platform(data_store, platform_name, identifier, platform_type, nationality, privacy, change_id, quadgraph=None)[source]¶
Implementation method should return any data necessary to create a platform. Currently: platform_name, platform_type, nationality, privacy.
- Parameters
data_store (DataStore) – A
DataStoreobjectplatform_name (String) – Name of
Platformnationality (String) – Name of
Nationalityplatform_type (String) – Name of
PlatformTypeprivacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobjectquadgraph (String) – The quadgraph that the platform is known by
- Returns
- resolve_reference(data_store, change_id, data_type, db_class, field_name, help_id, search_help_id, text_name=None)[source]¶
This method resolves any reference data according to the given parameters.
- Parameters
data_store (DataStore) – A
DataStoreobjectchange_id (UUID) – ID of the
Changeobjectdata_type (String) – For which data type the reference is resolved(Platform, Sensor or Datafile)
db_class (SQLAlchemy Declarative Base Class) – Class of a Reference Table
field_name (String) – Name of the resolved data
text_name (String) – Printed name of the resolved data
help_id (Integer) – Integer ID of the help text for resolve reference
search_help_id (Integer) – Integer ID of the help text for fuzzy search reference
- Returns
- resolve_sensor(data_store, sensor_name, sensor_type, host_id, privacy, change_id)[source]¶
Implementation method should return any data necessary to create a sensor. Currently: sensor_name, sensor_type.
- Parameters
data_store (DataStore) – A
DataStoreobjectsensor_name (String) – Name of
Sensorsensor_type (String) – Type of
Sensorhost_id (UUID) – Host Platform’s UUID
privacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
pepys_import.resolvers.data_resolver module¶
- class pepys_import.resolvers.data_resolver.DataResolver[source]¶
Bases:
abc.ABC- abstract reset_per_file_settings()[source]¶
Implementation method should do anything needed to reset per-file settings, such as whether to treat all platforms as unknown.
- abstract resolve_datafile(data_store, datafile_name, datafile_type, privacy, change_id)[source]¶
Implementation method should return any data necessary to create a datafile. Currently: datafile_type, privacy
- Parameters
data_store (DataStore) – A
DataStoreobjectdatafile_name (String) – Name of :class`Datafile`
datafile_type (String) – Type of :class`Datafile`
privacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
- abstract resolve_missing_info(question, default_value, min_value=None, max_value=None, allow_empty=False)[source]¶
Implementation method should return the data for the given property name as asked for in the question
- Parameters
property_name – The name of the property asked for
question – The question to resolve
default_value – The default value to use if unresolved
min_value – The minimum value allowed for the result, optional
max_value – The maximum value allowed for the result, optional
allow_empty – Whether to allow an empty value (e.g. to accept default), optional
- Returns
The missing information requested
- abstract resolve_platform(data_store, platform_name, identifier, platform_type, nationality, privacy, change_id, quadgraph=None)[source]¶
Implementation method should return any data necessary to create a platform. Currently: platform_name, platform_type, nationality, privacy.
- Parameters
data_store (DataStore) – A
DataStoreobjectplatform_name (String) – Name of
Platformnationality (String) – Name of
Nationalityplatform_type (String) – Name of
PlatformTypeprivacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobjectquadgraph (String) – The quadgraph that the platform is known by
- Returns
- abstract resolve_sensor(data_store, sensor_name, sensor_type, host_id, privacy, change_id)[source]¶
Implementation method should return any data necessary to create a sensor. Currently: sensor_name, sensor_type.
- Parameters
data_store (DataStore) – A
DataStoreobjectsensor_name (String) – Name of
Sensorsensor_type (String) – Type of
Sensorhost_id (UUID) – Host Platform’s UUID
privacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
pepys_import.resolvers.default_resolver module¶
- class pepys_import.resolvers.default_resolver.DefaultResolver[source]¶
Bases:
pepys_import.resolvers.data_resolver.DataResolver- default_datafile_name = 'DATAFILE-1'¶
- default_datafile_type = 'DATAFILE-TYPE-1'¶
- default_identifier = '123'¶
- default_nationality = 'UK'¶
- default_platform_name = 'PLATFORM-1'¶
- default_platform_type = 'Naval - frigate'¶
- default_privacy = 'Public'¶
- default_privacy_level = 10¶
- default_quadgraph = 'PLT1'¶
- default_sensor_name = 'SENSOR-1'¶
- default_sensor_type = 'Position'¶
- default_trigraph = 'PL1'¶
- reset_per_file_settings()[source]¶
Implementation method should do anything needed to reset per-file settings, such as whether to treat all platforms as unknown.
- resolve_datafile(data_store, datafile_name, datafile_type, privacy, change_id)[source]¶
Implementation method should return any data necessary to create a datafile. Currently: datafile_type, privacy
- Parameters
data_store (DataStore) – A
DataStoreobjectdatafile_name (String) – Name of :class`Datafile`
datafile_type (String) – Type of :class`Datafile`
privacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns
- resolve_missing_info(question, default_value, min_value=None, max_value=None, allow_empty=False)[source]¶
Implementation method should return the data for the given property name as asked for in the question
- Parameters
property_name – The name of the property asked for
question – The question to resolve
default_value – The default value to use if unresolved
min_value – The minimum value allowed for the result, optional
max_value – The maximum value allowed for the result, optional
allow_empty – Whether to allow an empty value (e.g. to accept default), optional
- Returns
The missing information requested
- resolve_platform(data_store, platform_name, identifier, platform_type, nationality, privacy, change_id, quadgraph=None)[source]¶
Implementation method should return any data necessary to create a platform. Currently: platform_name, platform_type, nationality, privacy.
- Parameters
data_store (DataStore) – A
DataStoreobjectplatform_name (String) – Name of
Platformnationality (String) – Name of
Nationalityplatform_type (String) – Name of
PlatformTypeprivacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobjectquadgraph (String) – The quadgraph that the platform is known by
- Returns
- resolve_privacy(data_store, change_id, data_type=None)[source]¶
Implementation method should return any data necessary to create a privacy. Currently: name
- Parameters
data_store (DataStore) – A
DataStoreobjectchange_id (UUID) – ID of the
Changeobjectdata_type (String) – Type of the data: datafile, platform or sensor
- Returns
- resolve_sensor(data_store, sensor_name, sensor_type, host_id, privacy, change_id)[source]¶
Implementation method should return any data necessary to create a sensor. Currently: sensor_name, sensor_type.
- Parameters
data_store (DataStore) – A
DataStoreobjectsensor_name (String) – Name of
Sensorsensor_type (String) – Type of
Sensorhost_id (UUID) – Host Platform’s UUID
privacy (String) – Name of
Privacychange_id (UUID) – ID of the
Changeobject
- Returns