Beispiel #1
0
    def from_xml(self, xml_distinfo):

        self.original_xml = xml_distinfo
        self.clear_widget()

        if xml_distinfo.tag == "distinfo":
            self.original_xml = xml_distinfo
            self.ui.radio_distyes.setChecked(True)
            if xml_distinfo.xpath("distrib/cntinfo"):
                self.contactinfo.from_xml(
                    xml_distinfo.xpath("distrib/cntinfo")[0])
            if xml_distinfo.xpath("distliab"):
                self.ui.radio_dist.setChecked(True)
                utils.populate_widget_element(widget=self.ui.fgdc_distliab,
                                              element=xml_distinfo,
                                              xpath="distliab")
                self.ui.fgdc_distliab.sizeChange()
            if xml_distinfo.xpath("custom"):
                self.ui.radio_otherdist.setChecked(True)
                utils.populate_widget_element(widget=self.ui.fgdc_custom,
                                              element=xml_distinfo,
                                              xpath="custom")
            if xml_distinfo.xpath("stdorder"):
                self.ui.radio_online.setChecked(True)
                utils.populate_widget_element(
                    widget=self.ui.fgdc_networkr,
                    element=xml_distinfo,
                    xpath=
                    "stdorder/digform/digtopt/onlinopt/computer/networka/networkr",
                )
                utils.populate_widget_element(
                    widget=self.ui.fgdc_fees,
                    element=xml_distinfo,
                    xpath="stdorder/fees",
                )
Beispiel #2
0
    def _from_xml(self, xml_distinfo):

        self.clear_widget()

        if xml_distinfo.tag == 'distinfo':
            self.ui.radio_distyes.setChecked(True)
            if xml_distinfo.xpath('distrib/cntinfo'):
                self.contactinfo._from_xml(
                    xml_distinfo.xpath('distrib/cntinfo')[0])
            if xml_distinfo.xpath('distliab'):
                self.ui.radio_dist.setChecked(True)
                utils.populate_widget_element(widget=self.ui.fgdc_distliab,
                                              element=xml_distinfo,
                                              xpath='distliab')
            if xml_distinfo.xpath('custom'):
                self.ui.radio_otherdist.setChecked(True)
                utils.populate_widget_element(widget=self.ui.fgdc_custom,
                                              element=xml_distinfo,
                                              xpath='custom')
            if xml_distinfo.xpath('stdorder'):
                self.ui.radio_online.setChecked(True)
                utils.populate_widget_element(
                    widget=self.ui.fgdc_networkr,
                    element=xml_distinfo,
                    xpath=
                    'stdorder/digform/digtopt/onlinopt/computer/networka/networkr'
                )
                utils.populate_widget_element(widget=self.ui.fgdc_fees,
                                              element=xml_distinfo,
                                              xpath='stdorder/fees')
    def _from_xml(self, srcinfo):
        """
        parses the xml code into the relevant srcinfo elements

        Parameters
        ----------
        srcinfo - the xml element status and its contents

        Returns
        -------
        None
        """
        try:
            if srcinfo.tag == "srcinfo":
                utils.populate_widget(self, srcinfo)
                srccite = srcinfo.xpath('srccite')[0]
                citeinfo = srccite.xpath('citeinfo')[0]
            elif srcinfo.tag != 'srcinfo':
                print("The tag is not 'srcinfo'")
                return

            self.citation._from_xml(citeinfo)

            utils.populate_widget_element(self.ui.fgdc_srcscale, srcinfo,
                                          'srcscale')

            typesrc = srcinfo.xpath('typesrc/text()')
            typesrc_text = str(typesrc[0])
            self.findChild(QComboBox,
                           "fgdc_typesrc").setCurrentText(typesrc_text)

            utils.populate_widget_element(self.ui.fgdc_srccitea, srcinfo,
                                          'srccitea')

            utils.populate_widget_element(self.ui.fgdc_srccontr, srcinfo,
                                          'srccontr')

            if srcinfo.xpath('srctime'):
                timeperd = etree.Element('timeperd')
                timeinfo = srcinfo.xpath('srctime/timeinfo')[0]
                srccurr = srcinfo.xpath('srctime/srccurr')[0]
                srccurr.tag = 'current'
                timeperd.append(timeinfo)
                timeperd.append(srccurr)
                self.timeperd._from_xml(timeperd)

        except KeyError:
            pass
Beispiel #4
0
    def from_xml(self, srcinfo):
        """
        parses the xml code into the relevant srcinfo elements

        Parameters
        ----------
        srcinfo - the xml element status and its contents

        Returns
        -------
        None
        """
        try:
            if srcinfo.tag == "srcinfo":
                utils.populate_widget(self, srcinfo)
                srccite = srcinfo.xpath("srccite")[0]
                citeinfo = srccite.xpath("citeinfo")[0]
            elif srcinfo.tag != "srcinfo":
                print("The tag is not 'srcinfo'")
                return

            self.citation.from_xml(citeinfo)

            utils.populate_widget_element(self.ui.fgdc_srcscale, srcinfo, "srcscale")
            self.format_scale()

            typesrc = srcinfo.xpath("typesrc/text()")
            typesrc_text = str(typesrc[0])
            self.findChild(QComboBox, "fgdc_typesrc").setCurrentText(typesrc_text)

            utils.populate_widget_element(self.ui.fgdc_srccitea, srcinfo, "srccitea")
            utils.populate_widget_element(self.ui.fgdc_srccontr, srcinfo, "srccontr")

            if srcinfo.xpath("srctime"):
                timeinfo = srcinfo.xpath("srctime/timeinfo")[0]
                srccurr = srcinfo.xpath("srctime/srccurr")[0]
                self.timeinfo.from_xml(timeinfo)
                self.ui.fgdc_srccurr.setCurrentText(srccurr.text)

            self.update_tab_label()

        except KeyError:
            pass
Beispiel #5
0
    def from_xml(self, spref_node):
        self.clear_widget()
        if spref_node.tag == 'spref':
            self.original_xml = spref_node

            self.ui.rbtn_yes.setChecked(True)

            geograph = xml_utils.search_xpath(spref_node, 'horizsys/geograph')
            if geograph is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_geographic.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_latres, 
                                              geograph, 'latres')
                utils.populate_widget_element(self.ui.fgdc_longres, 
                                              geograph, 'longres')
                utils.populate_widget_element(self.ui.fgdc_geogunit, 
                                              geograph, 'geogunit')

            local = xml_utils.search_xpath(spref_node, 'horizsys/local')
            if local is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_local.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_localdes, local, 
                                              'localdes')
                utils.populate_widget_element(self.ui.fgdc_localgeo, local, 
                                              'localgeo')

            planar = xml_utils.search_xpath(spref_node, 'horizsys/planar')
            if planar is not None:
                self.ui.btn_grid.setChecked(True)
                self.ui.btn_planar.setChecked(True)

                mapproj = xml_utils.search_xpath(planar, 'mapproj')
                if mapproj is not None:
                    self.ui.btn_projection.setChecked(True)

                    utils.populate_widget_element(self.ui.fgdc_mapprojn, 
                                                  mapproj, 'mapprojn')
                    mapproj_children = mapproj.getchildren()
                    if len(mapproj_children) > 1:
                        self.mapproj.from_xml(mapproj_children[1])

                gridsys = xml_utils.search_xpath(planar, 'gridsys')
                if gridsys is not None:
                    self.ui.btn_grid.setChecked(True)
                    xml_utils.search_xpath(gridsys, 'gridsysn')
                    utils.populate_widget_element(self.ui.fgdc_gridsysn,
                                                  gridsys, 'gridsysn')

                    gridsys_children = gridsys.getchildren()
                    if len(gridsys_children) > 1:
                        gridsys_contents = gridsys.getchildren()[1]
                    else:
                        gridsys_contents = []
                    for item in gridsys_contents.getchildren():
                        tag = item.tag
                        if spatial_utils.lookup_shortname(tag) is not None:
                            self.grid_mapproj.from_xml(item)
                        elif tag == 'mapproj':
                            mapprojn = xml_utils.search_xpath(item,
                                                              'mapprojn')
                            if mapprojn.text in \
                                    spatial_utils.PROJECTION_LOOKUP:
                                self.grid_mapproj.from_xml(item.getchildren()[1])
                        else:
                            item_widget = self.findChild(QLineEdit,
                                                         "fgdc_"+tag)
                            utils.set_text(item_widget, item.text)

                    grid_proj = gridsys.xpath('proj')

                localp = xml_utils.search_xpath(planar, 'localp')
                if localp:
                    self.ui.btn_localp.setChecked(True)
                    utils.populate_widget_element(self.ui.fgdc_localpd, 
                                                  localp, 'localpd')
                    utils.populate_widget_element(self.ui.fgdc_localpgi, 
                                                  localp, 'localpgi')

                utils.populate_widget_element(self.ui.fgdc_plance, planar, 
                                              'planci/plance')
                utils.populate_widget_element(self.ui.fgdc_plandu, planar, 
                                              'planci/plandu')
                utils.populate_widget_element(self.ui.fgdc_absres, planar, 
                                              'planci/coordrep/absres')
                utils.populate_widget_element(self.ui.fgdc_ordres, planar, 
                                              'planci/coordrep/ordres')

                self.planar_changed()

            geodetic = xml_utils.search_xpath(spref_node, 'horizsys/geodetic')
            if geodetic is not None:
                utils.populate_widget_element(self.ui.fgdc_horizdn, geodetic, 
                                              'horizdn')
                utils.populate_widget_element(self.ui.fgdc_ellips, geodetic, 
                                              'ellips')
                utils.populate_widget_element(self.ui.fgdc_semiaxis, geodetic,
                                              'semiaxis')
                utils.populate_widget_element(self.ui.fgdc_denflat, geodetic, 
                                              'denflat')

            vertdef = xml_utils.search_xpath(spref_node, 'vertdef')
            if vertdef is not None:
                self.vertdef.from_xml(vertdef)
Beispiel #6
0
    def _from_xml(self, citeinfo):
        """
        parses the xml code into the relevant citation elements

        Parameters
        ----------
        citation - the xml element status and its contents

        Returns
        -------
        None
        """
        try:
            if citeinfo.tag == "citation":
                citeinfo = citeinfo.xpath('citeinfo')[0]
            elif citeinfo.tag != 'citeinfo':
                print("The tag is not 'citation' or 'citeinfo'")
                return

            self.fgdc_origin.clear_widgets()
            originators = citeinfo.findall("origin")
            if originators :
                self.fgdc_origin.clear_widgets(add_another=False)
                for origin in citeinfo.findall('origin'):
                    origin_widget = self.fgdc_origin.add_another()
                    origin_widget.added_line.setText(origin.text)
            else:
                self.fgdc_origin.add_another()

            if citeinfo.findall('geoform'):
                self.ui.fgdc_geoform.setEditText(citeinfo.findall('geoform')[0].text)

            utils.populate_widget_element(self.ui.pubdate_widget.ui.fgdc_caldate,
                                          citeinfo, 'pubdate')
            utils.populate_widget_element(self.ui.fgdc_title, citeinfo, 'title')

            self.onlink_list.clear_widgets()
            if citeinfo.findall("onlink"):
                for onlink in citeinfo.findall('onlink'):
                    onlink_widget = self.onlink_list.widgets[0]
                    onlink_widget.added_line.setText(onlink.text)

            if citeinfo.xpath('serinfo'):
                self.ui.radio_seriesyes.setChecked(True)
                utils.populate_widget(self, citeinfo.xpath('serinfo')[0])
            else:
                self.ui.radio_seriesyes.setChecked(False)

            pubinfo = citeinfo.xpath('pubinfo')
            if pubinfo:
                self.ui.radio_pubinfoyes.setChecked(True)
                utils.populate_widget_element(self.ui.fgdc_publish, pubinfo[0], 'publish')
                utils.populate_widget_element(self.ui.fgdc_pubplace, pubinfo[0], 'pubplace')
            else:
                self.ui.radio_pubinfoyes.setChecked(False)
                self.ui.radioButton_8.setChecked(True)

            if citeinfo.xpath('lworkcit'):
                try:
                    self.ui.radio_lworkyes.setChecked(True)
                    self.lworkcit_widget._from_xml(citeinfo.xpath('lworkcit/citeinfo')[0])
                except AttributeError:
                    msg = 'you pasted a citation element into the larger work citation area'
                    msg += '\n that contained a larger work citation'
                    msg += '\n Multiple nested larger work citations are not currently supported in the tool'
                    msg += '\n\n the larger work citation being pasted will be ignored'
                    QMessageBox.warning(self, "Dropped Content Warning", msg)

            else:
                self.ui.radio_lworkno.setChecked(True)

        except KeyError:
            pass
    def _from_xml(self, citeinfo):
        """
        parses the xml code into the relevant citation elements

        Parameters
        ----------
        citation - the xml element status and its contents

        Returns
        -------
        None
        """
        try:
            if citeinfo.tag == "citation":
                citeinfo = citeinfo.xpath('citeinfo')[0]
            elif citeinfo.tag != 'citeinfo':
                print("The tag is not 'citation' or 'citeinfo'")
                return

            self.fgdc_origin.clear_widgets()
            if citeinfo.findall("origin"):
                for origin in citeinfo.findall('origin'):
                    origin_widget = self.fgdc_origin.widgets[0]
                    origin_widget.added_line.setText(origin.text)
            else:
                self.fgdc_origin.add_another()

            if citeinfo.findall('geoform'):
                self.ui.fgdc_geoform.setEditText(
                    citeinfo.findall('geoform')[0].text)

            utils.populate_widget_element(
                self.ui.pubdate_widget.ui.fgdc_caldate, citeinfo, 'pubdate')
            utils.populate_widget_element(self.ui.fgdc_title, citeinfo,
                                          'title')

            self.onlink_list.clear_widgets()
            if citeinfo.findall("onlink"):
                for onlink in citeinfo.findall('onlink'):
                    onlink_widget = self.onlink_list.widgets[0]
                    onlink_widget.added_line.setText(onlink.text)

            if citeinfo.xpath('serinfo'):
                self.ui.radio_seriesyes.setChecked(True)
                utils.populate_widget(self.ui.fgdc_serinfo,
                                      citeinfo.xpath('serinfo')[0])
            else:
                self.ui.radio_seriesyes.setChecked(False)

            pubinfo = citeinfo.xpath('pubinfo')
            if pubinfo:
                self.ui.radio_pubinfoyes.setChecked(True)
                utils.populate_widget_element(self.ui.fgdc_publish, pubinfo[0],
                                              'publish')
                utils.populate_widget_element(self.ui.fgdc_pubplace,
                                              pubinfo[0], 'pubplace')
            else:
                self.ui.radio_pubinfoyes.setChecked(False)

            if citeinfo.xpath('lworkcit'):
                self.ui.radio_lworkyes.setChecked(True)
                self.lworkcit_widget._from_xml(
                    citeinfo.xpath('lworkcit/citeinfo')[0])

        except KeyError:
            pass
Beispiel #8
0
    def from_xml(self, citeinfo):
        """
        parses the xml code into the relevant citation elements

        Parameters
        ----------
        citation - the xml element status and its contents

        Returns
        -------
        None
        """
        self.original_xml = citeinfo
        self.clear_widget()
        try:
            if citeinfo.tag == "citation":
                citeinfo = citeinfo.xpath("citeinfo")[0]
            elif citeinfo.tag != "citeinfo":
                print("The tag is not 'citation' or 'citeinfo'")
                return

            self.fgdc_origin.clear_widgets(add_another=False)
            originators = citeinfo.findall("origin")

            if originators:
                self.fgdc_origin.clear_widgets(add_another=False)
                for origin in citeinfo.findall("origin"):
                    origin_widget = self.fgdc_origin.add_another()
                    origin_widget.setText(origin.text)
            else:
                self.fgdc_origin.add_another()

            if citeinfo.findall("geoform"):
                self.ui.fgdc_geoform.setEditText(
                    citeinfo.findall("geoform")[0].text)

            utils.populate_widget_element(
                self.ui.pubdate_widget.ui.fgdc_caldate, citeinfo, "pubdate")
            utils.populate_widget_element(self.ui.fgdc_title, citeinfo,
                                          "title")
            utils.populate_widget_element(self.ui.fgdc_edition, citeinfo,
                                          "edition")
            utils.populate_widget_element(self.ui.fgdc_othercit, citeinfo,
                                          "othercit")

            self.onlink_list.clear_widgets()
            if citeinfo.findall("onlink"):
                self.onlink_list.clear_widgets(add_another=False)
                for onlink in citeinfo.findall("onlink"):
                    self.onlink_list.add_another()
                    onlink_widget = self.onlink_list.widgets[-1]
                    onlink_widget.setText(onlink.text)

            if citeinfo.xpath("serinfo"):
                self.ui.radio_seriesyes.setChecked(True)
                utils.populate_widget(self, citeinfo.xpath("serinfo")[0])
            else:
                self.ui.radio_seriesyes.setChecked(False)

            pubinfo = citeinfo.xpath("pubinfo")
            if pubinfo:
                self.ui.radio_pubinfoyes.setChecked(True)
                utils.populate_widget_element(self.ui.fgdc_publish, pubinfo[0],
                                              "publish")
                utils.populate_widget_element(self.ui.fgdc_pubplace,
                                              pubinfo[0], "pubplace")
            else:
                self.ui.radio_pubinfoyes.setChecked(False)
                self.ui.radio_pubinfono.setChecked(True)

            if citeinfo.xpath("lworkcit"):
                try:
                    self.ui.radio_lworkyes.setChecked(True)
                    self.lworkcit_widget.from_xml(
                        citeinfo.xpath("lworkcit/citeinfo")[0])
                except AttributeError:
                    msg = "you pasted a citation element into the larger work citation area"
                    msg += "\n that contained a larger work citation"
                    msg += "\n Multiple nested larger work citations are not currently supported in the tool"
                    msg += "\n\n the larger work citation being pasted will be ignored"
                    QMessageBox.warning(self, "Dropped Content Warning", msg)

            else:
                self.ui.radio_lworkno.setChecked(True)

        except KeyError:
            pass
Beispiel #9
0
    def from_xml(self, spref_node):
        self.clear_widget()
        if spref_node.tag == "spref":
            self.original_xml = spref_node

            self.ui.rbtn_yes.setChecked(True)

            geograph = xml_utils.search_xpath(spref_node, "horizsys/geograph")
            if geograph is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_geographic.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_latres, geograph,
                                              "latres")
                utils.populate_widget_element(self.ui.fgdc_longres, geograph,
                                              "longres")
                utils.populate_widget_element(self.ui.fgdc_geogunit, geograph,
                                              "geogunit")

            local = xml_utils.search_xpath(spref_node, "horizsys/local")
            if local is not None:
                self.ui.btn_planar.setChecked(True)
                self.ui.btn_local.setChecked(True)

                utils.populate_widget_element(self.ui.fgdc_localdes, local,
                                              "localdes")
                utils.populate_widget_element(self.ui.fgdc_localgeo, local,
                                              "localgeo")

            planar = xml_utils.search_xpath(spref_node, "horizsys/planar")
            if planar is not None:
                self.ui.btn_grid.setChecked(True)
                self.ui.btn_planar.setChecked(True)

                mapproj = xml_utils.search_xpath(planar, "mapproj")
                if mapproj is not None:
                    self.ui.btn_projection.setChecked(True)

                    utils.populate_widget_element(self.ui.fgdc_mapprojn,
                                                  mapproj, "mapprojn")
                    mapproj_children = mapproj.getchildren()
                    if len(mapproj_children) > 1:
                        self.mapproj.from_xml(mapproj_children[1])

                gridsys = xml_utils.search_xpath(planar, "gridsys")
                if gridsys is not None:
                    self.ui.btn_grid.setChecked(True)
                    xml_utils.search_xpath(gridsys, "gridsysn")
                    utils.populate_widget_element(self.ui.fgdc_gridsysn,
                                                  gridsys, "gridsysn")

                    gridsys_children = gridsys.getchildren()
                    if len(gridsys_children) > 1:
                        gridsys_contents = gridsys.getchildren()[1]
                    else:
                        gridsys_contents = []
                    for item in gridsys_contents.getchildren():
                        tag = item.tag
                        if spatial_utils.lookup_shortname(tag) is not None:
                            self.grid_mapproj.from_xml(item)
                        elif tag == "mapproj":
                            mapprojn = xml_utils.search_xpath(item, "mapprojn")
                            if mapprojn.text in spatial_utils.PROJECTION_LOOKUP:
                                self.grid_mapproj.from_xml(
                                    item.getchildren()[1])
                        else:
                            item_widget = self.findChild(
                                QLineEdit, "fgdc_" + tag)
                            utils.set_text(item_widget, item.text)

                    grid_proj = gridsys.xpath("proj")

                localp = xml_utils.search_xpath(planar, "localp")
                if localp:
                    self.ui.btn_localp.setChecked(True)
                    utils.populate_widget_element(self.ui.fgdc_localpd, localp,
                                                  "localpd")
                    utils.populate_widget_element(self.ui.fgdc_localpgi,
                                                  localp, "localpgi")

                utils.populate_widget_element(self.ui.fgdc_plance, planar,
                                              "planci/plance")
                utils.populate_widget_element(self.ui.fgdc_plandu, planar,
                                              "planci/plandu")
                utils.populate_widget_element(self.ui.fgdc_absres, planar,
                                              "planci/coordrep/absres")
                utils.populate_widget_element(self.ui.fgdc_ordres, planar,
                                              "planci/coordrep/ordres")

                self.planar_changed()

            geodetic = xml_utils.search_xpath(spref_node, "horizsys/geodetic")
            if geodetic is not None:
                utils.populate_widget_element(self.ui.fgdc_horizdn, geodetic,
                                              "horizdn")
                utils.populate_widget_element(self.ui.fgdc_ellips, geodetic,
                                              "ellips")
                utils.populate_widget_element(self.ui.fgdc_semiaxis, geodetic,
                                              "semiaxis")
                utils.populate_widget_element(self.ui.fgdc_denflat, geodetic,
                                              "denflat")

            vertdef = xml_utils.search_xpath(spref_node, "vertdef")
            if vertdef is not None:
                self.vertdef.from_xml(vertdef)