Interfaces
pyramid_oereb
This module offers the interface to the pyramid_oereb library.
All usage of pyramid_oereb
elements should be implemented here and proxied through this part
of geolink2oereb. That makes it easier to adapt once changes occur.
- class geolink2oereb.lib.interfaces.pyramid_oereb.OEREBlexSourceCustom(**kwargs)[source]
This subclass is basically used to manipulate the behaviour of the normal OEREBlexSource as it is used in
pyramid_oereb
.Main changes are: - adaption of _get_document_title to be able to manipulate title of documents more easy - adaption of _get_document_records to add a filter for federal documents because they are provided
in another way and can be omitted.
Creates a new OEREBlex document source.
- Keyword Arguments:
host (
uri
) – Host URL of OEREBlex (without /api/…).version (
str
) – The used geoLink schema version. Default is 1.2.2pass_version (
bool
) – True to pass version in URL, false otherwise. Defaults is false.language (
str
) – The language of the received data.canton (
str
) – Canton code used for the documents.mapping (
dict of str
) – Mapping for optional attributes.related_decree_as_main (
bool
) – Add related decrees directly to the public law restriction.related_notice_as_main (
bool
) – Add related notices directly to the public law restriction.proxy (
dict of uri
) – Optional proxy configuration for HTTP and/or HTTPS.auth (
dict of str
) – Optional credentials for basic authentication. Requires username and password to be defined.validation (
bool
) – Turn XML validation on/off. Default is true.url_param_config (
list of code and url_param
) – Optional url parameters to use, per plr codecode (
str
) – The official code. Regarding to the federal specifications.use_prepubs (
bool
) – If true and the law status is not “inForce”, the prepubs URL will be used. Default is false.
- property filter_federal_documents
A list to filter documents. It can be adopted to manipulate how the filter should work. In the default implementation it comletely skip federal documents because they should be added via official sources: https://models.geo.admin.ch/V_D/OeREB/OeREBKRM_V2_0_Gesetze.xml
The strings in the list are applied to the
federal_level
of a ÖEREBlex document.- Returns:
The filter strings which are applied to
federal_level
of a ÖEREBlex document.- Return type:
list of str
- geolink2oereb.lib.interfaces.pyramid_oereb.create_document_source(source_config, theme_code, language, oereb_lex_document_source_class=<class 'pyramid_oereb.contrib.data_sources.oereblex.sources.document.OEREBlexSource'>)[source]
Interface method to
pyramid_oereb
, to complete the config of the usedpyramid_oereb
source with missing elements and create the actual data source.- Parameters:
source_config (
dict
) – The config dict which is used to instanciate the ÖEREBlex Source.theme_code (
str
) – The theme code matching thepyramid_oereb
configuration.language (
str
) – The language code (de, it, fr, …).oereb_lex_document_source_class (
pyramid_oereb.contrib.data_sources.oereblex.sources.document.OEREBlexSource
) – # noqa: E501 The class which is used to produce the document records.
- Returns:
- The source to read
the documents.
- Return type:
pyramid_oereb.contrib.data_sources.oereblex.sources.document.OEREBlexSource
- geolink2oereb.lib.interfaces.pyramid_oereb.get_document_type_code_by_extract_value(theme_code, extract_value)[source]
Interface method to
pyramid_oereb
. Shortcut method to access the translation ofdocument_types
as defined inpyramid_oereb
configuration yaml.- Parameters:
theme_code (
str
) – The theme code matching thepyramid_oereb
configuration.extract_value (
str
) – Thedocument_type
as it is expected in the extract.
- Returns:
The translated
document_type
or None if no match was found.- Return type:
None or str
- geolink2oereb.lib.interfaces.pyramid_oereb.get_law_status_code_by_extract_value(theme_code, extract_value)[source]
Interface method to
pyramid_oereb
. Shortcut method to access the translation oflaw_status_codes
as defined inpyramid_oereb
configuration yaml.- Parameters:
theme_code (
str
) – The theme code matching thepyramid_oereb
configuration.extract_value (
str
) – Thelaw_status_code
as it is expected in the extract.
- Returns:
The translated
law_status_code
or None if no match was found.- Return type:
None or str
- geolink2oereb.lib.interfaces.pyramid_oereb.load(geolink_id, theme_code, pyramid_oereb_config_path, pyramid_config_section, source_class_path='geolink2oereb.lib.interfaces.pyramid_oereb.OEREBlexSourceCustom', c2ctemplate_style=False)[source]
Interface method to
pyramid_oereb
. It utilizes the lib to obtain a set of records from ÖREBlex.- Parameters:
geolink_id (
int
) – The geoLink ID (lexlink ID).theme_code (
str
) – The theme code matching thepyramid_oereb
configuration.pyramid_oereb_config_path (
str
) – The configuration yaml file path.pyramid_config_section (
str
) – The section within the yaml file.source_class_path (
str
) – The point separated path to the class which is used to produce the document records (Default:geolink2oereb.lib.interfaces.pyramid_oereb.OEREBlexSourceCustom
).c2ctemplate_style (
bool
) – If set to true, c2c.template library will be used to load config file (Default: False).
- Returns:
- The collected and corrected
documents, with types and offices.
- Return type:
list of pyramid_oereb.core.records.documents.DocumentRecord
- geolink2oereb.lib.interfaces.pyramid_oereb.make_office_at_web_multilingual(documents, language)[source]
ÖEREBlex offers multilingual elements via different URLS. With this method we combine all available languages into one multilingual element.
- Parameters:
documents (
list of pyramid_oereb.core.records.documents.DocumentRecord
) – The records to change the office.language (
str
) – the language code which will be used to make it multilingual.
Returns (list of pyramid_oereb.core.records.documents.DocumentRecord): the updated records.
- geolink2oereb.lib.interfaces.pyramid_oereb.merge_attribute(master_attribute, merger_attribute)[source]
A helper method to merge attributes which can be a dict or None.
- Parameters:
master_attribute (
dict or None
) – The master attribute.merger_attribute (
dict or None
) – The merger attribute.
- Returns:
The merged Attribute
- Return type:
dict or None
- geolink2oereb.lib.interfaces.pyramid_oereb.merge_document(master, merger)[source]
Merge multiple
DocumentRecord
to one. While processing ÖREBlex there can occur different versions of the same document in different languages. We try to solve that problem here.- Parameters:
master (
pyramid_oereb.core.records.documents.DocumentRecord
) – The record all date will be added to.merger (
pyramid_oereb.core.records.documents.DocumentRecord
) – The record all date will be taken from.
Returns (pyramid_oereb.core.records.documents.DocumentRecord): the updated master record.
- geolink2oereb.lib.interfaces.pyramid_oereb.merge_document_type(master, merger)[source]
Merge multiple
DocumentTypeRecord
to one. While processing ÖREBlex there can occur different versions of the same document type in different languages. We try to solve that problem here.- Parameters:
master (
pyramid_oereb.core.records.document_types.DocumentTypeRecord
) – The record all date will be added to.merger (
pyramid_oereb.core.records.document_types.DocumentTypeRecord
) – The record all date will be taken from.
Returns (pyramid_oereb.core.records.document_types.DocumentTypeRecord): the updated master record.
- geolink2oereb.lib.interfaces.pyramid_oereb.merge_office(master, merger)[source]
Merge multiple
OfficeRecords
to one. While processing ÖREBlex there can occur different versions of the same office in different languages. We try to solve that problem here.- Parameters:
master (
pyramid_oereb.core.records.office.OfficeRecord
) – The record all date will be added to.merger (
pyramid_oereb.core.records.office.OfficeRecord
) – The record all date will be taken from.
Returns (pyramid_oereb.core.records.office.OfficeRecord): the updated master record.
OeREBKRMtrsfr_V2_0 generators
This interface offers methods to access python classes matching the OeREBKRMtrsfr_V2_0
INTERLIS model. It
is used mainly for translation and handling between pyramid_oereb
and OeREBKRMtrsfr_V2_0
.
- geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.generators.document_record_to_oerebkrmtrsfr(document_record)[source]
Translates a
pyramid_oereb
document record object to an OeREBKRM_V2_0_Dokumente_Dokument object.- Parameters:
document_record (
pyramid_oereb.core.records.documents.DocumentRecord
) – The record to translate.- Returns:
tuple containing:
- geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Amt_Amt:
The office which belongs to the document (responsible office).
- geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Dokumente_Dokument:
The document.
- Return type:
(tuple)
- geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.generators.fix_url(url)[source]
Helper method to hotfix an often occurring problem with urls not being valid in the ili sense. The URLs out of ÖREBlex are missing the http/https part often. So we try to fix this on the fly.
- Parameters:
url (
str
) – The URL string which might be fixed.- Returns:
The maybe fixed URL.
- geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.generators.multilingual_text_from_dict(multilingual_dict)[source]
Produces a MultilingualText object out of a dict in the form:
{ "de": "Test", "it": "Testo" }
- Parameters:
multilingual_dict (
dict or None
) – The definition of the multilingual element or None.- Returns:
geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.TitelType
- geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.generators.multilingual_uri_from_dict(multilingual_dict)[source]
Produces a MultilingualText object out of a dict in the form:
{ "de": "Test", "it": "Testo" }
- Parameters:
multilingual_dict (
dict or None
) – The definition of the multilingual element or None.- Returns:
geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.TextImWebType
- geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.generators.office_record_to_oerebkrmtrsfr(office_record)[source]
Translates a
pyramid_oereb
office record object to an OeREBKRM_V2_0_Amt_Amt object.- Parameters:
office_record (
pyramid_oereb.core.records.office.OfficeRecord
) – The office record to translate.- Returns:
geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Amt_Amt
OeREBKRMtrsfr_V2_0 classes
This is a selection of classes available to adapt to OeREBKRMtrsfr_V2_0
. The selection shows the classes
used in the current implementation. Please have a look in the source file to see the complete implementation.
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Dokumente_Dokument(TID=None, Typ=None, Titel=None, Abkuerzung=None, OffizielleNr=None, NurInGemeinde=None, TextImWeb=None, Dokument=None, AuszugIndex=None, Rechtsstatus=None, publiziertAb=None, publiziertBis=None, ZustaendigeStelle=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='OeREBKRM_V2_0.Dokumente.Dokument', pretty_print=True)[source]
- member_data_items_ = {'Abkuerzung': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'AuszugIndex': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Dokument': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'NurInGemeinde': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'OffizielleNr': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Rechtsstatus': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'TID': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'TextImWeb': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Titel': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Typ': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'ZustaendigeStelle': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'publiziertAb': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'publiziertBis': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- validate_IliID_patterns_ = [['^(([a-zA-Z_][0-9a-zA-Z_\\-\\.]*:)?[0-9a-zA-Z_][0-9a-zA-Z_\\-\\.]*)$']]
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_Amt_Amt(TID=None, Name=None, AmtImWeb=None, UID=None, Zeile1=None, Zeile2=None, Strasse=None, Hausnr=None, PLZ=None, Ort=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='OeREBKRM_V2_0.Amt.Amt', pretty_print=True)[source]
- member_data_items_ = {'AmtImWeb': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Hausnr': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Name': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Ort': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'PLZ': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Strasse': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'TID': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'UID': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Zeile1': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Zeile2': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- validate_IliID_patterns_ = [['^(([a-zA-Z_][0-9a-zA-Z_\\-\\.]*:)?[0-9a-zA-Z_][0-9a-zA-Z_\\-\\.]*)$']]
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.ZustaendigeStelleType(REF=None, BID=None, ORDER_POS=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_='', name_='ZustaendigeStelleType', pretty_print=True)[source]
- member_data_items_ = {'BID': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'ORDER_POS': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'REF': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- validate_IliID_patterns_ = [['^(([a-zA-Z_][0-9a-zA-Z_\\-\\.]*:)?[0-9a-zA-Z_][0-9a-zA-Z_\\-\\.]*)$']]
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.TitelType(LocalisationCH_V1_MultilingualText=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='TitelType', pretty_print=True)[source]
- member_data_items_ = {'LocalisationCH_V1_MultilingualText': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.TextImWebType(OeREBKRM_V2_0_MultilingualUri=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='TextImWebType', pretty_print=True)[source]
- member_data_items_ = {'OeREBKRM_V2_0_MultilingualUri': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_MultilingualUri(LocalisedText=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='OeREBKRM_V2_0.MultilingualUri', pretty_print=True)[source]
- member_data_items_ = {'LocalisedText': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.OeREBKRM_V2_0_LocalisedUri(Language=None, Text=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='OeREBKRM_V2_0.LocalisedUri', pretty_print=True)[source]
- member_data_items_ = {'Language': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Text': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.LocalisedTextType(LocalisationCH_V1_LocalisedText=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='LocalisedTextType', pretty_print=True)[source]
- member_data_items_ = {'LocalisationCH_V1_LocalisedText': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.LocalisedTextType86(OeREBKRM_V2_0_LocalisedUri=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='LocalisedTextType86', pretty_print=True)[source]
- member_data_items_ = {'OeREBKRM_V2_0_LocalisedUri': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.LocalisationCH_V1_LocalisedText(Language=None, Text=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='LocalisationCH_V1.LocalisedText', pretty_print=True)[source]
- member_data_items_ = {'Language': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>, 'Text': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.LocalisationCH_V1_MultilingualText(LocalisedText=None, gds_collector_=None, **kwargs_)[source]
-
- export(outfile, level, namespaceprefix_='', namespacedef_=' xmlns:None="http://www.interlis.ch/INTERLIS2.3" ', name_='LocalisationCH_V1.MultilingualText', pretty_print=True)[source]
- member_data_items_ = {'LocalisedText': <geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.MemberSpec_ object>}
- subclass = None
- superclass = None
geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.GeneratedsSuper
is the superclass all above
mentioned classes are inheriting from.
- class geolink2oereb.lib.interfaces.oerebkrmtrsfr.v2_0.classes.GeneratedsSuper[source]
- Tag_strip_pattern_ = re.compile('\\{.*\\}')
- gds_validate_builtin_ST_(validator, value, input_name, min_occurs=None, max_occurs=None, required=None)[source]
- gds_validate_defined_ST_(validator, value, input_name, min_occurs=None, max_occurs=None, required=None)[source]
- tzoff_pattern = re.compile('(\\+|-)((0\\d|1[0-3]):[0-5]\\d|14:00)$')