Exemple #1
0
    def dropEvent(self, e):
        """
        Updates the form with the contents of an xml node dropped onto it.
        Parameters
        ----------
        e : qt event
        Returns
        -------
        None
        """
        try:
            e.setDropAction(Qt.CopyAction)
            e.accept()
            mime_data = e.mimeData()
            if mime_data.hasUrls() or self.is_doi_str(mime_data.text()):
                if self.is_doi_str(mime_data.text()):
                    doi = mime_data.text()
                else:
                    doi = e.mimeData().urls()[0].url()
                try:
                    citeinfo = doi_utils.get_doi_citation(doi)
                    self.from_xml(citeinfo.to_xml())
                except:
                    msg = "We ran into a problem creating a citeinfo element from that DOI({})".format(
                        doi)
                    msg += "Check the DOI and/or manually create the citation for it"
                    QMessageBox.warning(self, "Problem DOI", msg)
            else:
                element = xml_utils.string_to_node(mime_data.text())

                self.from_xml(element)
        except:
            e = sys.exc_info()[0]
            print("problem drop", e)
def test_datacite():
    doi = "10.5066/F7CJ8CDH"
    citeinfo = doi_utils.get_doi_citation(doi)
    assert (
        citeinfo.title.text
        == "14.86 km Profiles of the Electric and Self-potential Fields Measured in the Lower Guadalupe River Channel, Texas Interior Gulf Coastal Plain, September 2016"
    )
    assert citeinfo.geoform.text == "dataset"
Exemple #3
0
    def add_doi(self):
        doi = self.doi_lookup_ui.le_doi.text()
        try:
            citeinfo = doi_utils.get_doi_citation(doi)

            if citeinfo is None:
                msgbox = QMessageBox(self)
                utils.set_window_icon(msgbox)
                msgbox.setIcon(QMessageBox.Warning)
                msg = "'{}' Not Found on DataCite".format(doi)
                msg += "\nMake sure the DOI is valid and active."
                msgbox.setText(msg)
                msgbox.setInformativeText("No matching citation found")
                msgbox.setWindowTitle("DOI Not Found")
                msgbox.setStandardButtons(QMessageBox.Ok)
                msgbox.exec_()
            else:
                self.from_xml(citeinfo.to_xml())
        except:
            msg = "We ran into a problem creating a citeinfo element from that DOI({})".format(
                doi)
            msg += "Check the DOI and/or manually create the citation for it"
            QMessageBox.warning(self, "Problem DOI", msg)
        self.cancel()
Exemple #4
0
def test_crossref():
    doi = "https://doi.org/10.1007/s10530-018-1696-1"
    assert doi_utils.get_doi_citation(
        doi
    ).title.text == 'Managing an invasive corallimorph at Palmyra Atoll National Wildlife Refuge, Line Islands, Central Pacific'