valasp.domain package

Submodules

valasp.domain.names module

This module defines domain primitives for class names and predicate names.

class valasp.domain.names.AttributeName(value: str)[source]

Bases: valasp.domain.names.PredicateName

A domain primitive for names of attributes.

value: str
class valasp.domain.names.ClassName(value: str)[source]

Bases: object

A domain primitive for names of classes.

to_predicate()valasp.domain.names.PredicateName[source]

Return the predicate name associated with this class name.

Returns

a predicate name

value: str
class valasp.domain.names.PredicateName(value: str)[source]

Bases: object

A domain primitive for names of predicates.

to_class()valasp.domain.names.ClassName[source]

Return the class name associated with this predicate name.

Returns

a class name

value: str

valasp.domain.primitive_types module

The enum Fun and the primitive types are defined in this module.

The primitive types are markers to be used in annotations. They cannot be instantiated, and offer a very limited set of utility function.

class valasp.domain.primitive_types.Alpha[source]

Bases: valasp.domain.primitive_types.Type

Primitive type representing named constants.

This class cannot be instantiated.

classmethod init_code(arg: str) → List[str][source]

Return code to validate the type of the given argument name.

Subclasses are expected to call this method in their init_code() method.

Parameters

arg – the name of the argument

Returns

validation code

classmethod parse(value: str)str[source]

Return value, or raise an exception if value is not valid

Parameters

value – a string to be parsed

Raise

ValueError if value is not a valid function name, or TypeError if the type of value is not str

Returns

value

class valasp.domain.primitive_types.Any[source]

Bases: valasp.domain.primitive_types.Type

Primitive type representing wildcards.

This class cannot be instantiated.

classmethod init_code(arg: str) → List[str][source]

Return code to validate the type of the given argument name.

Subclasses are expected to call this method in their init_code() method.

Parameters

arg – the name of the argument

Returns

validation code

class valasp.domain.primitive_types.Fun(value)[source]

Bases: enum.Enum

Modalities for the validate() decorator.

  • FORWARD_IMPLICIT means FORWARD for symbols of arity 1, and IMPLICIT otherwise.

  • FORWARD can be used with symbols of arity 1 and essentially means to leave the init argument as it is.

  • IMPLICIT must be used if the init argument is expected to be a function with the same name of the symbol. The arguments of the function are unpacked.

  • TUPLE is like IMPLICIT, but the function is expected to have emtpy name.

FORWARD = 1
FORWARD_IMPLICIT = 0
IMPLICIT = 2
TUPLE = 3
class valasp.domain.primitive_types.Integer[source]

Bases: valasp.domain.primitive_types.Type

Primitive type representing integers.

This class cannot be instantiated.

classmethod init_code(arg: str) → List[str][source]

Return code to validate the type of the given argument name.

Subclasses are expected to call this method in their init_code() method.

Parameters

arg – the name of the argument

Returns

validation code

classmethod max()int[source]

Return the greatest integer for the ASP system.

Returns

the greatest integer

classmethod min()int[source]

Return the smallest integer for the ASP system.

Returns

the smallest integer

classmethod parse(value: str)int[source]

Return the integer represented in value.

Parameters

value – a string to be parsed

Raise

TypeError if value is not an integer, or if its type is not str

Raise

OverflowError if value does not fit into a 32-bit signed integer

Returns

the integer in value

class valasp.domain.primitive_types.String[source]

Bases: valasp.domain.primitive_types.Type

Primitive type representing strings.

This class cannot be instantiated.

classmethod init_code(arg: str) → List[str][source]

Return code to validate the type of the given argument name.

Subclasses are expected to call this method in their init_code() method.

Parameters

arg – the name of the argument

Returns

validation code

classmethod parse(value: str)str[source]

Return value, as any string is valid

Parameters

value – a string to be parsed

Returns

value

class valasp.domain.primitive_types.Type[source]

Bases: object

Base class for type annotations.

This class cannot be instantiated, and its subclasses are expected to satisfy this invariant.

classmethod get_primitive(typ: ClassVar)valasp.domain.primitive_types.Type[source]

Return a subclass of Type associated with typ.

Parameters

typ – a type for which Type.is_primitive(typ) == True

Raise

KeyError if Type.is_primitive(typ) != True

Returns

a subclass of Type associated with typ

static init_code(arg: str) → List[str][source]

Return code to validate the type of the given argument name.

Subclasses are expected to call this method in their init_code() method.

Parameters

arg – the name of the argument

Returns

validation code

classmethod is_primitive(typ: ClassVar)bool[source]

Return true if typ is considered a primitive type.

Parameters

typ – a type

Returns

true if typ is a primitive type

classmethod parse(value: str)str[source]

Return value, or raises an exception if value is not a string.

Parameters

value – a string to be parsed

Raise

TypeError if value is not str

Returns

value

classmethod set_primitives(value)None[source]

Init the Type class with primitive types.

This method is called at the end of this file, and cannot be called a second time.

Parameters

value – a dictionary (see the bottom of this file)

Raise

PermissionError if called a second time

valasp.domain.raisers module

Any warning and error specific to ValAsp should be defined here.

The policy of the framework is to rely as much as possible on the usual error classes, like TypeError and ValueError.

exception valasp.domain.raisers.ValAspWarning[source]

Bases: UserWarning

Generic warning from the framework.

Module contents