+
+ +
+

aria.parser.presentation

+

Presentation package.

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
aria.parser.presentation.PresentationContextPresentation context.
aria.parser.presentation.PresenterExceptionARIA presenter exception.
aria.parser.presentation.PresenterNotFoundErrorARIA presenter error: presenter not found for raw.
aria.parser.presentation.FieldField handler used by @has_fields decorator.
aria.parser.presentation.NULLRepresents an explicit null value provided by the user, which is different from not supplying a value at all.
aria.parser.presentation.none_to_nullConvert None to NULL, recursively.
aria.parser.presentation.null_to_noneConvert NULL to None, recursively.
aria.parser.presentation.ValueEncapsulates a typed value assignment.
aria.parser.presentation.PresenterBase class for ARIA presenters.
aria.parser.presentation.PresenterSourceBase class for ARIA presenter sources.
aria.parser.presentation.DefaultPresenterSourceThe default ARIA presenter source.
+
+

Presentations

+ ++++ + + + + + + + + + + + +
aria.parser.presentation.PresentationBaseBase class for ARIA presentation classes.
aria.parser.presentation.PresentationBase class for ARIA presentations.
aria.parser.presentation.AsIsPresentationBase class for trivial ARIA presentations that provide the raw value as is.
+
+
+

Field decorators

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
aria.parser.presentation.has_fieldsClass decorator for validated field support.
aria.parser.presentation.short_form_fieldClass decorator for specifying the short form field.
aria.parser.presentation.allow_unknown_fieldsClass decorator specifying that the class allows unknown fields.
aria.parser.presentation.primitive_fieldMethod decorator for primitive fields.
aria.parser.presentation.primitive_list_fieldMethod decorator for list of primitive fields.
aria.parser.presentation.primitive_dict_fieldMethod decorator for dict of primitive fields.
aria.parser.presentation.primitive_dict_unknown_fieldsMethod decorator for dict of primitive fields, for all the fields that are not already decorated.
aria.parser.presentation.object_fieldMethod decorator for object fields.
aria.parser.presentation.object_list_fieldMethod decorator for list of object fields.
aria.parser.presentation.object_dict_fieldMethod decorator for dict of object fields.
aria.parser.presentation.object_sequenced_list_fieldMethod decorator for sequenced list of object fields.
aria.parser.presentation.object_dict_unknown_fieldsMethod decorator for dict of object fields, for all the fields that are not already decorated.
aria.parser.presentation.field_getterMethod decorator for overriding the getter function of a field.
aria.parser.presentation.field_setterMethod decorator for overriding the setter function of a field.
aria.parser.presentation.field_validatorMethod decorator for overriding the validator function of a field.
+
+
+

Field validators

+ ++++ + + + + + + + + + + + + + + +
aria.parser.presentation.type_validatorMakes sure that the field refers to an existing type defined in the root presenter.
aria.parser.presentation.list_type_validatorMakes sure that the field’s elements refer to existing types defined in the root presenter.
aria.parser.presentation.list_length_validatorMakes sure the field has exactly a specific number of elements.
aria.parser.presentation.derived_from_validatorMakes sure that the field refers to a valid parent type defined in the root presenter.
+
+
+

Utilities

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
aria.parser.presentation.get_locatorGets the first available locator.
aria.parser.presentation.parse_types_dict_namesIf the first element in the array is a function, extracts it out.
aria.parser.presentation.validate_primitiveChecks if the value is of the primitive type, optionally attempting to coerce it if it is not.
aria.parser.presentation.validate_no_short_formMakes sure that we can use short form definitions only if we allowed it.
aria.parser.presentation.validate_no_unknown_fieldsMake sure that we can use unknown fields only if we allowed it.
aria.parser.presentation.validate_known_fieldsValidates all known fields.
aria.parser.presentation.get_parent_presentationReturns the parent presentation according to the derived_from field, or None if invalid.
aria.parser.presentation.report_issue_for_unknown_type
aria.parser.presentation.report_issue_for_parent_is_self
aria.parser.presentation.report_issue_for_unknown_parent_type
aria.parser.presentation.report_issue_for_circular_type_hierarchy
+
+
+exception aria.parser.presentation.PresenterException(message=None, cause=None, cause_traceback=None)
+

Bases: aria.exceptions.AriaException

+

ARIA presenter exception.

+
+ +
+
+exception aria.parser.presentation.PresenterNotFoundError(message=None, cause=None, cause_traceback=None)
+

Bases: aria.parser.presentation.exceptions.PresenterException

+

ARIA presenter error: presenter not found for raw.

+
+ +
+
+class aria.parser.presentation.PresentationContext
+

Bases: object

+

Presentation context.

+ +++ + + + +
Variables:
    +
  • presenter (Presenter) – the generated presenter instance
  • +
  • location (Location) – from where we will generate the presenter
  • +
  • presenter_source (PresenterSource) – for finding presenter classes
  • +
  • presenter_class (type) – overrides presenter_source with a specific class
  • +
  • import_profile (bool) – whether to import the profile by default (defaults to True)
  • +
  • threads (int) – number of threads to use when reading data
  • +
  • timeout (float) – timeout in seconds for loading data
  • +
  • print_exceptions (bool) – whether to print exceptions while reading data
  • +
+
+
+
+get(*names)
+

Gets attributes recursively from the presenter.

+
+ +
+
+get_from_dict(*names)
+

Gets attributes recursively from the presenter, except for the last name which is used +to get a value from the last dict.

+
+ +
+ +
+
+class aria.parser.presentation.Presenter(name=None, raw=None, container=None)
+

Bases: aria.parser.presentation.presentation.Presentation

+

Base class for ARIA presenters.

+

Presenters provide a robust API over agnostic raw data.

+
+
+ALLOWED_IMPORTED_DSL_VERSIONS = None
+
+ +
+
+DSL_VERSIONS = None
+
+ +
+
+classmethod can_present(raw)
+
+ +
+ +
+
+class aria.parser.presentation.Value(type_name, value, description)
+

Bases: object

+

Encapsulates a typed value assignment.

+
+ +
+
+class aria.parser.presentation.PresentationBase(name=None, raw=None, container=None)
+

Bases: aria.utils.caching.HasCachedMethods

+

Base class for ARIA presentation classes.

+
+
+as_raw
+
+ +
+ +
+
+class aria.parser.presentation.Presentation(name=None, raw=None, container=None)
+

Bases: aria.parser.presentation.presentation.PresentationBase

+

Base class for ARIA presentations. A presentation is a Pythonic wrapper around agnostic raw +data, adding the ability to read and modify the data with proper validation.

+

ARIA presentation classes will often be decorated with has_fields(), as that mechanism +automates a lot of field-specific validation. However, that is not a requirement.

+

Make sure that your utility property and method names begin with a _, because those names +without a _ prefix are normally reserved for fields.

+
+ +
+
+class aria.parser.presentation.AsIsPresentation(name=None, raw=None, container=None, cls=None)
+

Bases: aria.parser.presentation.presentation.PresentationBase

+

Base class for trivial ARIA presentations that provide the raw value as is.

+
+
+value
+
+ +
+ +
+
+class aria.parser.presentation.PresenterSource
+

Bases: object

+

Base class for ARIA presenter sources.

+

Presenter sources provide appropriate Presenter classes for agnostic raw data.

+
+
+get_presenter(raw)
+
+ +
+ +
+
+class aria.parser.presentation.DefaultPresenterSource(classes=None)
+

Bases: aria.parser.presentation.source.PresenterSource

+

The default ARIA presenter source.

+
+
+get_presenter(raw)
+
+ +
+ +
+
+aria.parser.presentation.none_to_null(value)
+

Convert None to NULL, recursively.

+
+ +
+
+aria.parser.presentation.null_to_none(value)
+

Convert NULL to None, recursively.

+
+ +
+
+class aria.parser.presentation.Field(field_variant, func, cls=None, default=None, allowed=None, required=False)
+

Bases: object

+

Field handler used by @has_fields decorator.

+
+
+default_get(presentation, context)
+
+ +
+
+default_set(presentation, context, value)
+
+ +
+
+default_validate(presentation, context)
+
+ +
+
+dump(presentation, context)
+
+ +
+
+full_cls_name
+
+ +
+
+full_name
+
+ +
+
+get(presentation, context)
+
+ +
+
+get_locator(raw)
+
+ +
+
+set(presentation, context, value)
+
+ +
+
+validate(presentation, context)
+
+ +
+
+validate_value(value, context)
+
+ +
+ +
+
+aria.parser.presentation.has_fields(cls)
+

Class decorator for validated field support.

+
    +
  1. Adds a FIELDS class property that is a dict of all the fields. Will inherit and merge +FIELDS properties from base classes if they have them.
  2. +
  3. Generates automatic @property implementations for the fields with the help of a set of +special function decorators.
  4. +
+

The class also works with the Python dict protocol, so that fields can be accessed via dict +semantics. The functionality is identical to that of using attribute access.

+

The class will also gain two utility methods, _iter_field_names and _iter_fields.

+
+ +
+
+aria.parser.presentation.short_form_field(name)
+

Class decorator for specifying the short form field.

+

The class must be decorated with has_fields().

+
+ +
+
+aria.parser.presentation.allow_unknown_fields(cls)
+

Class decorator specifying that the class allows unknown fields.

+

The class must be decorated with has_fields().

+
+ +
+
+aria.parser.presentation.primitive_field(cls=None, default=None, allowed=None, required=False)
+

Method decorator for primitive fields.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.primitive_list_field(cls=None, default=None, allowed=None, required=False)
+

Method decorator for list of primitive fields.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.primitive_dict_field(cls=None, default=None, allowed=None, required=False)
+

Method decorator for dict of primitive fields.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.primitive_dict_unknown_fields(cls=None, default=None, allowed=None, required=False)
+

Method decorator for dict of primitive fields, for all the fields that are +not already decorated.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.object_field(cls, default=None, allowed=None, required=False)
+

Method decorator for object fields.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.object_list_field(cls, default=None, allowed=None, required=False)
+

Method decorator for list of object fields.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.object_dict_field(cls, default=None, allowed=None, required=False)
+

Method decorator for dict of object fields.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.object_sequenced_list_field(cls, default=None, allowed=None, required=False)
+

Method decorator for sequenced list of object fields.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.object_dict_unknown_fields(cls, default=None, allowed=None, required=False)
+

Method decorator for dict of object fields, for all the fields that are not already decorated.

+

The function must be a method in a class decorated with has_fields().

+
+ +
+
+aria.parser.presentation.field_getter(getter_func)
+

Method decorator for overriding the getter function of a field.

+

The signature of the getter function must be: f(field, presentation, context). +The default getter can be accessed as `field.default_get(presentation, context).

+

The function must already be decorated with a field decorator.

+
+ +
+
+aria.parser.presentation.field_setter(setter_func)
+

Method decorator for overriding the setter function of a field.

+

The signature of the setter function must be: f(field, presentation, context, value). +The default setter can be accessed as field.default_set(presentation, context, value).

+

The function must already be decorated with a field decorator.

+
+ +
+
+aria.parser.presentation.field_validator(validator_fn)
+

Method decorator for overriding the validator function of a field.

+

The signature of the validator function must be: f(field, presentation, context). +The default validator can be accessed as field.default_validate(presentation, context).

+

The function must already be decorated with a field decorator.

+
+ +
+
+aria.parser.presentation.type_validator(type_name, *types_dict_names)
+

Makes sure that the field refers to an existing type defined in the root presenter.

+

The arguments from the second onwards are used to locate a nested field under +service_template under the root presenter. The first of these can optionally be a function, +in which case it will be called to convert type names. This can be used to support shorthand +type names, aliases, etc.

+

Can be used with the field_validator() decorator.

+
+ +
+
+aria.parser.presentation.list_type_validator(type_name, *types_dict_names)
+

Makes sure that the field’s elements refer to existing types defined in the root presenter.

+

Assumes that the field is a list.

+

The arguments from the second onwards are used to locate a nested field under +service_template under the root presenter. The first of these can optionally be a function, +in which case it will be called to convert type names. This can be used to support shorthand +type names, aliases, etc.

+

Can be used with the field_validator() decorator.

+
+ +
+
+aria.parser.presentation.list_length_validator(length)
+

Makes sure the field has exactly a specific number of elements.

+

Assumes that the field is a list.

+

Can be used with the field_validator() decorator.

+
+ +
+
+aria.parser.presentation.derived_from_validator(*types_dict_names)
+

Makes sure that the field refers to a valid parent type defined in the root presenter.

+

Checks that we do not derive from ourselves and that we do not cause a circular hierarchy.

+

The arguments are used to locate a nested field under service_template under the root +presenter. The first of these can optionally be a function, in which case it will be called to +convert type names. This can be used to support shorthand type names, aliases, etc.

+

Can be used with the field_validator() decorator.

+
+ +
+
+aria.parser.presentation.get_locator(*values)
+

Gets the first available locator.

+ +++ + + + +
Return type:aria.parser.reading.Locator
+
+ +
+
+aria.parser.presentation.parse_types_dict_names(types_dict_names)
+

If the first element in the array is a function, extracts it out.

+
+ +
+
+aria.parser.presentation.validate_primitive(value, cls, coerce=False)
+

Checks if the value is of the primitive type, optionally attempting to coerce it +if it is not.

+ +++ + + + +
Raises:ValueError – if not a primitive type or if coercion failed.
+
+ +
+
+aria.parser.presentation.validate_no_short_form(context, presentation)
+

Makes sure that we can use short form definitions only if we allowed it.

+
+ +
+
+aria.parser.presentation.validate_no_unknown_fields(context, presentation)
+

Make sure that we can use unknown fields only if we allowed it.

+
+ +
+
+aria.parser.presentation.validate_known_fields(context, presentation)
+

Validates all known fields.

+
+ +
+
+aria.parser.presentation.get_parent_presentation(context, presentation, *types_dict_names)
+

Returns the parent presentation according to the derived_from field, or None if invalid.

+

Checks that we do not derive from ourselves and that we do not cause a circular hierarchy.

+

The arguments from the third onwards are used to locate a nested field under +service_template under the root presenter. The first of these can optionally be a function, +in which case it will be called to convert type names. This can be used to support shorthand +type names, aliases, etc.

+
+ +
+
+aria.parser.presentation.report_issue_for_unknown_type(context, presentation, type_name, field_name, value=None)
+
+ +
+
+aria.parser.presentation.report_issue_for_unknown_parent_type(context, presentation, field_name)
+
+ +
+
+aria.parser.presentation.report_issue_for_parent_is_self(context, presentation, field_name)
+
+ +
+
+aria.parser.presentation.report_issue_for_circular_type_hierarchy(context, presentation, field_name)
+
+ +
+
+ + +
+
+ +
+