gensaschema._config module

Schema config management

Schema config management.

Copyright:

Copyright 2010 - 2023 André Malo or his licensors, as applicable

License:

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class gensaschema._config.Config(tables, schemas, lines=None)[source]

Schema config container

tables

Table list

Type:

list

schemas

Alien schema mapping

Type:

dict

_lines

Original config lines (or None)

Type:

list

_CONFIG_TPL = <gensaschema._template.Template object>

Template for empty config file

Type:

Template

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'gensaschema._config', '__doc__': '\n    Schema config container\n\n    Attributes:\n      tables (list):\n        Table list\n\n      schemas (dict):\n        Alien schema mapping\n\n      _lines (list):\n        Original config lines (or ``None``)\n    ', '_CONFIG_TPL': <gensaschema._template.Template object>, '__init__': <function Config.__init__>, 'from_file': <classmethod(<function Config.from_file>)>, 'from_lines': <classmethod(<function Config.from_lines>)>, 'from_parser': <classmethod(<function Config.from_parser>)>, 'dump': <function Config.dump>, '__dict__': <attribute '__dict__' of 'Config' objects>, '__weakref__': <attribute '__weakref__' of 'Config' objects>, '__annotations__': {}})
__init__(tables, schemas, lines=None)[source]

Initialization

Parameters:
  • tables (list) – Table list

  • schemas (dict) – (Alien) Schema mapping

  • lines (iterable) – Original config lines. If omitted or None, the config lines are not available.

__module__ = 'gensaschema._config'
__weakref__

list of weak references to the object (if defined)

dump(fp)[source]

Dump config to a file

Parameters:

fp (file) – Stream to dump to

classmethod from_file(name_or_file)[source]

Construct from config file

Parameters:

name_or_file (str or file) – Config filename or file pointer

Returns:

New Config instance

Return type:

Config

Raises:

IOError – Error reading the file (except for ENOENT, which treats the file as empty)

classmethod from_lines(lines)[source]

Create from config lines

Parameters:

lines (iterable) – List of config lines

Returns:

New Config instance

Return type:

Config

classmethod from_parser(parser, lines=None)[source]

Construct from config parser

Parameters:
  • parser (ConfigParser.RawConfigParser) – Configparser instance

  • lines (iterable) – Original config lines

Returns:

New Config instance

Return type:

Config