gws.spec.core

Core data structures and constants for the specs.

Source code: gws.spec.core

Module Contents

class gws.spec.core.c

Type kinds, the values of Type.c.

ATOM = 'ATOM'

Atomic, one of the built-in types.

CALLABLE = 'CALLABLE'

Callable, a callable argument.

CLASS = 'CLASS'

Class, a user-defined type.

COMMAND = 'COMMAND'

Command, a method decorated as gws.ext.command.

CONSTANT = 'CONSTANT'

Constant type.

DICT = 'DICT'

Generic dictionary type.

ENUM = 'ENUM'

Enum type.

EXPR = 'EXPR'

Compile-time expression type.

EXT = 'EXT'

Extension, a gws.ext alias.

FUNCTION = 'FUNCTION'

Function, a callable type.

LIST = 'LIST'

Generic list type.

LITERAL = 'LITERAL'

Literal type.

METHOD = 'METHOD'

Method, a callable type with a specific signature.

MODULE = 'MODULE'

Module type.

NONE = 'NONE'

None type.

OPTIONAL = 'OPTIONAL'

Optional, a type that can be None.

PROPERTY = 'PROPERTY'

Property, a type that is a property of a class.

SET = 'SET'

Generic set type.

TUPLE = 'TUPLE'

Generic tuple type.

TYPE = 'TYPE'

Type alias.

UNDEFINED = 'UNDEFINED'

Undefined, a type that is not defined.

UNION = 'UNION'

Union, a type that can be one of several types.

VARIANT = 'VARIANT'

Variant, a type that can be one of several types with a tag.

class gws.spec.core.Chunk

Source code chunk, the core packages or a plugin with their source files.

bundleDir: str

Directory where the client bundle of the chunk is stored.

exclude: list[str]

Path fragments to exclude from the chunk.

name: str

Name of the chunk.

paths: dict[str, list[str]]

Source file paths, grouped by file kind (python, ts, css, theme, strings).

sourceDir: str

Source directory of the chunk.

exception gws.spec.core.Error

Bases: Exception

Base class for spec errors.

exception gws.spec.core.GeneratorError

Bases: Error

Raised when the spec generator fails.

exception gws.spec.core.LoadError

Bases: Error

Raised when a class cannot be loaded from its module.

gws.spec.core.make_type(args: dict)

Create a Type object.

Parameters:

args – Attribute values for the type.

Returns:

A new Type object.

exception gws.spec.core.ReadError

Bases: Error

Raised when a value does not match its spec type.

The arguments are the message and the offending value. With verbose errors, a gws.ConfigErrorInfo object is added as the third argument.

class gws.spec.core.SpecData

Specs data, produced by the generator and loaded by the runtime.

chunks: list[Chunk]

Source code chunks of the application and its plugins.

meta: dict

version, manifestPath and manifest.

Type:

Build-time metadata

serverTypes: list[Type]

configuration, request and response types, ext objects and command methods.

Type:

Types used by the server

strings: dict[str, dict[str, str]]

Documentation strings keyed by language code and type uid.

class gws.spec.core.Type

Spec type record, describes a single type, property, method or module.

Which fields are populated depends on the type kind c.

c: TypeKind

Type kind, one of the constants in c.

constValue: Any = None

Constant value for a constant type.

defaultExpression: Any = None

Unevaluated default of a property (a constant or enum reference), evaluated by the normalizer.

defaultValue: Any = None

Default value for a property.

doc: str = ''

Documentation string for the type.

enumDocs: dict

For ENUM types, member docstrings keyed by member name.

enumValues: dict

For ENUM types, member values keyed by member name.

extName: str = ''

gws.ext name of an extension type, variant or command method, if any.

hasDefault: bool = False

True if the type has a default value.

ident: str = ''

Source code identifier (class, property or method name), used in the documentation.

isConfig: bool = False

True if the type is reachable from the application Config.

literalValues: list = []

For LITERAL types, the allowed values.

modName: str = ''

Name of the module that defines this type.

modPath: str = ''

Path to the module that defines this type.

name: str = ''

Qualified name of a named type, e.g. gws.base.layer.core.Config.

pos: str = ''

Source code position of the definition, as path:line.

tArg: TypeUid = ''

For METHOD types, type uid of the last (request) argument.

tArgs: list[TypeUid] = []

For METHOD types, type uids of the arguments.

tItem: TypeUid = ''

For LIST and SET types, type uid of the item.

tItems: list[TypeUid] = []

For UNION, TUPLE and CALLABLE types, type uids of the items.

title: str = ''

Documentation title, filled from the strings by get_config_types.

tKey: TypeUid = ''

For DICT types, type uid of the key.

tMembers: dict[str, TypeUid]

For VARIANT types, member type uids keyed by the type tag.

tModule: TypeUid = ''

Type uid of the type’s module.

tOwner: TypeUid = ''

For PROPERTY and METHOD types, type uid of the owning class.

tProperties: dict[str, TypeUid]

For CLASS types, property type uids keyed by property name, including inherited properties.

tReturn: TypeUid = ''

For METHOD types, type uid of the return value.

tSupers: list[TypeUid] = []

For CLASS types, type uids of the base classes.

tTarget: TypeUid = ''

For TYPE, EXT and OPTIONAL types, type uid of the target type.

tValue: TypeUid = ''

For PROPERTY types, type uid of the value; for DICT types, type uid of the dict values.

uid: TypeUid

Type unique identifier, a string that identifies the type.

type gws.spec.core.TypeKind = str

Type kind, one of the constants in c.

type gws.spec.core.TypeUid = str

Type unique identifier, a string that identifies the type.

class gws.spec.core.v

Constants for the spec generator and runtime.

APP_DIR = b'.'
APP_NAME = 'gws'

Application package name.

ATOMS = ['any', 'bool', 'bytes', 'float', 'int', 'str']

Names of atomic types.

BUILTIN_TYPES = ['Any', 'Callable', 'ContextManager', 'Dict', 'Enum', 'Iterable', 'Iterator', 'List', 'Literal',...

Names from typing and foreign modules that are treated as built-in.

BUILTINS = ['any', 'bool', 'bytes', 'float', 'int', 'str', 'type', 'object', 'Exception', 'dict', 'list',...

Built-in names, registered as ATOM types.

CLIENT_NAME = 'gc'

Name of the client chunk.

DEFAULT_EXT_SUPERS

Default base classes for synthesized ext config and props classes.

DEFAULT_VARIANT_TAG = 'default'

Variant member used when the tag property is missing.

EXCLUDE_PATHS = ['___', '/vendor/', 'test', 'core/ext', '__pycache__']

Path fragments of source files the generator skips.

EXT_COMMAND_API_PREFIX = 'gws.ext.command.api.'

Prefix of API command names.

EXT_COMMAND_CLI_PREFIX = 'gws.ext.command.cli.'

Prefix of CLI command names.

EXT_COMMAND_GET_PREFIX = 'gws.ext.command.get.'

Prefix of web GET command names.

EXT_COMMAND_PREFIX = 'gws.ext.command.'

Prefix of command names.

EXT_CONFIG_CLASS = 'Config'

Default config class name in a gws.ext.new declaration.

EXT_CONFIG_PREFIX = 'gws.ext.config.'

Prefix of extension config names.

EXT_DECL_PREFIX = 'gws.ext.new.'

Prefix of gws.ext.new declarations in the sources.

EXT_OBJECT_CLASS = 'Object'

Default object class name in a gws.ext.new declaration.

EXT_OBJECT_PREFIX = 'gws.ext.object.'

Prefix of extension object names.

EXT_PREFIX = 'gws.ext'

Prefix of all extension names.

EXT_PROPS_CLASS = 'Props'

Default props class name in a gws.ext.new declaration.

EXT_PROPS_PREFIX = 'gws.ext.props.'

Prefix of extension props names.

FILE_KINDS = [['.py', 'python'], ['/index.ts', 'ts'], ['/index.tsx', 'ts'], ['/index.css.js', 'css'],...

Source file suffixes and the file kinds they map to.

GLOBAL_MODULES

Modules whose names are available directly as gws.<Name>.

INLINE_COMMENT_SYMBOL = '#:'
PLUGIN_DIR = '/gws/plugin'

Directory of the built-in plugins, relative to the app directory.

PLUGIN_PREFIX = 'gws.plugin'
SELF_DIR
SYSTEM_CHUNKS

Names and source directories of the system chunks.

VARIANT_TAG = 'type'

Name of the property that selects the member of a variant.