def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.contactinfo = ContactInfo(parent=self) self.metd = FGDCDate(parent=self, fgdc_name='fgdc_metd') self.ui.help_metd.layout().addWidget(self.metd) self.ui.fgdc_metc.layout().addWidget(self.contactinfo)
def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_ProcessStep.Ui_Form() self.ui.setupUi(self) self.ui.fgdc_procdesc.heightMin = 150 self.setup_dragdrop(self) self.single_date = FGDCDate(show_format=False, required=True, label="", fgdc_name="fgdc_procdate") self.proccont = ProcessContact() self.ui.fgdc_procdate.setLayout(QVBoxLayout()) self.ui.fgdc_procdate.layout().insertWidget(0, self.single_date) self.ui.widget_proccont.layout().insertWidget(0, self.proccont) self.srcused_list = RepeatingElement( add_text="Add another", remove_text="Remove last", widget_kwargs={ "label": "Source used", "line_name": "fgdc_srcused" }, ) self.srcused_list.add_another() self.ui.srcused_groupbox.layout().addWidget(self.srcused_list) self.srcprod_list = RepeatingElement( add_text="Add another", remove_text="Remove last", widget_kwargs={ "label": "Source produced:", "line_name": "fgdc_srcprod" }, ) self.srcprod_list.add_another() self.ui.srcprod_groupbox.layout().addWidget(self.srcprod_list) self.clear_widget()
def build_ui(self, ): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_citeinfo.Ui_parent_form() self.ui.setupUi(self) if self.include_lwork: self.lworkcit_widget = Citeinfo(parent=self, include_lwork=False) self.lworkcit_widget.ui.lbl_dataset_title.setText( 'Larger Work Title') self.ui.lworkcite_widget.layout().addWidget(self.lworkcit_widget) self.lworkcit_widget.ui.fgdc_geoform.setEditText('publication') else: self.ui.fgdc_lworkcit.hide() self.include_lworkext_change(self.ui.radio_lworkyes.isChecked()) self.ui.series_ext.hide() self.ui.pub_ext.hide() self.ui.pubdate_widget = FGDCDate(label='YYYYMMDD ', show_format=False, required=True, fgdc_name='fgdc_pubdate') self.ui.pubdate_layout.addWidget(self.ui.pubdate_widget) self.onlink_list = RepeatingElement(add_text='Add online link', remove_text='Remove last', widget_kwargs={ 'label': 'Link', 'line_name': 'fgdc_onlink' }) self.onlink_list.add_another() self.ui.onlink_layout.addWidget(self.onlink_list) self.fgdc_origin = RepeatingElement( add_text='Add originator', remove_text='Remove last', widget_kwargs={ 'label': 'Originator', 'line_name': 'fgdc_origin', 'required': True, 'placeholder_text': self.origin_hint, 'spellings': False }, ) self.ui.originator_layout.addWidget(self.fgdc_origin) self.fgdc_origin.add_another() self.setup_dragdrop(self) if not hananero_installed: self.ui.btn_import_doi.hide()
def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_ProcessStep.Ui_Form()#.Ui_USGSContactInfoWidgetMain() self.ui.setupUi(self) self.setup_dragdrop(self) self.single_date = FGDCDate(show_format=False, required=True, label='', fgdc_name='fgdc_procdate') self.proccont = ProcessContact() self.ui.fgdc_procdate.setLayout(QVBoxLayout(self)) self.ui.fgdc_procdate.layout().insertWidget(0, self.single_date) self.ui.widget_proccont.layout().insertWidget(0, self.proccont) self.clear_widget()
def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_timeperd.Ui_Form() self.ui.setupUi(self) self.setup_dragdrop(self) self.single_date = FGDCDate(label=' Single Date ', fgdc_name='fgdc_caldate') self.ui.fgdc_sngdate.layout().insertWidget(0, self.single_date) self.range_start_date = FGDCDate(label='Start ', fgdc_name='fgdc_begdate') self.range_end_date = FGDCDate(label='End ', fgdc_name='fgdc_enddate') self.ui.layout_daterange.addWidget(self.range_start_date) self.ui.layout_daterange.addWidget(self.range_end_date) date_widget_kwargs = { 'show_format': False, 'label': 'Individual Date ', 'fgdc_name': 'fgdc_caldate', 'parent_fgdc_name': 'fgdc_sngdate' } self.multi_dates = RepeatingElement(widget=FGDCDate, widget_kwargs=date_widget_kwargs) self.multi_dates.add_another() self.switch_primary()
def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_timeinfo.Ui_Form() self.ui.setupUi(self) self.setup_dragdrop(self) self.single_date = FGDCDate(label=" Single Date ", fgdc_name="fgdc_caldate") self.ui.fgdc_sngdate.layout().insertWidget(0, self.single_date) self.range_start_date = FGDCDate(label="Start ", fgdc_name="fgdc_begdate") self.range_end_date = FGDCDate(label="End ", fgdc_name="fgdc_enddate") self.ui.layout_daterange.addWidget(self.range_start_date) self.ui.layout_daterange.addWidget(self.range_end_date) date_widget_kwargs = { "show_format": False, "label": "Individual Date ", "fgdc_name": "fgdc_caldate", "parent_fgdc_name": "fgdc_sngdate", } self.multi_dates = RepeatingElement(widget=FGDCDate, widget_kwargs=date_widget_kwargs) self.multi_dates.add_another() self.switch_primary()
class ProcessStep(WizardWidget): # drag_label = "Process Step <procstep>" acceptable_tags = ['procstep'] def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_ProcessStep.Ui_Form() self.ui.setupUi(self) self.ui.fgdc_procdesc.heightMin = 150 self.setup_dragdrop(self) self.single_date = FGDCDate(show_format=False, required=True, label='', fgdc_name='fgdc_procdate') self.proccont = ProcessContact() self.ui.fgdc_procdate.setLayout(QVBoxLayout()) self.ui.fgdc_procdate.layout().insertWidget(0, self.single_date) self.ui.widget_proccont.layout().insertWidget(0, self.proccont) self.srcused_list = RepeatingElement(add_text='Add another', remove_text='Remove last', widget_kwargs={ 'label': 'Source used', 'line_name': 'fgdc_srcused' }) self.srcused_list.add_another() self.ui.srcused_groupbox.layout().addWidget(self.srcused_list) self.srcprod_list = RepeatingElement(add_text='Add another', remove_text='Remove last', widget_kwargs={ 'label': 'Source produced:', 'line_name': 'fgdc_srcprod' }) self.srcprod_list.add_another() self.ui.srcprod_groupbox.layout().addWidget(self.srcprod_list) self.clear_widget() def clear_widget(self): super(self.__class__, self).clear_widget() self.proccont.ui.rbtn_no.setChecked(True) def to_xml(self): """ encapsulates the QPlainTextEdit text in an element tag Returns ------- procstep element tag in xml tree """ procstep = xml_utils.xml_node(tag='procstep') procdesc = xml_utils.xml_node(tag='procdesc') procdesc.text = self.findChild(QPlainTextEdit, "fgdc_procdesc").toPlainText() procstep.append(procdesc) for srcused in self.srcused_list.get_widgets(): if srcused.text(): xml_utils.xml_node('srcused', text=srcused.text(), parent_node=procstep) procdate = xml_utils.xml_node(tag='procdate') date_var = self.single_date.findChild(QLineEdit, "fgdc_procdate").text() procdate.text = date_var procstep.append(procdate) for srcprod in self.srcprod_list.get_widgets(): if srcprod.text(): xml_utils.xml_node('srcprod', text=srcprod.text(), parent_node=procstep) if self.proccont.ui.rbtn_yes.isChecked(): proccont = self.proccont.to_xml() procstep.append(proccont) return procstep def from_xml(self, xml_processstep): """ parses the xml code into the relevant procstep elements Parameters ---------- process_step - the xml element status and its contents Returns ------- None """ try: if xml_processstep.tag == 'procstep': utils.populate_widget(self, xml_processstep) if xml_processstep.xpath('procdate'): self.single_date.set_date( xml_processstep.xpath('procdate')[0].text) if xml_processstep.xpath('proccont'): self.proccont.ui.rbtn_yes.setChecked(True) cntinfo_node = xml_processstep.xpath('proccont/cntinfo')[0] self.proccont.from_xml(cntinfo_node) else: self.proccont.ui.rbtn_no.setChecked(True) pass srcuseds = xml_processstep.findall("srcused") if srcuseds: self.srcused_list.clear_widgets(add_another=False) for srcused in srcuseds: srcused_widget = self.srcused_list.add_another() srcused_widget.setText(srcused.text) else: self.srcused_list.clear_widgets(add_another=True) srcprods = xml_processstep.findall("srcprod") if srcprods: self.srcprod_list.clear_widgets(add_another=False) for srcprod in srcprods: srcprod_widget = self.srcprod_list.add_another() srcprod_widget.setText(srcprod.text) else: self.srcprod_list.clear_widgets(add_another=True) else: print("The tag is not procstep") except KeyError: pass
class ProcessStep(WizardWidget): # drag_label = "Process Step <procstep>" acceptable_tags = ['procstep'] def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_ProcessStep.Ui_Form()#.Ui_USGSContactInfoWidgetMain() self.ui.setupUi(self) self.setup_dragdrop(self) self.single_date = FGDCDate(show_format=False, required=True, label='', fgdc_name='fgdc_procdate') self.proccont = ProcessContact() self.ui.fgdc_procdate.setLayout(QVBoxLayout(self)) self.ui.fgdc_procdate.layout().insertWidget(0, self.single_date) self.ui.widget_proccont.layout().insertWidget(0, self.proccont) self.clear_widget() def clear_widget(self): super(self.__class__, self).clear_widget() self.proccont.ui.rbtn_no.setChecked(True) def _to_xml(self): """ encapsulates the QPlainTextEdit text in an element tag Returns ------- procstep element tag in xml tree """ procstep = etree.Element('procstep') procdesc = etree.Element('procdesc') procdesc.text = self.findChild(QPlainTextEdit, "fgdc_procdesc").toPlainText() procstep.append(procdesc) srcused = etree.Element('srcused') srcused.text = self.findChild(QLineEdit, "fgdc_srcused").text() if len(srcused.text): procstep.append(srcused) procdate = etree.Element('procdate') date_var = self.single_date.findChild(QLineEdit, "fgdc_procdate").text() procdate.text = date_var procstep.append(procdate) srcprod = etree.Element('srcprod') srcprod.text = self.findChild(QLineEdit, "fgdc_srcprod").text() if len(srcprod.text): procstep.append(srcprod) if self.proccont.ui.rbtn_yes.isChecked(): proccont = self.proccont._to_xml() procstep.append(proccont) return procstep def _from_xml(self, xml_processstep): """ parses the xml code into the relevant procstep elements Parameters ---------- process_step - the xml element status and its contents Returns ------- None """ try: if xml_processstep.tag == 'procstep': utils.populate_widget(self, xml_processstep) if xml_processstep.xpath('procdate'): self.single_date.set_date(xml_processstep.xpath('procdate')[0].text) else: pass if xml_processstep.xpath('proccont'): self.proccont.ui.rbtn_yes.setChecked(True) cntinfo_node = xml_processstep.xpath('proccont/cntinfo')[0] self.proccont._from_xml(cntinfo_node) else: self.proccont.ui.rbtn_no.setChecked(True) pass else: print ("The tag is not procstep") except KeyError: pass
class Timeperd(WizardWidget): # drag_label = "Time Period of Content <timeperd>" acceptable_tags = ['timeperd'] def build_ui(self): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_timeperd.Ui_Form() self.ui.setupUi(self) self.setup_dragdrop(self) self.single_date = FGDCDate(label=' Single Date ', fgdc_name='fgdc_caldate') self.ui.fgdc_sngdate.layout().insertWidget(0, self.single_date) self.range_start_date = FGDCDate(label='Start ', fgdc_name='fgdc_begdate') self.range_end_date = FGDCDate(label='End ', fgdc_name='fgdc_enddate') self.ui.layout_daterange.addWidget(self.range_start_date) self.ui.layout_daterange.addWidget(self.range_end_date) date_widget_kwargs = { 'show_format': False, 'label': 'Individual Date ', 'fgdc_name': 'fgdc_caldate', 'parent_fgdc_name': 'fgdc_sngdate' } self.multi_dates = RepeatingElement(widget=FGDCDate, widget_kwargs=date_widget_kwargs) self.multi_dates.add_another() self.switch_primary() def connect_events(self): """ Connect the appropriate GUI components with the corresponding functions Returns ------- None """ self.ui.radio_single.toggled.connect(self.switch_primary) self.ui.radio_range.toggled.connect(self.switch_primary) self.ui.radio_multiple.toggled.connect(self.switch_primary) def switch_primary(self): """ Switches form to reflect either organization or person primary Returns ------- None """ if self.ui.radio_single.isChecked(): self.findChild(QStackedWidget, "fgdc_timeinfo").setCurrentIndex(0) self.ui.fgdc_sngdate.show() self.ui.fgdc_rngdates.hide() self.ui.fgdc_mdattim.hide() self.ui.fgdc_mdattim.layout().removeWidget(self.multi_dates) elif self.ui.radio_range.isChecked(): self.findChild(QStackedWidget, "fgdc_timeinfo").setCurrentIndex(1) self.ui.fgdc_rngdates.hide() self.ui.fgdc_rngdates.show() self.ui.fgdc_mdattim.hide() self.ui.fgdc_mdattim.layout().removeWidget(self.multi_dates) elif self.ui.radio_multiple.isChecked(): self.findChild(QStackedWidget, "fgdc_timeinfo").setCurrentIndex(2) self.ui.fgdc_sngdate.hide() self.ui.fgdc_rngdates.hide() self.ui.fgdc_mdattim.layout().addWidget(self.multi_dates) self.ui.fgdc_mdattim.show() def _to_xml(self): """ encapsulates the QTabWidget text for Metadata Time in an element tag Returns ------- timeperd element tag in xml tree """ timeperd = xml_utils.xml_node('timeperd') timeinfo = xml_utils.xml_node("timeinfo", parent_node=timeperd) tabIndex = self.ui.fgdc_timeinfo.currentIndex() if tabIndex == 0: sngdate = xml_utils.xml_node("sngdate", parent_node=timeinfo) caldate = xml_utils.xml_node('caldate', parent_node=sngdate, text=self.single_date.get_date()) if tabIndex == 1: rngdates = xml_utils.xml_node("rngdates", parent_node=timeinfo) begdate = xml_utils.xml_node("begdate", parent_node=rngdates, text=self.range_start_date.get_date()) enddate = xml_utils.xml_node("enddate", parent_node=rngdates, text=self.range_end_date.get_date()) if tabIndex == 2: mdattim = xml_utils.xml_node("mdattim", parent_node=timeinfo) for single_date in self.multi_dates.get_widgets(): single_date_node = xml_utils.xml_node("sngdate", parent_node=mdattim) caldate = xml_utils.xml_node('caldate', parent_node=single_date_node, text=single_date.get_date()) current = xml_utils.xml_node('current', parent_node=timeperd, text=self.ui.fgdc_current.currentText()) return timeperd def _from_xml(self, timeperd): """ parses the xml code into the relevant timeperd elements Parameters ---------- metadata_date - the xml element timeperd and its contents Returns ------- None """ try: if timeperd.tag == 'timeperd': if timeperd.findall("current"): current_text = timeperd.findtext("current") current_box = self.findChild(QComboBox, 'fgdc_current') current_box.setCurrentText(current_text) else: pass timeinfo_stack = self.ui.fgdc_timeinfo if timeperd.xpath("timeinfo/rngdates"): self.ui.radio_range.setChecked(True) timeinfo_stack.setCurrentIndex(1) begdate = timeperd.findtext("timeinfo/rngdates/begdate") self.range_start_date.set_date(begdate) enddate = timeperd.findtext("timeinfo/rngdates/enddate") self.range_end_date.set_date(enddate) elif timeperd.xpath("timeinfo/mdattim"): self.ui.radio_multiple.setChecked(True) timeinfo_stack.setCurrentIndex(2) self.multi_dates.clear_widgets(add_another=False) for caldate in timeperd.xpath( 'timeinfo/mdattim/sngdate/caldate'): date_widget = self.multi_dates.add_another() date_widget.set_date(caldate.text) elif timeperd.xpath("timeinfo/sngdate"): self.ui.radio_single.setChecked(True) timeinfo_stack.setCurrentIndex(0) sngdate = timeperd.findtext("timeinfo/sngdate/caldate") self.single_date.set_date(sngdate) else: pass else: print("The tag is not timeperd") except KeyError: pass
def build_ui(self, ): """ Build and modify this widget's GUI Returns ------- None """ self.ui = UI_citeinfo.Ui_parent_form() self.ui.setupUi(self) if self.include_lwork: self.lworkcit_widget = Citeinfo(parent=self, include_lwork=False) self.lworkcit_widget.ui.lbl_dataset_title.setText( "Larger Work Title") self.ui.lworkcite_widget.layout().addWidget(self.lworkcit_widget) self.lworkcit_widget.ui.fgdc_geoform.setEditText("publication") else: self.ui.fgdc_lworkcit.hide() self.include_lworkext_change(self.ui.radio_lworkyes.isChecked()) self.ui.series_ext.hide() self.ui.pub_ext.hide() self.ui.pubdate_widget = FGDCDate( label="YYYYMMDD ", show_format=False, required=True, fgdc_name="fgdc_pubdate", ) self.ui.pubdate_layout.addWidget(self.ui.pubdate_widget) self.onlink_list = RepeatingElement( add_text="Add online link", remove_text="Remove last", italic_text= "Is there a link to the data or the agency that produced it? if so, provide the URL(s) ", widget_kwargs={ "label": "Link", "line_name": "fgdc_onlink" }, ) self.onlink_list.add_another() self.ui.onlink_layout.addWidget(self.onlink_list) self.fgdc_origin = RepeatingElement( add_text="Add originator", remove_text="Remove last", italic_text= "Who created the dataset? List the organization and/or person(s)", widget_kwargs={ "label": "Originator", "line_name": "fgdc_origin", "required": True, "placeholder_text": self.origin_hint, "spellings": False, }, ) self.ui.originator_layout.addWidget(self.fgdc_origin) self.fgdc_origin.add_another() self.setup_dragdrop(self) if not hananero_installed: self.ui.btn_import_doi.hide()
class MetaInfo(WizardWidget): drag_label = "Metadata Information <metainfo>" acceptable_tags = ['metainfo', 'cntinfo', 'ptcontact'] ui_class = UI_metainfo.Ui_fgdc_metainfo def __init__(self, root_widget=None): super(self.__class__, self).__init__() self.root_widget = root_widget def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.contactinfo = ContactInfo(parent=self) self.metd = FGDCDate(parent=self, fgdc_name='fgdc_metd') self.ui.help_metd.layout().addWidget(self.metd) self.ui.fgdc_metc.layout().addWidget(self.contactinfo) def connect_events(self): self.ui.fgdc_metstdn.currentTextChanged.connect(self.update_metstdv) self.ui.fgdc_metstdv.currentIndexChanged.connect(self.update_metstdn) self.ui.button_use_dataset.clicked.connect(self.pull_datasetcontact) def update_metstdn(self): if self.ui.fgdc_metstdv.currentText() == 'FGDC-STD-001-1998': self.ui.fgdc_metstdn.setCurrentIndex(0) self.root_widget.switch_schema('fgdc') elif self.ui.fgdc_metstdv.currentText() == 'FGDC-STD-001.1-1999': self.ui.fgdc_metstdn.setCurrentIndex(1) self.root_widget.switch_schema('bdp') def update_metstdv(self): if 'biological' in self.ui.fgdc_metstdn.currentText().lower() or \ 'bdp' in self.ui.fgdc_metstdn.currentText().lower(): self.ui.fgdc_metstdv.setCurrentIndex(1) self.root_widget.switch_schema('bdp') else: self.ui.fgdc_metstdv.setCurrentIndex(0) self.root_widget.switch_schema('fgdc') def pull_datasetcontact(self): self.contactinfo.from_xml(self.root_widget.idinfo.ptcontac.to_xml()) def to_xml(self): # add code here to translate the form into xml representation metainfo_node = xml_utils.xml_node('metainfo') metd = xml_utils.xml_node('metd', text=self.metd.get_date(), parent_node=metainfo_node) if self.original_xml is not None: metrd = xml_utils.search_xpath(self.original_xml, 'metrd') if metrd is not None: metrd.tail = None metainfo_node.append(deepcopy(metrd)) if self.original_xml is not None: metfrd = xml_utils.search_xpath(self.original_xml, 'metfrd') if metfrd is not None: metfrd.tail = None metainfo_node.append(deepcopy(metfrd)) metc = xml_utils.xml_node('metc', parent_node=metainfo_node) cntinfo = self.contactinfo.to_xml() metc.append(cntinfo) metstdn = xml_utils.xml_node('metstdn', text=self.ui.fgdc_metstdn.currentText(), parent_node=metainfo_node) metstdv = xml_utils.xml_node('metstdv', text=self.ui.fgdc_metstdv.currentText(), parent_node=metainfo_node) if self.original_xml is not None: mettc = xml_utils.search_xpath(self.original_xml, 'mettc') if mettc is not None: mettc.tail = None metainfo_node.append(deepcopy(mettc)) if self.original_xml is not None: metac = xml_utils.search_xpath(self.original_xml, 'metac') if metac is not None: metac.tail = None metainfo_node.append(deepcopy(metac)) if self.original_xml is not None: metuc = xml_utils.search_xpath(self.original_xml, 'metuc') if metuc is not None: metuc_str = xml_utils.get_text_content(self.original_xml, 'metuc') metuc = xml_utils.xml_node('metuc', text=metuc_str, parent_node=metainfo_node) if self.original_xml is not None: metsi = xml_utils.search_xpath(self.original_xml, 'metsi') if metsi is not None: metsi.tail = None metainfo_node.append(deepcopy(metsi)) metextns = xml_utils.search_xpath(self.original_xml, 'metextns') if metextns is not None: metextns.tail = None metainfo_node.append(deepcopy(metextns)) return metainfo_node def from_xml(self, xml_metainfo): if xml_metainfo.tag == 'metainfo': self.original_xml = xml_metainfo if xml_metainfo.xpath('metc/cntinfo'): self.contactinfo.from_xml(xml_metainfo.xpath('metc/cntinfo')[0]) if xml_metainfo.xpath('metstdn'): standard = xml_utils.get_text_content(xml_metainfo, 'metstdn') self.ui.fgdc_metstdn.setCurrentText(standard) # switch wizard content to reflect the standard in this record if "biological" in standard.lower() \ or 'bdp' in standard.lower(): self.root_widget.switch_schema('bdp') else: self.root_widget.switch_schema('fgdc') metstdv = xml_utils.get_text_content(xml_metainfo, 'metstdv') self.ui.fgdc_metstdv.setCurrentText(metstdv) metd = xml_utils.get_text_content(xml_metainfo, 'metd') self.metd.set_date(metd) elif xml_metainfo.tag in ['ptcontac', 'cntinfo']: if xml_metainfo.tag == 'ptcontac': xml_metainfo = xml_utils.search_xpath(xml_metainfo, 'cntinfo') self.contactinfo.from_xml(xml_metainfo)
class MetaInfo(WizardWidget): drag_label = "Metadata Information <metainfo>" acceptable_tags = ["metainfo", "cntinfo", "ptcontact"] ui_class = UI_metainfo.Ui_fgdc_metainfo def __init__(self, root_widget=None): super().__init__() self.root_widget = root_widget def build_ui(self): self.ui = self.ui_class() self.ui.setupUi(self) self.setup_dragdrop(self) self.contactinfo = ContactInfo(parent=self) self.metd = FGDCDate(parent=self, fgdc_name="fgdc_metd") self.ui.help_metd.layout().addWidget(self.metd) self.ui.fgdc_metc.layout().addWidget(self.contactinfo) def connect_events(self): self.ui.fgdc_metstdn.currentTextChanged.connect(self.update_metstdv) self.ui.fgdc_metstdv.currentIndexChanged.connect(self.update_metstdn) self.ui.button_use_dataset.clicked.connect(self.pull_datasetcontact) self.ui.button_today.clicked.connect(self.todays_date) def update_metstdn(self): if self.ui.fgdc_metstdv.currentText() == "FGDC-STD-001-1998": self.ui.fgdc_metstdn.setCurrentIndex(0) self.root_widget.switch_schema("fgdc") elif self.ui.fgdc_metstdv.currentText() == "FGDC-STD-001.1-1999": self.ui.fgdc_metstdn.setCurrentIndex(1) self.root_widget.switch_schema("bdp") def update_metstdv(self): if ("biological" in self.ui.fgdc_metstdn.currentText().lower() or "bdp" in self.ui.fgdc_metstdn.currentText().lower()): self.ui.fgdc_metstdv.setCurrentIndex(1) self.root_widget.switch_schema("bdp") else: self.ui.fgdc_metstdv.setCurrentIndex(0) self.root_widget.switch_schema("fgdc") def pull_datasetcontact(self): self.contactinfo.from_xml(self.root_widget.idinfo.ptcontac.to_xml()) def todays_date(self): newdate = datetime.date.today() metd = newdate.strftime("%Y%m%d") self.metd.set_date(metd) def to_xml(self): # add code here to translate the form into xml representation metainfo_node = xml_utils.xml_node("metainfo") metc = xml_utils.xml_node('metc', parent_node=metainfo_node) if self.metd.has_content(): metd = self.metd.to_xml() metainfo_node.append(metd) if self.contactinfo.has_content(): cntinfo = self.contactinfo.to_xml() metc.append(cntinfo) metainfo_node.append(metc) if self.original_xml is not None: metstdn = xml_utils.search_xpath(self.original_xml, "metstdn") metstdv = xml_utils.search_xpath(self.original_xml, "metstdv") if metstdn is not None: metstdn.tail = None metainfo_node.append(deepcopy(metstdn)) metstdv.tail = None metainfo_node.append(deepcopy(metstdv)) else: metstdn = xml_utils.xml_node( 'metstdn', text=self.ui.fgdc_metstdn.currentText(), parent_node=metainfo_node) metstdv = xml_utils.xml_node( 'metstdv', text=self.ui.fgdc_metstdv.currentText(), parent_node=metainfo_node) # if self.original_xml is not None: # metd = xml_utils.xml_node("metd", parent_node=metainfo_node, # text=self.metd.get_date()) # if metd is not None: # metainfo_node.append(deepcopy(metd)) # metrd = xml_utils.search_xpath(self.original_xml, "metrd") # if metrd is not None: # metrd.tail = None # metainfo_node.append(deepcopy(metrd)) # metfrd = xml_utils.search_xpath(self.original_xml, "metfrd") # if metfrd is not None: # metfrd.tail = None # metainfo_node.append(deepcopy(metfrd)) # mettc = xml_utils.search_xpath(self.original_xml, "mettc") # if mettc is not None: # mettc.tail = None # metainfo_node.append(deepcopy(mettc)) # metac = xml_utils.search_xpath(self.original_xml, "metac") # if metac is not None: # metac.tail = None # metainfo_node.append(deepcopy(metac)) # metuc = xml_utils.search_xpath(self.original_xml, "metuc") # if metuc is not None: # metuc_str = xml_utils.get_text_content(self.original_xml, "metuc") # metuc = xml_utils.xml_node( # "metuc", text=metuc_str, parent_node=metainfo_node # ) # metsi = xml_utils.search_xpath(self.original_xml, "metsi") # if metsi is not None: # metsi.tail = None # metainfo_node.append(deepcopy(metsi)) # metextns = xml_utils.search_xpath(self.original_xml, "metextns") # if metextns is not None: # metextns.tail = None # metainfo_node.append(deepcopy(metextns)) # else: # metc = xml_utils.xml_node('metc', parent_node=metainfo_node) # cntinfo = self.contactinfo.to_xml() # metc.append(cntinfo) # metstdn = xml_utils.xml_node('metstdn', # text=self.ui.fgdc_metstdn.currentText(), # parent_node=metainfo_node) # metstdv = xml_utils.xml_node('metstdv', # text=self.ui.fgdc_metstdv.currentText(), # parent_node=metainfo_node) return metainfo_node def from_xml(self, xml_metainfo): if xml_metainfo.tag == "metainfo": self.original_xml = xml_metainfo if xml_metainfo.xpath("metc/cntinfo"): self.contactinfo.from_xml( xml_metainfo.xpath("metc/cntinfo")[0]) if xml_metainfo.xpath("metstdn"): standard = xml_utils.get_text_content(xml_metainfo, "metstdn") self.ui.fgdc_metstdn.setCurrentText(standard) # switch wizard content to reflect the standard in this record if "biological" in standard.lower() or "bdp" in standard.lower( ): self.root_widget.switch_schema("bdp") else: self.root_widget.switch_schema("fgdc") metstdv = xml_utils.get_text_content(xml_metainfo, "metstdv") self.ui.fgdc_metstdv.setCurrentText(metstdv) metd = xml_utils.get_text_content(xml_metainfo, "metd") self.metd.set_date(metd) elif xml_metainfo.tag in ["ptcontac", "cntinfo"]: if xml_metainfo.tag == "ptcontac": xml_metainfo = xml_utils.search_xpath(xml_metainfo, "cntinfo") self.contactinfo.from_xml(xml_metainfo)