pepys_import.resolvers package

Submodules

pepys_import.resolvers.command_line_input module

pepys_import.resolvers.command_line_input.create_menu(title, choices, cancel='import', completer=None, validate_method=None)[source]

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_input.get_fuzzy_completer(completer_list)[source]
pepys_import.resolvers.command_line_input.is_valid(option)[source]

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 DataStore object

  • platform_name (String) – Name of Platform

  • nationality (Nationality) – Name of Nationality

  • platform_type (PlatformType) – Name of PlatformType

  • privacy (Privacy) – Name of Privacy

  • change_id (UUID) – ID of the Change object

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 DataStore object

  • sensor_name (Sensor) – Name of Sensor

  • sensor_type (SensorType) – Type of Sensor

  • privacy (Privacy) – Name of Privacy

  • change_id (UUID) – ID of the Change object

Returns

add_unknown_platform(data_store, platform_name, change_id)[source]
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 DataStore object

  • platform_name (String) – Name of Platform

  • nationality (Nationality) – Name of Nationality

  • platform_type (PlatformType) – Name of PlatformType

  • privacy (Privacy) – Name of Privacy

  • change_id (UUID) – ID of the Change object

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 DataStore object

  • change_id (UUID) – ID of the Change object

  • data_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 DataStore object

  • sensor_name (Sensor) – Name of Sensor

  • sensor_type (SensorType) – Type of Sensor

  • privacy (Privacy) – Name of Privacy

  • change_id (UUID) – ID of the Change object

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 DataStore object

  • datafile_name (String) – Name of :class`Datafile`

  • datafile_type (String) – Type of :class`Datafile`

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

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 DataStore object

  • platform_name (String) – Name of Platform

  • nationality (String) – Name of Nationality

  • platform_type (String) – Name of PlatformType

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

  • quadgraph (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 DataStore object

  • change_id (UUID) – ID of the Change object

  • data_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 DataStore object

  • sensor_name (String) – Name of Sensor

  • sensor_type (String) – Type of Sensor

  • host_id (UUID) – Host Platform’s UUID

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

Returns

class pepys_import.resolvers.command_line_resolver.MinMaxValidator(minimum=None, maximum=None, allow_empty=False)[source]

Bases: prompt_toolkit.validation.Validator

A validator to check numerical values are between a given minimum/maximum value

validate(document)[source]

Validate the input. If invalid, this should raise a ValidationError.

Parameters

documentDocument instance.

pepys_import.resolvers.command_line_resolver.is_number(text)[source]

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 DataStore object

  • datafile_name (String) – Name of :class`Datafile`

  • datafile_type (String) – Type of :class`Datafile`

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

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 DataStore object

  • platform_name (String) – Name of Platform

  • nationality (String) – Name of Nationality

  • platform_type (String) – Name of PlatformType

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

  • quadgraph (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 DataStore object

  • sensor_name (String) – Name of Sensor

  • sensor_type (String) – Type of Sensor

  • host_id (UUID) – Host Platform’s UUID

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

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 DataStore object

  • datafile_name (String) – Name of :class`Datafile`

  • datafile_type (String) – Type of :class`Datafile`

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

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 DataStore object

  • platform_name (String) – Name of Platform

  • nationality (String) – Name of Nationality

  • platform_type (String) – Name of PlatformType

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

  • quadgraph (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 DataStore object

  • change_id (UUID) – ID of the Change object

  • data_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 DataStore object

  • sensor_name (String) – Name of Sensor

  • sensor_type (String) – Type of Sensor

  • host_id (UUID) – Host Platform’s UUID

  • privacy (String) – Name of Privacy

  • change_id (UUID) – ID of the Change object

Returns

Module contents