def parse(self, view_service): # pragma: no cover language = Config.get('default_language') for element in view_service: if get_tag(element) == self.TAG_LEGEND: count = 1 for legend_entry in element: if get_tag(legend_entry) == self.TAG_LEGEND_ENTRY: sub_theme = parse_string(legend_entry, self.TAG_SUB_THEME) if sub_theme is not None: sub_theme = {language: sub_theme} instance = self._model( id='{0}.legende.{1}'.format( view_service.attrib['TID'], count), symbol=self._parse_symbol(legend_entry, self.TAG_SYMBOL), legend_text=parse_multilingual_text( legend_entry, self.TAG_LEGEND_TEXT), type_code=parse_string(legend_entry, self.TAG_TYPE_CODE), type_code_list=parse_string( legend_entry, self.TAG_TYPE_CODE_LIST), topic=self._topic_code, sub_theme=sub_theme, other_theme=parse_string(legend_entry, self.TAG_OTHER_THEME), view_service_id=view_service.attrib['TID']) self._session.add(instance) count += 1
def test_parse_string(): element = XML(""" <Element> <Property>Value</Property> </Element> """) assert parse_string(element, 'foo') is None assert parse_string(element, 'Property') == 'Value'
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, 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, view_service): # pragma: no cover reference_wms = parse_string(view_service, self.TAG_REFERENCE_WMS) legend_at_web = parse_string(view_service, self.TAG_LEGEND_AT_WEB) if legend_at_web is None and reference_wms is not None: legend_at_web = self._copy_legend_at_web_from_reference_wms(reference_wms) instance = self._model( id=view_service.attrib['TID'], reference_wms=reference_wms, legend_at_web=legend_at_web ) self._session.add(instance) self._legend_entry.parse(view_service)
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 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)