def parse(self, public_law_restriction): # pragma: no cover language = Config.get('default_language') sub_theme = parse_string(public_law_restriction, self.TAG_SUB_THEME) if sub_theme is not None: sub_theme = {language: sub_theme} instance = self._model( id=public_law_restriction.attrib['TID'], information=parse_multilingual_text(public_law_restriction, self.TAG_INFORMATION), topic=self._topic_code, sub_theme=sub_theme, other_theme=parse_string(public_law_restriction, self.TAG_OTHER_THEME), type_code=parse_string(public_law_restriction, self.TAG_TYPE_CODE), type_code_list=parse_string(public_law_restriction, self.TAG_TYPE_CODE_LIST), law_status=parse_string(public_law_restriction, self.TAG_LAW_STATUS), published_from=parse_string(public_law_restriction, self.TAG_PUBLISHED_FROM), view_service_id=parse_ref(public_law_restriction, self.TAG_VIEW_SERVICE), office_id=parse_ref(public_law_restriction, self.TAG_RESPONSIBLE_OFFICE)) self._session.add(instance)
def parse(self, plr_document): # pragma: no cover source = parse_ref(plr_document, self.TAG_SOURCE) target = parse_ref(plr_document, self.TAG_TARGET) instance = self._model(id='{0}-{1}'.format(source, target), public_law_restriction_id=source, document_id=target, article_numbers=parse_article_numbers( plr_document, self.TAG_ARTICLE_NUMBERS)) self._session.add(instance)
def parse(self, document_reference_definition): # pragma: no cover document_id = parse_ref(document_reference_definition, self.TAG_DOCUMENT) reference_definition_id = parse_ref(document_reference_definition, self.TAG_REFERENCE_DEFINITION) instance = self._model( id='{0}-{1}'.format(document_id, reference_definition_id), document_id=document_id, reference_definition_id=reference_definition_id ) self._session.add(instance)
def parse(self, geometry): # pragma: no cover instance = self._model( id=geometry.attrib['TID'], law_status=parse_string(geometry, self.TAG_LAW_STATUS), published_from=parse_string(geometry, self.TAG_PUBLISHED_FROM), geo_metadata=parse_string(geometry, self.TAG_GEO_METADATA), public_law_restriction_id=parse_ref( geometry, self.TAG_PUBLIC_LAW_RESTRICTION), office_id=parse_ref(geometry, self.TAG_RESPONSIBLE_OFFICE), geom=self._parse_geom(geometry)) self._session.add(instance)
def parse(self, document_reference): # pragma: no cover source = parse_ref(document_reference, self.TAG_SOURCE) target = parse_ref(document_reference, self.TAG_TARGET) instance = self._model( id='{0}-{1}'.format(source, target), document_id=source, reference_document_id=target, article_numbers=parse_article_numbers( document_reference, self.TAG_ARTICLE_NUMBERS ) ) self._session.add(instance)
def parse(self, reference_definition): # pragma: no cover instance = self._model( id=reference_definition.attrib['TID'], topic=self._topic_code, canton=parse_string(reference_definition, self.TAG_CANTON), municipality=parse_string(reference_definition, self.TAG_MUNICIPALITY), office_id=parse_ref(reference_definition, self.TAG_RESPONSIBLE_OFFICE)) self._session.add(instance)
def parse(self, article): # pragma: no cover instance = self._model( id=article.attrib['TID'], text_at_web=parse_multilingual_text(article, self.TAG_TEXT_AT_WEB), law_status=parse_string(article, self.TAG_LAW_STATUS), published_from=parse_string(article, self.TAG_PUBLISHED_FROM), number=parse_string(article, self.TAG_NUMBER), text=parse_multilingual_text(article, self.TAG_TEXT), document_id=parse_ref(article, self.TAG_DOCUMENT)) self._session.add(instance)
def parse(self, document, document_type): # pragma: no cover instance = self._model( id=document.attrib['TID'], text_at_web=parse_multilingual_text(document, self.TAG_TEXT_AT_WEB), law_status=parse_string(document, self.TAG_LAW_STATUS), published_from=parse_string(document, self.TAG_PUBLISHED_FROM), document_type=document_type, title=parse_multilingual_text(document, self.TAG_TITLE), official_title=parse_multilingual_text(document, self.TAG_OFFICIAL_TITLE), abbreviation=parse_multilingual_text(document, self.TAG_ABBREVIATION), official_number=parse_string(document, self.TAG_OFFICIAL_NUMBER), office_id=parse_ref(document, self.TAG_RESPONSIBLE_OFFICE)) self._session.add(instance)
def test_parse_ref(): el = XML(""" <bar REF="foo"></bar> """) assert parse_ref([el], 'bar') == 'foo' assert parse_ref([el], 'baz') is None