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

# type 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 must 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
importAugmentableNamespaces(self) A list of namespaces for which new bindings are allowd. | source code
_setImportAugmentableNamespaces(self, namespace_set) Return the set of namespaces that may be augmented by import directives. | source code
addImportAugmentableNamespace(self, namespace) Mark that the specified namespace may be imported by new bindings. | 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
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
`str` |
loggingConfigFile(self) A file provided to `logging.config.fileConfig` to control log messages. | source code
setLoggingConfigFile(self, logging_config_file) | 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) A unique identifier associated with this Generator instance. | 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) Provide a Python module path for the module record. | source code
resolveExternalSchema(self) | source code
__graphFromComponents(self, components, include_lax) | source code
__resolveComponentDependencies(self) | source code
moduleRecords(self) The set of pyxb.namespace.archive.ModuleRecord instances associated with schema processed in this generation instance. | source code
componentGraph(self) | source code
componentOrder(self) | source code
__generateBindings(self) | source code
bindingModules(self) | source code
writeNamespaceArchive(self) | source code
moduleForComponent(self, component) | source code

Class Variables | [hide private]
| _DEFAULT_bindingRoot = ``'``.``'``
| __bindingRoot = `None`
| __generateToFiles = `None`
| __schemaRoot = `None`
| __schemaStrippedPrefix = `None`
| __locationPrefixMap = ``{``}``
| __schemaLocationList = `None`
| __schemas = `None`
| __namespaces = `None`
| __moduleList = `None`
| __modulePrefix = `None`
| __namespaceModuleMap = `None`
| __archivePath = `None`
| __noloadNamespaces = `None`
| __importAugmentableNamespaces = `None`
| __archiveToFile = `None`
| __namespaceVisibilityMap = `None`
| __defaultNamespacePublic = `None`
| __validateChanges = `None`
| __writeForCustomization = `None`
| __allowAbsentModule = `None`
| __allowBuiltinGeneration = `None`
| __uriContentArchiveDirectory = `None`
| __loggingConfigFile = `None`
| __stripSpaces_re = `re.compile(r'\s\s\s`+`')`
| __OptionSetters = `'binding_root', setBindingRoot, ('schema_roo`...``
| __generationUID = `None`
| __optionParser = `None`
| __didResolveExternalSchema = `False`
| __moduleRecords = `None`
| __componentGraph = `None`
| __componentOrder = `None`
| __bindingModules = `None`

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.

### addImportAugmentableNamespace(self, namespace) | source code
Mark that the specified namespace may be imported by new bindings. Normally namespaces that are available from archives are considered to be complete, and schema locations in import directives are ignored. Use this to indicate that the bindings being generated import new bindings. Note that attempts to import schema that contributed to the archive will only be detected if the archive was generated from the same schemaLocation URI; if the archive was generated from a different source component definitions might conflict.

### 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.

### 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`

### loggingConfigFile(self) | source code
A file provided to `logging.config.fileConfig` to control log messages. In the absence of other configuration the Python standard logging infrastructure is used in its default configuration. 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: `binding_root` - Invokes setBindingRoot `schema_root` - Invokes setSchemaRoot `schema_stripped_prefix` - Invokes setSchemaStrippedPrefix `location_prefix_rewrite_map` - Invokes setLocationPrefixRewriteMap `schema_location_list` - Invokes setSchemaLocationList `module_list` - Invokes _setModuleList `module_prefix` - Invokes setModulePrefix `archive_path` - Invokes setArchivePath `no_load_namespaces` - Invokes _setNoLoadNamespaces `import_augmentable_namespaces` - Invokes _setImportAugmentableNamespaces `archive_to_file` - Invokes setArchiveToFile `public_namespace` - Invokes setNamespaceVisibility `private_namespace` - Invokes setNamespaceVisibility `default_namespace_public` - Invokes setDefaultNamespacePublic `validate_changes` - Invokes setValidateChanges `namespace_module_map` - Initializes namespaceModuleMap `schemas` - Invokes setSchemas `namespaces` - Invokes setNamespaces `write_for_customization` - Invokes setWriteForCustomization `allow_builtin_generation` - Invokes setAllowBuiltinGeneration `allow_absent_module` - Invokes setAllowAbsentModule `generate_to_files` - Sets generateToFiles `uri_content_archive_directory` - Invokes setUriContentArchiveDirectory `logging_config_file` - Invokes setLoggingConfigFile Overrides: object.__init__

### generationUID(self) | source code
A unique identifier associated with this Generator instance. This is an instance of pyxb.utils.utility.UniqueIdentifier. Its associated objects are pyxb.namespace.archive._SchemaOrigin instances, which identify schema that contribute to the definition of a namespace.

### 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.

### assignModulePath(self, module_record, module_path=None) | source code
Provide a Python module path for the module record. This is the path by which the module bindings associated with `module_record` will be imported. If a path had already been assigned to the module, it is left in place. Parameters: `module_record` (pyxb.namespace.archive.ModuleRecord) - Information about a collection of related bindings `module_path` (`str`) - Default path to use Returns: `module_record`

### moduleRecords(self) | source code
The set of pyxb.namespace.archive.ModuleRecord instances associated with schema processed in this generation instance. These should be in one-to-one correspondence with the namespaces for which bindings are being generated. Multiple input schemas may contribute to a single module record; all material in that record is placed in a single binding file.

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), ('import_augmentable_namespace', _setImportAugmentableName
      spaces), ('archive_to_file', setArchiveToFile), ('default_namespace_pu
      blic', setDefaultNamespacePublic), ('validate_changes', setValidateCha
      ...