Generator API

Inheritance diagram of qface.generator

Generator Class

Provides an API for accessing the file system and controlling the generator

FileSystem Class

class qface.generator.FileSystem[source]

Bases: object

QFace helper functions to work with the file system

static merge_annotations(system, document)[source]

Read a YAML document and for each root symbol identifier updates the tag information of that symbol

static parse(input, identifier: str = None, use_cache=False, clear_cache=True, pattern='*.qface', profile=<EProfile.FULL: 'full'>)[source]

Input can be either a file or directory or a list of files or directory. A directory will be parsed recursively. The function returns the resulting system. Stores the result of the run in the domain cache named after the identifier.

  • path – directory to parse
  • identifier – identifies the parse run. Used to name the cache
  • clear_cache – clears the domain cache (defaults to true)
strict = False

enables strict parsing

class qface.generator.Generator(search_path, context={}, force=False)[source]

Bases: object

Manages the templates and applies your context data


destination prefix for generator write


Retrieves a single template file from the template loader

register_filter(name, callback)[source]

Register your custom template filter

render(name, context)[source]

Returns the rendered text from a single template file from the template loader using the given context data


source prefix for template lookup

strict = False

enables strict code generation

write(file_path, template, context={}, preserve=False, force=False)[source]

Using a template file name it renders a template into a file given a context

Template Domain API

This API is exposed to the Jinja template system.

Inheritance diagram of qface.idl.domain

High Level Classes

class qface.idl.domain.System[source]

Bases: object

The root entity which consist of modules

lookup(name: str)[source]

lookup a symbol by fully qualified name.


returns ordered list of module symbols

class qface.idl.domain.Module(name: str, system: qface.idl.domain.System)[source]

Bases: qface.idl.domain.Symbol

Module is a namespace for types, e.g. interfaces, enums, structs


returns ordered list of enum symbols


returns ordered list of import symbols


returns ordered list of interface symbols

lookup(name: str, fragment: str = None)[source]

lookup a symbol by name. If symbol is not local it will be looked up system wide


returns the major version number of the version information


returns the minor version number of the version information


returns the last part of the module uri


return module name splitted by ‘.’ in parts


returns ordered list of struct symbols

Base Classes

class qface.idl.domain.NamedElement(name, module: qface.idl.domain.Module)[source]

Bases: object

module = None

module the symbol belongs to

name = None

symbol name


return the fully qualified name (<module>.<name>)

class qface.idl.domain.Symbol(name: str, module: qface.idl.domain.Module)[source]

Bases: qface.idl.domain.NamedElement

A symbol represents a base class for names elements

add_attribute(tag, name, value)[source]

add an attribute (nam, value pair) to the named tag


add a tag to the tag list

attribute(tag, name)[source]

return attribute by tag and attribute name

comment = None

comment which appeared in QFace right before symbol


return general list of symbol contents

kind = None

the associated type information


returns reference to system


return tag by name

class qface.idl.domain.TypeSymbol(name: str, parent: qface.idl.domain.NamedElement)[source]

Bases: qface.idl.domain.NamedElement

Defines a type in the system


checks if type is primitive and bool

is_complex = None

if type represents a complex type


checks if type is an enumeration and reference is enum


checks if type is complex and instance of type Enum


checks if type is an enumeration and reference is flag


checks if type is primitive and int


checks if type is interface

is_list = None

if type represents a list of nested types

is_map = None

if type represents a map of nested types. A key type is not defined

is_model = None

if type represents a model of nested types

is_primitive = None

if type represents a primitive type


checks if type is primitive and real


checks if type is primitive and string


checks if type is complex and struct


checks if type is a valid type


checks if type is primitive and var

is_void = None

if type represents the void type

nested = None

nested type if symbol is list or model

parent = None

the parent symbol of this type


returns the symbol reference of the type name


return the type information. In this case: self

Utility Modules

qface.watch.monitor(args, watch)[source]

reloads the script given by argv when src files changes

qface.shell.sh(args, **kwargs)[source]

runs the given cmd as shell command