devana.utility

devana.utility.errors

exception CodeError[source]

Bases: ValueError

Expressions in the code as C/C++ standard.

exception ParserError[source]

Bases: CodeError

Parsing error, most commonly due to backend errors or the use of unsupported syntax.

devana.utility.fakeenum

class FakeEnum(name, bases, args)[source]

Bases: type

Helper metaclass for provide enums with variable values in instance-level (standard enum do it in class-level). You must provide enum_source argument.

devana.utility.init_params

init_params(skip=None)[source]

A decorator that automatically assigns classmethod parameters to instance attributes, if the attribute has a setter or exists as an instance variable.

Parameters in the skip set will be ignored, “cls” is ignored by default. If parameter is not settable or doesn’t exist in the instance, an AttributeError will be raised.

Example usage:

class Person:
    name: str = ""
    age: int = 0

    @classmethod
    @init_params()
    def create(cls, name: str, age: int):
        return cls()

jerry = Person.create("Jerry", 20)
print(jerry.name, jerry.age)  # Outputs: Jerry 20
Return type

Callable

devana.utility.lazy

class LazyNotInit[source]

Bases: object

The Value used by lazy_invoke to determine property is initialized or not. Set this type to value of property in init function to inform that value must be initialized. For example, self._name = LazyNotInit

lazy_invoke(func)[source]

devana.utility.traits

class IBasicCreatable[source]

Bases: IDefaultCreatable, IFromCursorCreatable, IFromParamsCreatable, ABC

An interface that describes a set of constructors for a code element.

class ICursorValidate[source]

Bases: ABC

An interface that specifies that an object can only work with certain types of clang cursors.

abstract static is_cursor_valid(cursor)[source]

It checks if it is possible to create a valid object on the basis of the rate.

Return type

bool

class IDefaultCreatable[source]

Bases: ABC

The interface of an object that can be created with default sets of values.

abstract classmethod create_default(parent=None)[source]

Create a default, valid instance. Cls parameter allows implementing this method once if init meets requirements in all derivative types.

class IFromCursorCreatable[source]

Bases: ABC

The interface of an object that can be created from many clang cursor.

abstract classmethod from_cursor(cursor, parent=None)[source]

Create an instance from parsed information from clang. Return None if creation is not possible. Cls parameter allows implementing this method once if init meets requirements in all derivative types.

class IFromParamsCreatable[source]

Bases: ABC

The interface of an object that can be created from many parameters.

abstract classmethod from_params()[source]

Multi-parameter constructor. Similar to the default value, except that it allows you to set some basic properties.

Return type

ISyntaxElement

devana.utility.typeregister

register(current_register)[source]

Registers a type in the given variable - usually a global module variable. Useful for automatically creating lists of default supported classes, etc.

Sets of utility classes.