Package pyxb :: Package binding :: Module generate :: Class Generator
[hide private]
[frames] | no frames]

Class Generator

source code

object --+
         |
        Generator

Configuration and data for a single binding-generation action.

Instance Methods [hide private]
str
bindingRoot(self)
The directory path into which generated bindings will be written.
source code
 
setBindingRoot(self, binding_root) source code
 
__moduleFilePath(self, module_elts, inhibit_extension=False) source code
 
generateToFiles(self) source code
 
modulePathData(self, module) source code
 
schemaRoot(self)
The directory from which entrypoint schemas specified as relative file paths will be read.
source code
 
setSchemaRoot(self, schema_root) source code
 
schemaStrippedPrefix(self)
Optional string that is stripped from the beginning of schemaLocation values before loading from them.
source code
 
setSchemaStrippedPrefix(self, schema_stripped_prefix) source code
 
locationPrefixRewriteMap(self)
Optional map to rewrite schema locations.
source code
 
setLocationPrefixRewriteMap(self, location_prefix_rewrite_map) source code
 
addLocationPrefixRewrite(self, prefix, substituent)
Add a rewrite entry for schema locations.
source code
 
argAddLocationPrefixRewrite(self, prefix_rewrite)
Add a rewrite entry for schema locations.
source code
 
schemaLocationList(self)
A list of locations from which entrypoint schemas are to be read.
source code
 
setSchemaLocationList(self, schema_location_list) source code
 
addSchemaLocation(self, schema_location, converter=None)
Add the location of an entrypoint schema.
source code
 
argAddSchemaLocation(self, schema_location)
Add the location of an entrypoint schema.
source code
 
schemas(self)
Schema for which bindings should be generated.
source code
 
setSchemas(self, schemas) source code
 
addSchema(self, schema) source code
set
namespaces(self)
The set of namespaces for which bindings will be generated.
source code
 
setNamespaces(self, namespace_set) source code
 
addNamespace(self, namespace) source code
 
moduleList(self)
A list of module names to be applied in order to the namespaces of entrypoint schemas
source code
 
_setModuleList(self, module_list) source code
 
addModuleName(self, module_name)
Add a module name corresponding to an entrypoint schema.
source code
 
modulePrefix(self)
The prefix for binding modules.
source code
 
setModulePrefix(self, module_prefix) source code
 
namespaceModuleMap(self)
A map from namespace URIs to the module to be used for the corresponding generated binding.
source code
 
archivePath(self)
A colon-separated list of paths from which namespace archives can be read.
source code
 
setArchivePath(self, archive_path) source code
 
noLoadNamespaces(self)
A frozenset of namespaces that many not be loaded from an archive.
source code
 
_setNoLoadNamespaces(self, namespace_set)
Record the set of namespaces that should not be loaded from an archive.
source code
 
addNoLoadNamespace(self, namespace)
Mark that the specified namespace should not be loaded from an archive.
source code
 
preLoadArchives(self)
A list of paths to archives that should be loaded, in order, prior to parsing schema.
source code
 
addPreLoadArchive(self, archive_file)
Name of a file containing a stored archive from which namespaces should be read prior to processing schema.
source code
 
_setPreLoadArchives(self, pre_load_archives) source code
 
archiveToFile(self)
Optional file into which the archive of namespaces will be written.
source code
 
setArchiveToFile(self, archive_to_file) source code
 
setNamespaceVisibility(self, namespace, visibility) source code
 
_setNamespaceVisibilities(self, public, private) source code
 
namespaceVisibilityMap(self)
Indicates, for specific namespaces, whether their visibility in the archive should be public or private.
source code
 
defaultNamespacePublic(self)
Indicates whether unmentioned namespaces will be public or private (default) in the archive.
source code
 
setDefaultNamespacePublic(self, default_namespace_public) source code
 
validateChanges(self)
Indicates whether the bindings should validate mutations against the content model.
source code
 
setValidateChanges(self, validate_changes) source code
 
bindingStyle(self)
The style of Python used in generated bindings.
source code
 
setBindingStyle(self, binding_style) source code
 
writeForCustomization(self)
Indicates whether the binding Python code should be written into a sub-module for customization.
source code
 
setWriteForCustomization(self, write_for_customization) source code
 
allowAbsentModule(self)
Indicates whether the code generator is permitted to process namespace for which no module path can be determined.
source code
 
setAllowAbsentModule(self, allow_absent_module) source code
 
allowBuiltinGeneration(self)
Indicates whether bindings will be written for namespaces that are built-in to PyXB.
source code
 
setAllowBuiltinGeneration(self, allow_builtin_generation) source code
str
uriContentArchiveDirectory(self)
The directory path into which any content retrieved by URI will be written.
source code
 
setUriContentArchiveDirectory(self, ucad) source code
 
__init__(self, *args, **kw)
Create a configuration to be used for generating bindings.
source code
 
__stripSpaces(self, string) source code
 
applyOptionValues(self, options, args=None) source code
 
setFromCommandLine(self, argv=None) source code
 
generationUID(self) source code
 
optionParser(self, reset=False)
Return an optparse.OptionParser instance tied to this configuration.
source code
 
getCommandLineArgs(self)
Return a command line option sequence that could be used to construct an equivalent configuration.
source code
 
normalizeSchemaLocation(self, sl) source code
 
__assignModulePath(self, module_record, module_path=None) source code
 
resolveExternalSchema(self, reset=False) source code
 
__graphFromComponents(self, components, include_lax) source code
 
__buildBindingModules(self) source code
 
bindingModules(self, reset=False) source code
 
writeNamespaceArchive(self) source code
 
moduleForComponent(self, component) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _DEFAULT_bindingRoot = '.'
  __bindingRoot = None
hash(x)
  __generateToFiles = None
hash(x)
  __schemaRoot = None
hash(x)
  __schemaStrippedPrefix = None
hash(x)
  __locationPrefixMap = {}
  __schemaLocationList = None
hash(x)
  __schemas = None
hash(x)
  __namespaces = None
hash(x)
  __moduleList = None
hash(x)
  __modulePrefix = None
hash(x)
  __namespaceModuleMap = None
hash(x)
  __archivePath = None
hash(x)
  __noloadNamespaces = None
hash(x)
  __preLoadArchives = None
hash(x)
  __archiveToFile = None
hash(x)
  __namespaceVisibilityMap = None
hash(x)
  __defaultNamespacePublic = None
hash(x)
  __validateChanges = None
hash(x)
  _DEFAULT_bindingStyle = 'property'
  __bindingStyle = None
hash(x)
  __writeForCustomization = None
hash(x)
  __allowAbsentModule = None
hash(x)
  __allowBuiltinGeneration = None
hash(x)
  __uriContentArchiveDirectory = None
hash(x)
  __stripSpaces_re = re.compile(r'\s\s\s+')
  __OptionSetters = 'binding_root', setBindingRoot, ('schema_roo...
  __generationUID = None
hash(x)
  __optionParser = None
hash(x)
  __didResolveExternalSchema = False
  __bindingModules = None
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

schemaStrippedPrefix(self)

source code 

Optional string that is stripped from the beginning of schemaLocation values before loading from them.

This applies only to the values of schemaLocation attributes in import and include elements. Its purpose is to convert absolute schema locations into relative ones to allow offline processing when all schema are available in a local directory. See schemaRoot.

locationPrefixRewriteMap(self)

source code 

Optional map to rewrite schema locations.

This applies only to the values of schemaLocation attributes in import and include elements. Its purpose is to convert remote or absolute schema locations into local or relative ones to allow offline processing when all schema are available in a local directory. See schemaRoot.

addLocationPrefixRewrite(self, prefix, substituent)

source code 

Add a rewrite entry for schema locations.

Parameters:
  • prefix - A text prefix that should be removed from schema location URIs.
  • substituent - The text prefix that should replace prefix as a prefix in a schema location URI.

argAddLocationPrefixRewrite(self, prefix_rewrite)

source code 

Add a rewrite entry for schema locations.

Parameter values are strings of the form pfx=sub. The effect is that a schema location that begins with pfx is rewritten so that it instead begins with sub.

schemaLocationList(self)

source code 

A list of locations from which entrypoint schemas are to be read.

The values in the list are either URIs, or tuples consisting of a value and a callable which, when passed the generator object and the value, will return a pyxb.xmlschema.structures.Schema instance. See addSchemaLocation.

See also addSchemaLocation and schemas.

addSchemaLocation(self, schema_location, converter=None)

source code 

Add the location of an entrypoint schema.

Parameters:
  • schema_location - The location of the schema. This should be a URL; if the schema location does not have a URL scheme (e.g., http:), it is assumed to be a file, and if it is not an absolute path is located relative to the schemaRoot.
  • converter - Optional callable that will be invoked with the generator instance and the schema location, and is expected to return a pyxb.xmlschema.structures.Schema instance. If absent, the contents of the location are converted directly.

Note: The converter argument derives from WSDL support: we need to add to the sequence of schema locations a URI of something that will not parse as a schema, but does have inner material that can if treated properly. "Treated properly" may include having the archive path and other namespace manipulations configured before anything is done to it.

argAddSchemaLocation(self, schema_location)

source code 

Add the location of an entrypoint schema. The provided value should be a URL; if it does not have a URL scheme (e.g., http:), it is assumed to be a file, and if it is not an absolute path is located relative to the schemaRoot.

schemas(self)

source code 

Schema for which bindings should be generated.

These may be Schema instances, or strings; the latter is preferred, and is parsed into a Schema instance when required.

This is the list of entrypoint schemas for binding generation. Values in schemaLocationList are read and converted into schema, then appended to this list. Values from moduleList are applied starting with the first schema in this list.

namespaces(self)

source code 

The set of namespaces for which bindings will be generated.

This is the set of namespaces read from entrypoint schema, closed under reference to namespaces defined by schema import.

Returns: set

addModuleName(self, module_name)

source code 

Add a module name corresponding to an entrypoint schema.

The namespace defined by the corresponding schema will be written to a binding using the given module name, adjusted by modulePrefix.

modulePrefix(self)

source code 

The prefix for binding modules.

The base name for the module holding a binding is taken from the moduleList, moduleMap, or an XMLNS prefix associated with the namespace in a containing schema. This value, if present, is used as a prefix to allow a deeper module hierarchy.

namespaceModuleMap(self)

source code 

A map from namespace URIs to the module to be used for the corresponding generated binding.

Module values are adjusted by modulePrefix if that has been specified.

An entry in this map for a namespace supersedes the module specified in moduleList if the namespace is defined by an entrypoint schema.

Returns:
A reference to the namespace module map.

archivePath(self)

source code 

A colon-separated list of paths from which namespace archives can be read.

The default path is the contents of the PYXB_ARCHIVE_PATH environment variable, or the standard path configured at installation time. Any file with the extension .wxs found in one of these directories is examined to see whether it is a namespace archive.

_setNoLoadNamespaces(self, namespace_set)

source code 

Record the set of namespaces that should not be loaded from an archive.

The expectation is that any required entities in the namespace will be defined by loading schema.

addNoLoadNamespace(self, namespace)

source code 

Mark that the specified namespace should not be loaded from an archive.

Use this when you are generating bindings for an application that has a restricted profile of a namespace that would otherwise be read from an archive. Be aware that this removes any knowledge of any archive in which this namespace is present as a non-private member.

addPreLoadArchive(self, archive_file)

source code 

Name of a file containing a stored archive from which namespaces should be read prior to processing schema.

Files to be pre-loaded are not affected by noLoadNamespace.

archiveToFile(self)

source code 

Optional file into which the archive of namespaces will be written.

Subsequent generation actions can read pre-parsed namespaces from this file, and therefore reference the bindings that were built earlier rather than re-generating them.

The file name should normally end with .wxs.

defaultNamespacePublic(self)

source code 

Indicates whether unmentioned namespaces will be public or private (default) in the archive.

A namespace is mentioned if it is the target namespace of an entrypoint schema, or appears in a namespace visibility specification. I.e., this default applies only to namespaces that are modified as a result of including some schema, which is generally a local customization of something.

bindingStyle(self)

source code 

The style of Python used in generated bindings.

accessor means values are private variables accessed through inspector and mutator methods.

property means values are private variables accessed through a Python property.

writeForCustomization(self)

source code 

Indicates whether the binding Python code should be written into a sub-module for customization.

If enabled, a module path.to.namespace will be written to the file path/to/raw/namespace.py, so that the file path/to/namespace.py can import it and override behavior.

allowAbsentModule(self)

source code 

Indicates whether the code generator is permitted to process namespace for which no module path can be determined.

Use this only when generating bindings that will not be referenced by other bindings.

allowBuiltinGeneration(self)

source code 

Indicates whether bindings will be written for namespaces that are built-in to PyXB.

This must be enabled when building bindings for the XML, XMLSchema instance, and other built-in namespaces. Normally generation of these namespaces is inhibited lest it produce inconsistencies.

uriContentArchiveDirectory(self)

source code 

The directory path into which any content retrieved by URI will be written.

This serves as a local cache, and to give you an opportunity to inspect material retrieved from some other system.

Returns: str

__init__(self, *args, **kw)
(Constructor)

source code 

Create a configuration to be used for generating bindings.

Arguments are treated as additions to the schema location list after all keywords have been processed.

Parameters:
Overrides: object.__init__

optionParser(self, reset=False)

source code 

Return an optparse.OptionParser instance tied to this configuration.

Parameters:
  • reset (bool) - If False (default), a parser created in a previous invocation will be returned. If True, any previous option parser is discarded and a new one created.

getCommandLineArgs(self)

source code 

Return a command line option sequence that could be used to construct an equivalent configuration.

Note: If you extend the option parser, as is done by pyxbgen, this may not be able to reconstruct the correct command line.


Class Variable Details [hide private]

__OptionSetters

Value:
'binding_root', setBindingRoot, ('schema_root', setSchemaRoot), ('sche\
ma_stripped_prefix', setSchemaStrippedPrefix), ('location_prefix_rewri\
te', argAddLocationPrefixRewrite), ('schema_location', setSchemaLocati\
onList), ('module', _setModuleList), ('module_prefix', setModulePrefix\
), ('archive_path', setArchivePath), ('no_load_namespace', _setNoLoadN\
amespaces), ('pre_load_archive', _setPreLoadArchives), ('archive_to_fi\
le', setArchiveToFile), ('default_namespace_public', setDefaultNamespa\
cePublic), ('binding_style', setBindingStyle), ('validate_changes', se\
...