diff --git a/doc/source/conf.py b/doc/source/conf.py index d515d5331a..2abad0b2c4 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -27,9 +27,6 @@ import sphinx_rtd_theme from pyramid_oereb.core.config import Config Config._config = {'srid': -1, 'app_schema': {'name': 'pyramid_oereb_main'}} -from pyramid_oereb.contrib.data_sources.standard.sources.plr import StandardThemeConfigParser # noqa E402 -import pyramid_oereb.contrib.data_sources.standard # noqa E402 -import pyramid_oereb.contrib.data_sources.standard.models.main # noqa E402 # -- General configuration ------------------------------------------------ @@ -65,16 +62,6 @@ '../../.venv/bin/mako-render' if os.path.exists('../../.venv/bin/mako-render') else 'mako-render', 'core/sources.rst.mako']).decode('utf-8')) -with open('standard/sources.rst', 'w') as sources: - sources.write(subprocess.check_output([ - '../../.venv/bin/mako-render' if os.path.exists('../../.venv/bin/mako-render') else 'mako-render', - 'standard/sources.rst.mako']).decode('utf-8')) - -with open('contrib/sources.rst', 'w') as sources: - sources.write(subprocess.check_output([ - '../../.venv/bin/mako-render' if os.path.exists('../../.venv/bin/mako-render') else 'mako-render', - 'contrib/sources.rst.mako']).decode('utf-8')) - with open('contrib/print_proxy.rst', 'w') as sources: sources.write(subprocess.check_output([ '../../.venv/bin/mako-render' if os.path.exists('../../.venv/bin/mako-render') else 'mako-render', @@ -84,54 +71,23 @@ sources.write(subprocess.check_output([ '../../.venv/bin/mako-render' if os.path.exists('../../.venv/bin/mako-render') else 'mako-render', 'contrib/stats.rst.mako']).decode('utf-8')) +target_paths = [ + 'contrib/data_sources/standard/index.rst', + 'contrib/data_sources/standard/models.rst', + 'contrib/data_sources/standard/models-main.rst', + 'contrib/data_sources/standard/models-theme.rst', + 'contrib/data_sources/standard/sources.rst', + 'contrib/data_sources/interlis_2_3/index.rst', + 'contrib/data_sources/oereblex/index.rst', + 'contrib/data_sources/swisstopo/index.rst', + 'contrib/data_sources/index.rst' +] -module_file_names = [] -module_name = 'pyramid_oereb.contrib.data_sources.standard.models.main' -file_name = 'pyramid_oereb_contrib_data_sources_standard_models_main' -module_file_names.append(file_name) -main_classes = [] -for name, obj in inspect.getmembers(pyramid_oereb.contrib.data_sources.standard.models.main): - if inspect.isclass(obj) and obj.__module__ == module_name: - main_classes.append(name) -with open('standard/models/{name}.rst'.format(name=file_name), 'w') as sources: - template = Template(filename='standard/models/models.rst.mako') - sources.write(template.render(**{'module_name': module_name, 'classes': main_classes})) - -conf_parser = StandardThemeConfigParser(source={ - "class": 'pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource', - "params": { - "model_factory": "pyramid_oereb.contrib.data_sources.standard.models.theme.model_factory_string_pk", - "schema_name": "land_use_plans" - } -}) - -models = conf_parser.get_models() -modelnames = [modelname for modelname in dir(models) if modelname[0].isupper() and modelname != 'Base'] - -# create fake python module pyramid_oereb.contrib.data_sources.standard.factory_models -factory_models = types.ModuleType('FactoryModels', 'Virtual module for factory generated classes') -factory_models.__name__ = 'factory_models' -factory_models.__mro__ = [] -factory_models.__module__ = 'pyramid_oereb.contrib.data_sources.standard' -for modelname in modelnames: - model = models.__getattribute__(modelname) - model.__name__ = modelname - model.__module__ = 'pyramid_oereb.contrib.data_sources.standard.factory_models' - factory_models.__dict__.update({modelname: model}) - -pyramid_oereb.contrib.data_sources.standard.__dict__.update({'factory_models': factory_models}) -sys.modules['pyramid_oereb.contrib.data_sources.standard.factory_models'] = factory_models - -module_name = 'pyramid_oereb.contrib.data_sources.standard.factory_models' -file_name = module_name.replace('.', '_').lower() -module_file_names.append(file_name) -with open('standard/models/{name}.rst'.format(name=file_name), 'w') as sources: - template = Template(filename='standard/models/factory_models.rst.mako') - sources.write(template.render(**{'module_name': module_name, 'classes': modelnames})) - -with open('standard/models/index.rst', 'w') as sources: - template = Template(filename='standard/models/index.rst.mako') - sources.write(template.render(**{'module_file_names': module_file_names})) +for target_path in target_paths: + with open(target_path, 'w') as sources: + sources.write(subprocess.check_output([ + '../../.venv/bin/mako-render' if os.path.exists('../../.venv/bin/mako-render') else 'mako-render', + f'{target_path}.mako']).decode('utf-8')) # Add any paths that contain templates here, relative to this directory. templates_path = ['doc/_buildtemplates'] diff --git a/doc/source/contrib/data_sources/index.rst b/doc/source/contrib/data_sources/index.rst new file mode 100644 index 0000000000..4510799391 --- /dev/null +++ b/doc/source/contrib/data_sources/index.rst @@ -0,0 +1,29 @@ +.. _contrib-data-sources: + +Data Sources +------------ + +``pyramid_oereb`` provides a plugable system to offer an extendable system. The most +interesting part of that is probably the extension of what data sources should be +connected to the core system of ``pyramid_oereb``. + +As of now ``pyramid_oereb`` offers the following data sources (db structures) you can store +your data to: + +* :ref:`contrib-data-sources-standard` +* oereblex +* interlis 2.3 + + + +In addition there is a source to use with the address localisation: + +* swisstopo + +.. toctree:: + :hidden: + + standard/index + oereblex/index + interlis_2_3/index + swisstopo/index diff --git a/doc/source/contrib/data_sources/index.rst.mako b/doc/source/contrib/data_sources/index.rst.mako new file mode 100644 index 0000000000..4510799391 --- /dev/null +++ b/doc/source/contrib/data_sources/index.rst.mako @@ -0,0 +1,29 @@ +.. _contrib-data-sources: + +Data Sources +------------ + +``pyramid_oereb`` provides a plugable system to offer an extendable system. The most +interesting part of that is probably the extension of what data sources should be +connected to the core system of ``pyramid_oereb``. + +As of now ``pyramid_oereb`` offers the following data sources (db structures) you can store +your data to: + +* :ref:`contrib-data-sources-standard` +* oereblex +* interlis 2.3 + + + +In addition there is a source to use with the address localisation: + +* swisstopo + +.. toctree:: + :hidden: + + standard/index + oereblex/index + interlis_2_3/index + swisstopo/index diff --git a/doc/source/contrib/data_sources/interlis_2_3/index.rst b/doc/source/contrib/data_sources/interlis_2_3/index.rst new file mode 100644 index 0000000000..ec971023e2 --- /dev/null +++ b/doc/source/contrib/data_sources/interlis_2_3/index.rst @@ -0,0 +1,8 @@ +.. _contrib-data-sources-interlis-23: + +Application schema Models +========================= + + +.. toctree:: + :hidden: diff --git a/doc/source/contrib/data_sources/interlis_2_3/index.rst.mako b/doc/source/contrib/data_sources/interlis_2_3/index.rst.mako new file mode 100644 index 0000000000..ec971023e2 --- /dev/null +++ b/doc/source/contrib/data_sources/interlis_2_3/index.rst.mako @@ -0,0 +1,8 @@ +.. _contrib-data-sources-interlis-23: + +Application schema Models +========================= + + +.. toctree:: + :hidden: diff --git a/doc/source/contrib/data_sources/oereblex/index.rst b/doc/source/contrib/data_sources/oereblex/index.rst new file mode 100644 index 0000000000..6e0835218a --- /dev/null +++ b/doc/source/contrib/data_sources/oereblex/index.rst @@ -0,0 +1,8 @@ +.. _contrib-data-sources-oereblex: + +ÖREBlex +======= + + +.. toctree:: + :hidden: diff --git a/doc/source/contrib/data_sources/oereblex/index.rst.mako b/doc/source/contrib/data_sources/oereblex/index.rst.mako new file mode 100644 index 0000000000..6e0835218a --- /dev/null +++ b/doc/source/contrib/data_sources/oereblex/index.rst.mako @@ -0,0 +1,8 @@ +.. _contrib-data-sources-oereblex: + +ÖREBlex +======= + + +.. toctree:: + :hidden: diff --git a/doc/source/contrib/data_sources/standard/index.rst b/doc/source/contrib/data_sources/standard/index.rst new file mode 100644 index 0000000000..a00d92210b --- /dev/null +++ b/doc/source/contrib/data_sources/standard/index.rst @@ -0,0 +1,43 @@ +.. _contrib-data-sources-standard: + +Standard +^^^^^^^^ + +The standard data source is a binding to a database following the definitions of +`OeREBKRMkvs_V2_0 `__ +and `OeREBKRMtrsfr_V2_0 `__ +but adds some magic sugar for convenience. + +Exemplary schema of a standard database: + + .. image:: ../../../../images/standard_database_schema_example.png + :scale: 20 % + :align: center + +This structure is defined as models for SQL-Alchemy ORM and as a fitting set of +DataBaseSource-Adapters to hook it into the core of ``pyramid_oereb``. The models +defined in this contribution package describing 2 different structures. The ``main`` +definitions are used by ``pyramid_oereb`` application itself and contain the application +configuration as suggested in +`OeREBKRMkvs_V2_0 `__. +The ``theme`` definitions define a single ÖREB-Theme as it is suggested by +`OeREBKRMtrsfr_V2_0 `__. +Please be aware that for performance reasons the schematic mapping of SQL-Alchemy ORM +definitions and the linked INTERLIS models is not 1:1. + +The definition of main and theme schema share some classes. These are provided via +factory methods at modul level. These methods can be found here :ref:`contrib-data-sources-standard-models` + +* :ref:`contrib-data-sources-standard-models` +* :ref:`contrib-data-sources-standard-models-main` +* :ref:`contrib-data-sources-standard-models-theme` +* :ref:`contrib-data-sources-standard-sources` + + +.. toctree:: + :hidden: + + models + models-main + models-theme + sources diff --git a/doc/source/contrib/data_sources/standard/index.rst.mako b/doc/source/contrib/data_sources/standard/index.rst.mako new file mode 100644 index 0000000000..a00d92210b --- /dev/null +++ b/doc/source/contrib/data_sources/standard/index.rst.mako @@ -0,0 +1,43 @@ +.. _contrib-data-sources-standard: + +Standard +^^^^^^^^ + +The standard data source is a binding to a database following the definitions of +`OeREBKRMkvs_V2_0 `__ +and `OeREBKRMtrsfr_V2_0 `__ +but adds some magic sugar for convenience. + +Exemplary schema of a standard database: + + .. image:: ../../../../images/standard_database_schema_example.png + :scale: 20 % + :align: center + +This structure is defined as models for SQL-Alchemy ORM and as a fitting set of +DataBaseSource-Adapters to hook it into the core of ``pyramid_oereb``. The models +defined in this contribution package describing 2 different structures. The ``main`` +definitions are used by ``pyramid_oereb`` application itself and contain the application +configuration as suggested in +`OeREBKRMkvs_V2_0 `__. +The ``theme`` definitions define a single ÖREB-Theme as it is suggested by +`OeREBKRMtrsfr_V2_0 `__. +Please be aware that for performance reasons the schematic mapping of SQL-Alchemy ORM +definitions and the linked INTERLIS models is not 1:1. + +The definition of main and theme schema share some classes. These are provided via +factory methods at modul level. These methods can be found here :ref:`contrib-data-sources-standard-models` + +* :ref:`contrib-data-sources-standard-models` +* :ref:`contrib-data-sources-standard-models-main` +* :ref:`contrib-data-sources-standard-models-theme` +* :ref:`contrib-data-sources-standard-sources` + + +.. toctree:: + :hidden: + + models + models-main + models-theme + sources diff --git a/doc/source/contrib/data_sources/standard/models-main.rst b/doc/source/contrib/data_sources/standard/models-main.rst new file mode 100644 index 0000000000..a350a77181 --- /dev/null +++ b/doc/source/contrib/data_sources/standard/models-main.rst @@ -0,0 +1,192 @@ +.. _contrib-data-sources-standard-models-main: + +ORM Models for application Main schema +`````````````````````````````````````` + + + + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.models.main + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-address: + +*Address* +''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.Address + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-availability: + +*Availability* +'''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.Availability + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-dataintegration: + +*DataIntegration* +''''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.DataIntegration + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-disclaimer: + +*Disclaimer* +'''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.Disclaimer + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-documenttypetext: + +*DocumentTypeText* +'''''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.DocumentTypeText + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-generalinformation: + +*GeneralInformation* +'''''''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.GeneralInformation + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-glossary: + +*Glossary* +'''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.Glossary + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-lawstatus: + +*LawStatus* +''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.LawStatus + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-logo: + +*Logo* +'''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.Logo + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-maplayering: + +*MapLayering* +''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.MapLayering + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-municipality: + +*Municipality* +'''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.Municipality + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-realestate: + +*RealEstate* +'''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.RealEstate + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-realestatetype: + +*RealEstateType* +'''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.RealEstateType + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-theme: + +*Theme* +''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.Theme + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-main-themedocument: + +*ThemeDocument* +''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.main.ThemeDocument + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + diff --git a/doc/source/contrib/sources.rst.mako b/doc/source/contrib/data_sources/standard/models-main.rst.mako similarity index 72% rename from doc/source/contrib/sources.rst.mako rename to doc/source/contrib/data_sources/standard/models-main.rst.mako index 37909edd2b..5e3ef5acd0 100644 --- a/doc/source/contrib/sources.rst.mako +++ b/doc/source/contrib/data_sources/standard/models-main.rst.mako @@ -1,20 +1,23 @@ -.. _contrib-sources: +.. _contrib-data-sources-standard-models-main: -Sources -------- +ORM Main schema +``````````````` -<%! import glob, inspect, re, sys %> +<%! +import glob, inspect, re, sys +from pyramid_oereb.core.config import Config +Config._config = {'srid': -1, 'app_schema': {'name': 'pyramid_oereb_main'}} +%> <% modules = [m for m in sys.modules.keys() if m.startswith('pyramid_oereb')] -files = glob.glob('../../pyramid_oereb/contrib/data_sources/oereblex/sources/*.py') -files += glob.glob('../../pyramid_oereb/contrib/data_sources/swisstopo/*.py') -files += glob.glob('../../pyramid_oereb/contrib/data_sources/interlis_2_3/sources/*.py') +files = glob.glob('../../pyramid_oereb/contrib/data_sources/standard/models/main.py') modules = [ re.sub(r'\.__init__', '', f[6:-3].replace("/", ".")) for f in files ] - modules.sort() + delete_modules = [] + for i, module in enumerate(modules): try: __import__(module) @@ -39,16 +42,16 @@ underline = ['^', '`', '\'', '.', '~', '*'] .. automodule:: ${module} - %for cls in classes[module]: .. _api-${module.replace('.', '-').lower()}-${cls.lower()}: *${cls}* -${re.sub('.', underline[0], 'Class ' + cls)} +${underline[2]*len("*"+cls+"*")} .. autoclass:: ${module}.${cls} :members: :inherited-members: + :show-inheritance: .. automethod:: __init__ diff --git a/doc/source/contrib/data_sources/standard/models-theme.rst b/doc/source/contrib/data_sources/standard/models-theme.rst new file mode 100644 index 0000000000..7f1659da04 --- /dev/null +++ b/doc/source/contrib/data_sources/standard/models-theme.rst @@ -0,0 +1,24 @@ +.. _contrib-data-sources-standard-models-theme: + +ORM Models for application Theme schema +``````````````````````````````````````` + + + + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-theme: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.models.theme + +.. _api-pyramid_oereb-contrib-data_sources-standard-models-theme-models: + +*Theme Models* +'''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.models.theme.Models + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + diff --git a/doc/source/contrib/data_sources/standard/models-theme.rst.mako b/doc/source/contrib/data_sources/standard/models-theme.rst.mako new file mode 100644 index 0000000000..19fb718bc6 --- /dev/null +++ b/doc/source/contrib/data_sources/standard/models-theme.rst.mako @@ -0,0 +1,59 @@ +.. _contrib-data-sources-standard-models-theme: + +ORM Theme schema +```````````````` + +<%! +import glob, inspect, re, sys +from pyramid_oereb.core.config import Config +Config._config = {'srid': -1, 'app_schema': {'name': 'pyramid_oereb_main'}} +%> +<% +modules = [m for m in sys.modules.keys() if m.startswith('pyramid_oereb')] +files = glob.glob('../../pyramid_oereb/contrib/data_sources/standard/models/theme.py') +modules = [ + re.sub(r'\.__init__', '', f[6:-3].replace("/", ".")) for f in files +] +modules.sort() + +delete_modules = [] + +for i, module in enumerate(modules): + try: + __import__(module) + except ImportError: + delete_modules.append(i) +delete_modules.reverse() +for i in delete_modules: + del modules[i] + +classes = {} +for module in modules: + classes[module] = [] + for name, obj in inspect.getmembers(sys.modules[module]): + if inspect.isclass(obj) and obj.__module__ == module: + classes[module].append(name) + +underline = ['^', '`', '\'', '.', '~', '*'] +%> + +%for module in modules: +.. _api-${module.replace('.', '-').lower()}: + +.. automodule:: ${module} + +%for cls in classes[module]: +.. _api-${module.replace('.', '-').lower()}-${cls.lower()}: + +*${module.split('.')[-1].title()} ${cls}* +${underline[2]*len("*"+module.split('.')[-1].title()+' '+cls+"*")} + +.. autoclass:: ${module}.${cls} + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +%endfor +%endfor \ No newline at end of file diff --git a/doc/source/contrib/data_sources/standard/models.rst b/doc/source/contrib/data_sources/standard/models.rst new file mode 100644 index 0000000000..fc00e35e0c --- /dev/null +++ b/doc/source/contrib/data_sources/standard/models.rst @@ -0,0 +1,6 @@ +.. _contrib-data-sources-standard-models: + +ORM Models for application Main AND Theme schema +```````````````````````````````````````````````` +.. automodule:: pyramid_oereb.contrib.data_sources.standard.models + :members: diff --git a/doc/source/contrib/data_sources/standard/models.rst.mako b/doc/source/contrib/data_sources/standard/models.rst.mako new file mode 100644 index 0000000000..2086500cb6 --- /dev/null +++ b/doc/source/contrib/data_sources/standard/models.rst.mako @@ -0,0 +1,6 @@ +.. _contrib-data-sources-standard-models: + +ORM Common +`````````` +.. automodule:: pyramid_oereb.contrib.data_sources.standard.models + :members: diff --git a/doc/source/contrib/data_sources/standard/sources.rst b/doc/source/contrib/data_sources/standard/sources.rst new file mode 100644 index 0000000000..6331327bfe --- /dev/null +++ b/doc/source/contrib/data_sources/standard/sources.rst @@ -0,0 +1,328 @@ +.. _contrib-data-sources-standard-sources: + +Sources +``````` + + + + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-address: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.address + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-address-databasesource: + +*Address* +''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.address.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-availability: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.availability + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-availability-databasesource: + +*Availability* +'''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.availability.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-data_integration: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.data_integration + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-data_integration-databasesource: + +*Data_Integration* +'''''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.data_integration.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-disclaimer: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.disclaimer + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-disclaimer-databasesource: + +*Disclaimer* +'''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.disclaimer.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-document: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.document + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-document-databasesource: + +*Document* +'''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.document.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-document_types: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.document_types + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-document_types-databasesource: + +*Document_Types* +'''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.document_types.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-general_information: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.general_information + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-general_information-databasesource: + +*General_Information* +''''''''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.general_information.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-glossary: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.glossary + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-glossary-databasesource: + +*Glossary* +'''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.glossary.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-law_status: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.law_status + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-law_status-databasesource: + +*Law_Status* +'''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.law_status.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-legend: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.legend + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-legend-databasesource: + +*Legend* +'''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.legend.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-logo: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.logo + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-logo-databasesource: + +*Logo* +'''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.logo.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-map_layering: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.map_layering + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-map_layering-databasesource: + +*Map_Layering* +'''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.map_layering.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-municipality: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.municipality + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-municipality-databasesource: + +*Municipality* +'''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.municipality.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-office: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.office + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-office-databasesource: + +*Office* +'''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.office.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-plr: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.plr + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-plr-databasesource: + +*Plr* +''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.plr.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-plr-standardthemeconfigparser: + +*Plr* +''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.plr.StandardThemeConfigParser + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-real_estate: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.real_estate + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-real_estate-databasesource: + +*Real_Estate* +''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.real_estate.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-real_estate_type: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.real_estate_type + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-real_estate_type-databasesource: + +*Real_Estate_Type* +'''''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.real_estate_type.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-theme: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.theme + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-theme-databasesource: + +*Theme* +''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.theme.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-theme_document: + +.. automodule:: pyramid_oereb.contrib.data_sources.standard.sources.theme_document + +.. _api-pyramid_oereb-contrib-data_sources-standard-sources-theme_document-databasesource: + +*Theme_Document* +'''''''''''''''' + +.. autoclass:: pyramid_oereb.contrib.data_sources.standard.sources.theme_document.DatabaseSource + :members: + :inherited-members: + :show-inheritance: + + .. automethod:: __init__ + diff --git a/doc/source/standard/sources.rst.mako b/doc/source/contrib/data_sources/standard/sources.rst.mako similarity index 77% rename from doc/source/standard/sources.rst.mako rename to doc/source/contrib/data_sources/standard/sources.rst.mako index f33f9f3c18..baacd33f07 100644 --- a/doc/source/standard/sources.rst.mako +++ b/doc/source/contrib/data_sources/standard/sources.rst.mako @@ -1,18 +1,19 @@ -.. _standard-sources: +.. _contrib-data-sources-standard-sources: Sources -------- +``````` -<%! import glob, inspect, re, sys %> +<%! import glob, inspect, re, sys%> <% modules = [m for m in sys.modules.keys() if m.startswith('pyramid_oereb')] -files = glob.glob('../../pyramid_oereb/core/sources/*.py') +files = glob.glob('../../pyramid_oereb/contrib/data_sources/standard/sources/*.py') modules = [ re.sub(r'\.__init__', '', f[6:-3].replace("/", ".")) for f in files ] - modules.sort() + delete_modules = [] + for i, module in enumerate(modules): try: __import__(module) @@ -37,16 +38,16 @@ underline = ['^', '`', '\'', '.', '~', '*'] .. automodule:: ${module} - %for cls in classes[module]: .. _api-${module.replace('.', '-').lower()}-${cls.lower()}: -*${module.split('.')[-1].title().replace('_', ' ')} ${cls}* -${re.sub('.', underline[0], module.split('.')[-1] + ' ' + cls)} +*${module.split('.')[-1].title()}* +${underline[2]*len("*"+module.split('.')[-1].title()+"*")} .. autoclass:: ${module}.${cls} :members: :inherited-members: + :show-inheritance: .. automethod:: __init__ diff --git a/doc/source/contrib/data_sources/swisstopo/index.rst b/doc/source/contrib/data_sources/swisstopo/index.rst new file mode 100644 index 0000000000..827677f7bf --- /dev/null +++ b/doc/source/contrib/data_sources/swisstopo/index.rst @@ -0,0 +1,8 @@ +.. _contrib-data-sources-swisstopo: + +Application schema Models +========================= + + +.. toctree:: + :hidden: diff --git a/doc/source/contrib/data_sources/swisstopo/index.rst.mako b/doc/source/contrib/data_sources/swisstopo/index.rst.mako new file mode 100644 index 0000000000..827677f7bf --- /dev/null +++ b/doc/source/contrib/data_sources/swisstopo/index.rst.mako @@ -0,0 +1,8 @@ +.. _contrib-data-sources-swisstopo: + +Application schema Models +========================= + + +.. toctree:: + :hidden: diff --git a/doc/source/contrib/index.rst b/doc/source/contrib/index.rst index 5c7d3c1c31..40fe4be639 100644 --- a/doc/source/contrib/index.rst +++ b/doc/source/contrib/index.rst @@ -10,7 +10,7 @@ Would you like to contribute to the project? Please see :ref:`contributing`. .. toctree:: :hidden: - sources + data_sources/index print_proxy stats contributing diff --git a/doc/source/index.rst b/doc/source/index.rst index 1b33706e1e..2fe031d8a0 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -11,9 +11,9 @@ pyramid_oereb (ÖREB-Server) documentation :hidden: installation + installation-dev configuration changes - standard/index contrib/index core/index faq diff --git a/doc/source/installation-dev.rst b/doc/source/installation-dev.rst new file mode 100644 index 0000000000..7a20914b98 --- /dev/null +++ b/doc/source/installation-dev.rst @@ -0,0 +1,17 @@ +.. _installation-dev: + +Installation for DEV's +====================== + +``pyramid_oereb`` is a piece of python software following the rules of the pyramid webframework. To develop +features there are basically two ways to setup: + +# Docker/Docker-Compose +# local system python with a virtualenv + +We recommend the Docker way since ``pyramid_oereb`` has dependencies around the geos/gdal/ogr stack which +might easily conflict with versions installed in a daily used system and therefore might lead to problems. + + + + diff --git a/doc/source/installation.rst b/doc/source/installation.rst index 72a79eddd1..a8bb7ca781 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -3,9 +3,9 @@ Installation ============ -This section will guide you through the steps to install and run an own DEV instance of ``pyramid_oereb`` using -the standard configuration. If you are planning to adapt the application to fit a custom data source, the -possibilities and additional steps are described in the section :ref:`configuration`. +This section will guide you through the steps to install and run an own DEV instance of ``pyramid_oereb`` +using the standard configuration. If you are planning to adapt the application to fit a custom data source, +the possibilities and additional steps are described in the section :ref:`configuration`. .. _installation-requirements: diff --git a/doc/source/standard/index.rst b/doc/source/standard/index.rst deleted file mode 100644 index 7f15487de6..0000000000 --- a/doc/source/standard/index.rst +++ /dev/null @@ -1,38 +0,0 @@ - -Standard -======== - -The standard package is the part where all the database configuration is stored. It also provides really -useful functions to integrate data, as well as creation of a YAML-configuration fitting this standard -structure. In addition you will find here the hook methods which are used in several places in the -configuration and an example usage of the pyconizer package to provide legend entry icons for a dedicated -layer. - -.. toctree:: - :hidden: - - sources - models/index - -Functions for creating standard environment -------------------------------------------- - -.. _api-pyramid_oereb-standard-create_tables: - -.. automodule:: pyramid_oereb.contrib.data_sources.create_tables - :members: - create_tables_from_standard_configuration - -.. _api-pyramid_oereb-standard-load_legend_entries: - -.. automodule:: pyramid_oereb.contrib.data_sources.standard.load_legend_entries - :members: - create_legend_entries_in_standard_db - -Functions used as configurable hooks ------------------------------------- - -.. _api-pyramid_oereb-standard-hook_methods: - -.. automodule:: pyramid_oereb.contrib.data_sources.standard.hook_methods - :members: diff --git a/doc/source/standard/models/factory_models.rst.mako b/doc/source/standard/models/factory_models.rst.mako deleted file mode 100644 index 3cc9bf0d07..0000000000 --- a/doc/source/standard/models/factory_models.rst.mako +++ /dev/null @@ -1,23 +0,0 @@ -<% import re%> - -.. _api-${module_name.replace('.', '-').lower()}: - -*${module_name.split('.')[-1].title().replace('_', ' ')}* -${re.sub('.', '^', module_name.split('.')[-1].title().replace('_', ' ') + ' ')} - -TODO: improve explication of how generic classes adapt to themes - -The classes below are generated through a class builder factory and are customized for the different themes (TODO: insert link) which make up the app. - -.. autoclass:: ${module_name} - -%for cls in classes: - -.. _api-${module_name.replace('.', '-').lower()}-${cls.lower()}: - -${cls} -${re.sub('.', '~', cls)} - -.. autoclass:: ${module_name}.${cls} - -%endfor \ No newline at end of file diff --git a/doc/source/standard/models/index.rst.mako b/doc/source/standard/models/index.rst.mako deleted file mode 100644 index 8aa1021ff3..0000000000 --- a/doc/source/standard/models/index.rst.mako +++ /dev/null @@ -1,20 +0,0 @@ -.. _api-pyramid_oereb-standard-models: - -Models -====== - -.. automodule:: pyramid_oereb.contrib.data_sources.standard.models - - -.. toctree:: - :hidden: - -%for file_name in module_file_names: - ${file_name} -%endfor - -Exemplary schema of a standard database ---------------------------------------- - .. image:: ../../../images/standard_database_schema_example.png - :scale: 20 % - :align: center diff --git a/doc/source/standard/models/models.rst.mako b/doc/source/standard/models/models.rst.mako deleted file mode 100644 index 085cf093fd..0000000000 --- a/doc/source/standard/models/models.rst.mako +++ /dev/null @@ -1,23 +0,0 @@ -<% import re%> - -.. _api-${module_name.replace('.', '-').lower()}: - -*${module_name.split('.')[-1].title().replace('_', ' ')}* -${re.sub('.', '^', module_name.split('.')[-1].title().replace('_', ' ') + ' ')} - -.. automodule:: ${module_name} - -%for cls in classes: - -.. _api-${module_name.replace('.', '-').lower()}-${cls.lower()}: - -${cls} -${re.sub('.', '~', cls)} - -.. autoclass:: ${module_name}.${cls} - :members: - :inherited-members: - - .. automethod:: __init__ - -%endfor \ No newline at end of file diff --git a/pyramid_oereb/contrib/data_sources/standard/models/__init__.py b/pyramid_oereb/contrib/data_sources/standard/models/__init__.py index 20090a7e01..ea8d2b6c93 100644 --- a/pyramid_oereb/contrib/data_sources/standard/models/__init__.py +++ b/pyramid_oereb/contrib/data_sources/standard/models/__init__.py @@ -2,6 +2,16 @@ """ This Package provides all models fitting to the standard database configuration. It is separated by the 17 mandatory topics the federation asks for. + +The following functions are class factories to enable reuse and making SQL-Alchemy +classes configurable. + +The classes produced by the factory methods are shared in different contrib modules. +As of the moment of writing this includes: + +* :ref:`contrib-data-sources-standard` +* :ref:`contrib-data-sources-oereblex` + """ diff --git a/pyramid_oereb/contrib/data_sources/standard/models/main.py b/pyramid_oereb/contrib/data_sources/standard/models/main.py index 82cd536901..c16f145ed7 100644 --- a/pyramid_oereb/contrib/data_sources/standard/models/main.py +++ b/pyramid_oereb/contrib/data_sources/standard/models/main.py @@ -16,7 +16,7 @@ pyramid_oereb_main -But you can change it also via configuration. +But you can change it also via :ref:`configuration`. Note: Whenever you configure your own sqlalchemy ORM's to use them in this application you must imitate diff --git a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py index 0527815880..06c9f31591 100644 --- a/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py +++ b/pyramid_oereb/contrib/print_proxy/mapfish_print/mapfish_print.py @@ -784,11 +784,12 @@ def sort_by_index(elem): """ Provides the sort key for the supplied hint / law / legal provision element as a tuple consisting of: - * index - Notes - - index is defined by Interlis model OeREBKRM_V2_0 as range -1000..1000 - - "Index = None" if geolink_formatter processes entry from OEREBLEX that has no index + * index + + Notes: + - index is defined by Interlis model OeREBKRM_V2_0 as range -1000..1000 + - "Index = None" if geolink_formatter processes entry from OEREBLEX that has no index Args: elem (dict): one element of the hints / laws / legal provisions list Returns: diff --git a/pyramid_oereb/core/records/view_service.py b/pyramid_oereb/core/records/view_service.py index cd98ac02d4..cd88cad012 100644 --- a/pyramid_oereb/core/records/view_service.py +++ b/pyramid_oereb/core/records/view_service.py @@ -46,7 +46,7 @@ def __init__(self, symbol, legend_text, type_code, type_code_list, theme, sub_theme (pyramid_oereb.lib.records.theme.ThemeRecord): The optional sub theme to which the legend entry belongs. identifier (str): The identifier of the legend entry which might be used for linking to - other elements. + other elements. """ if not isinstance(legend_text, dict): warnings.warn('Type of "legend_text" should be "dict"' @@ -116,9 +116,10 @@ def __init__(self, reference_wms, layer_index, layer_opacity, default_language, @staticmethod def sanitize_layer_index(layer_index): """ - Checks the validity of the layer index + Checks the validity of the layer index. + Arg: - layer_index (int): index of the layer + layer_index (int): index of the layer Returns: int: the layer index if it is an int berween -1000 and 1000. @@ -163,6 +164,7 @@ def check_min_max_attributes(min_point, min_name, max_point, max_name): Checks the validity of a min and max point: - type check - min_point < max_point + Args: min_point (shapely.geometry.point.Point): a point geometry min_name (): the name of the point