Skip to main content
`Ctrl`+`K`

# ng911ok.lib.session module

Reads in configuration data from `config.yml`.

authors:

  Riley Baird (OK), Emma Baker (OK)

created:

  August 20, 2024

modified:

  May 12, 2025

class _NG911Config(gdb_info: NG911GeodatabaseInfo, domains: NG911DomainNamespace, fields: NG911FieldNamespace, feature_classes: NG911FeatureClassNamespace)

  Bases: `YAMLObject`

  Class containing data from `config.yml`.

  yaml_loader

    alias of `SafeLoader`

  classmethod from_yaml(loader: SafeLoader, node: Node)

    Convert a representation node to a Python object.

  _match_names(target: Literal['DOMAINS', 'FIELDS', 'FEATURE_CLASSES'], names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') → list[str | None]
  get_closest_field_name(name: str, fields: Collection[NG911Field | str] | None = None) → str | None

    Attempts to find the closest field name to name out of those in fields. Case and underscores are ignored during matching. If fields is `None`, all field names are considered. If the match is acceptably close, the match is returned (with the correct case). Otherwise, returns `None`.

    Parameters:

      - name (str) – The field name to search for

      - fields (Optional[Collection[NG911Field | str]]) – Optional list of `NG911Field` objects or field names to consider; default None

    Returns:

      The closest field name or `None`

    Return type:

      str | None

  get_domain_by_name(name: str, case_sensitive: bool = True) → NG911Domain

    Returns the instance of `NG911Domain` from `self.domains` with a `name` attribute equal to name.

    Parameters:

      - name (str) – `name` attribute of the domain

      - case_sensitive (bool) – Whether the case of `name` must match that of the domain, default True

    Returns:

      Domain with the given name

    Return type:

      NG911Domain

  get_feature_class_by_name(name: str, case_sensitive: bool = True) → NG911FeatureClass

    Returns the instance of `NG911FeatureClass` from `self.feature_classes` with a `name` attribute equal to name.

    This is an alternative to selecting a feature class by its `role` attribute, which, given a feature class with role “role_value”, would normally be done as `self.feature_classes.role_value` or `self.feature_classes["role_value"]`.

    Parameters:

      - name (str) – `name` attribute of the feature class

      - case_sensitive (bool) – Whether the case of `name` must match that of the feature class, default True

    Returns:

      Feature class with the given name

    Return type:

      NG911FeatureClass

  get_field_by_name(name: str, case_sensitive: bool = True) → NG911Field

    Returns the instance of `NG911Field` from `self.fields` with a `name` attribute equal to name.

    This is an alternative to selecting a field by its `role` attribute, which, given a field with role “role_value”, would normally be done as `self.fields.role_value` or `self.fields["role_value"]`.

    Parameters:

      - name (str) – `name` attribute of the field

      - case_sensitive (bool) – Whether the case of `name` must match that of the field, default True

    Returns:

      Field with the given name

    Return type:

      NG911Field

  match_domain_names(names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') → list[str | None]

    Given a case-insensitive sequence of domain names, return a list of the corresponding correctly-cased domain names.

    Valid values for on_mismatch are:

    - `"DROP"`: Silently skip the name

    - `"ERROR"`: Raise a `ValueError`

    - `"NONE"`: Append `None` to the results

    Parameters:

      - names (Sequence[str]) – Case-insensitive names to match

      - on_mismatch (Literal["DROP", "ERROR", "NONE"]) – Behavior if no match is found; default `"DROP"`

    Returns:

      List of correctly-cased domain names (and possibly `None` if on_mismatch is `"NONE"`)

    Return type:

      list[str | None]

  match_feature_class_names(names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') → list[str | None]

    Given a case-insensitive sequence of feature class names, return a list of the corresponding correctly-cased feature class names.

    Valid values for on_mismatch are:

    - `"DROP"`: Silently skip the name

    - `"ERROR"`: Raise a `ValueError`

    - `"NONE"`: Append `None` to the results

    Parameters:

      - names (Sequence[str]) – Case-insensitive names to match

      - on_mismatch (Literal["DROP", "ERROR", "NONE"]) – Behavior if no match is found; default `"DROP"`

    Returns:

      List of correctly-cased feature class names (and possibly `None` if on_mismatch is `"NONE"`)

    Return type:

      list[str | None]

  match_field_names(names: Sequence[str], on_mismatch: Literal['DROP', 'ERROR', 'NONE'] = 'DROP') → list[str | None]

    Given a case-insensitive sequence of field names, return a list of the corresponding correctly-cased field names.

    Valid values for on_mismatch are:

    - `"DROP"`: Silently skip the name

    - `"ERROR"`: Raise a `ValueError`

    - `"NONE"`: Append `None` to the results

    Parameters:

      - names (Sequence[str]) – Case-insensitive names to match

      - on_mismatch (Literal["DROP", "ERROR", "NONE"]) – Behavior if no match is found; default `"DROP"`

    Returns:

      List of correctly-cased field names (and possibly `None` if on_mismatch is `"NONE"`)

    Return type:

      list[str | None]

  domains: NG911DomainNamespace

    Object containing information about the domains specified in the Standard. The namespace is designed to facilitate autocompletion.

  feature_class_info: dict[str, IterableNamespace[str | list[str]]]

    Dictionary of feature class information: name, geometry_type, fields (list)

    Deprecated since version 3.0.0-alpha.2: Use `feature_classes` instead.

  feature_classes: NG911FeatureClassNamespace

    Object containing information about the feature class schemas specified in the Standard. The namespace is designed to facilitate autocompletion.

  field_info: dict[str, IterableNamespace[str | int | IterableNamespace[str | dict[str, str]] | None]]

    Dictionary of all fields with field properties

    Deprecated since version 3.0.0-alpha.2: Use `fields` instead.

  field_names: FrozenList[str]

    Returns a list of all of names (not roles) of all fields.

  fields: NG911FieldNamespace

    Object containing information about the fields specified in the Standard. The namespace is designed to facilitate autocompletion.

  gdb_info: NG911GeodatabaseInfo

    Object containing information that applies to the NG911 geodatabase or to multiple items therein.

  optional_feature_class_names: FrozenList[str]

    Returns a list of the names (not roles) of feature classes that are allowed in the optional feature dataset.

  required_feature_class_names: FrozenList[str]

    Returns a list of the names (not roles) of feature classes that belong in the required feature dataset.

  street_field_names: FrozenList[str]

    Returns a list of the names (not roles) of all the `NG911Field` objects relevant to computing the `
    FullName` field in `
    ROAD_CENTERLINE` and `
    ADDRESS_POINT`. Legacy fields are not included.

  street_fields: FrozenList[NG911Field]

    Returns a list of all the `NG911Field` objects relevant to computing the `
    FullName` field in `
    ROAD_CENTERLINE` and `
    ADDRESS_POINT`. Legacy fields are not included.

  yaml_tag = '!NG911Config'

_construct_domain_namespace(loader: Loader, node: Node) → NG911DomainNamespace

_construct_feature_class(loader: Loader, tag: str, node: Node) → NG911FeatureClass

_construct_feature_class_namespace(loader: Loader, node: Node) → NG911FeatureClassNamespace

_construct_field_namespace(loader: Loader, node: Node) → NG911FieldNamespace

config: _NG911Config = <ng911ok.lib.session._NG911Config object>

  The single instance of `_NG911Config`, containing data from the configuration file `config.yml`.