devana.preprocessing.components.property.parsers

devana.preprocessing.components.property.parsers.attributeparser

class AttributeParser(properties=None, configuration=None)[source]

Bases: IGenerator

Parser implementation using C++ standard attributes.

add_property(prop)[source]
generate(data)[source]

Generate data like generate code.

Return type

Iterable[Result]

classmethod get_produced_type()[source]

Specifies a result type, typically as an interface.

Return type

Type

classmethod get_required_type()[source]

Specifies the required input type. In common cases should be interfaced.

Return type

Type

devana.preprocessing.components.property.parsers.configuration

class Configuration(orphaned_enum_values_allowed=False, property_overload_allowed=False, ignore_unknown=False)[source]

Bases: object

Parser core configuration.

ignore_unknown: bool = False

An option that determines whether to ignore a syntactically valid property with an unknown name without error. This does not apply to cases where unknown values assigned to a property with a known name. This option can be partially ignored for special parsers. In particular, C++11 attribute-based parsers may partially ignore this setting in order to more easily implement compiler extension attributes - this applies to the global namespace, so it is recommended for such parsers to always use their own namespaces.

orphaned_enum_values_allowed: bool = False

An orphaned enum is an enum value not preceded by an enum name. For example, EnumTypeName.Value1 is the standard value notation, but the user can only use Value1 in a given context - a parser based on the expected argument type can match the argument type. This option is mainly useful for simple preprocessors that do not use unions.

property_overload_allowed: bool = False

Allows multiple properties with the same name (within namespace) with different argument types. Does not affect the ability to use default arguments.

devana.preprocessing.components.property.parsers.descriptions

class IDescribedArgument[source]

Bases: ABC

Interface describing the arguments accepted by property.

abstract property default_value: Optional[IDescribedValue]

Default value of argument, if any.

Return type

Optional[IDescribedValue]

abstract property name: Optional[str]

Name of argument. If the argument is only and exclusively positional, it can be None. Otherwise, the syntax name1 = val1, name2 = val, etc. is allowed.

Return type

Optional[str]

abstract property type: IDescribedType

Type of argument.

Return type

IDescribedType

class IDescribedProperty[source]

Bases: ABC

Description property for parsing and diagnostic messages.

abstract property arguments: List[IDescribedArgument]

List of arguments for this property.

Return type

List[IDescribedArgument]

abstract property name: str

Name of property.

Return type

str

abstract property namespace: Optional[str]

Namespace in which the property is located (if it is located in any).

Return type

Optional[str]

class IDescribedType[source]

Bases: ABC

An interface containing a basic description of the type assumed by the property for unambiguous identification. Types can be (and often should be) created dynamically along with the creation of properties to provide support for example enums.

abstract property name: str

The full name of the type, including the names of the generic specialization types

Return type

str

class IDescribedValue[source]

Bases: ABC

Interface describing the possible value taken by property. Its use is to describe property definitions in the context of default values, making the parser’s work easier and ensuring diagnostic messages of appropriate quality. This interface does not apply to actual property values.

abstract property content: Optional[Any]

Provides a value if you need to provide a more reliable or non-standard way to provide values instead of relying on the parser when providing default values.

Return type

Optional[Any]

abstract property content_as_string: str

Test representation of a stored value - without a type, object data, etc. For example, holding the number 7.5, the text representation will be the string 7.5. If no content value is provided, the string should be paired to obtain the correct value.

Return type

str

abstract property type: IDescribedType

The type of the current value.

Return type

IDescribedType

devana.preprocessing.components.property.parsers.parser

class IParsableElement[source]

Bases: ABC

A class that performs basic data parsing - the smallest component, for example, a type.

abstract parse(text)[source]

Extraxt python data from text.

Return type

Union[ParsableElementError, Any]

abstract property result_type: Type

Python type of result.

Return type

Type

class IParsableType[source]

Bases: IParsableElement, IDescribedType, ABC

Mix of two interfaces needed by parser.

class ParsableElementError(what=None)[source]

Bases: object

Possible parsing errors

property is_meaningless: bool

Indicates when an error is used for fallback - it is not an actual user syntax error.

Return type

bool

what: Optional[str] = None

Error description. In most cases it will be empty allowing fallback to other types.

class ParsingBackend[source]

Bases: object

Core backend for all parser.

class Argument(value, type, name=None)[source]

Bases: object

Class holding result arguments.

name: Optional[str] = None
type: IDescribedType
value: Any
class ParsedValue(text, type)[source]

Bases: object

Internal value parsing result.

text: str
type: IDescribedType
add_type(element)[source]

Add a new type to parser. May raise exceptions for duplicate types.

parse_argument(text)[source]
Return type

Argument

property types: Dict[str, IParsableElement]
Return type

Dict[str, IParsableElement]

devana.preprocessing.components.property.parsers.result

class Arguments(positional=<factory>, named=<factory>)[source]

Bases: object

Calling arguments.

named: Dict[str, Value]
positional: List[Value]
class PropertySignature(name, namespaces=<factory>, arguments=<factory>)[source]

Bases: object

Invoking target property identification data.

arguments: List[Type]
name: str
namespaces: List[str]
class Result(property, arguments, target)[source]

Bases: object

Call frame - target function, arguments and current context

arguments: Arguments
property: PropertySignature
target: ISyntaxElement
class Value(content)[source]

Bases: object

The current value of the property argument with which it will be called.

content: Any

Python value.

property type: Type

Python type of content.

Return type

Type

devana.preprocessing.components.property.parsers.types

class BooleanType[source]

Bases: IParsableType

Representation of true/false.

property name: str

The full name of the type, including the names of the generic specialization types

Return type

str

parse(text)[source]

Extraxt python data from text.

Return type

Union[ParsableElementError, bool]

property result_type: Type

Python type of result.

Return type

Type

class EnumType(name, values)[source]

Bases: IDescribedType

Representation of enum.

property name: str

The full name of the type, including the names of the generic specialization types

Return type

str

property values: List[str]
Return type

List[str]

class FloatType[source]

Bases: IParsableType

Representation of floating point number.

property name: str

The full name of the type, including the names of the generic specialization types

Return type

str

parse(text)[source]

Extraxt python data from text.

Return type

Union[ParsableElementError, float]

property result_type: Type

Python type of result.

Return type

Type

class IntegerType[source]

Bases: IParsableType

Representation of integer number.

property name: str

The full name of the type, including the names of the generic specialization types

Return type

str

parse(text)[source]

Extraxt python data from text.

Return type

Union[ParsableElementError, int]

property result_type: Type

Python type of result.

Return type

Type

class ListType(specialization)[source]

Bases: _GenericType

Internal of list like []

class OptionalType(specialization)[source]

Bases: _GenericType

Internal of optional can be value of specialization type or none.

class StringType[source]

Bases: IParsableType

Representation of text.

property name: str

The full name of the type, including the names of the generic specialization types

Return type

str

parse(text)[source]

Extraxt python data from text.

Return type

Union[ParsableElementError, str]

property result_type: Type

Python type of result.

Return type

Type

class UnionType(types)[source]

Bases: IDescribedType

Internal of union type can be value of many types.

property name: str

The full name of the type, including the names of the generic specialization types

Return type

str

property types: List[IDescribedType]
Return type

List[IDescribedType]

parsable_element_from_described_type(desc)[source]

Create a parsing type from described.

Return type

IParsableType

Auxiliary classes that allow you to transform (parse) input data containing the text definition of a property into a set of Python data that can be used in the executor module.