How to use the wikidataintegrator.wdi_core.WDUrl function in wikidataintegrator

To help you get started, we’ve selected a few wikidataintegrator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SuLab / WikidataIntegrator / wikidataintegrator / wdi_helpers / publication.py View on Github external
def make_reference(self):
        if self.source == "crossref":
            assert 'doi' in self.ids
            extid = wdi_core.WDString(self.ids['doi'], PROPS['DOI'], is_reference=True)
            ref_url = wdi_core.WDUrl(self.ref_url, PROPS['reference URL'], is_reference=True)
            stated_in = wdi_core.WDItemID(self.SOURCES[self.source], PROPS['stated in'], is_reference=True)
            retrieved = wdi_core.WDTime(strftime("+%Y-%m-%dT00:00:00Z", gmtime()), PROPS['retrieved'],
                                        is_reference=True)
            self.reference = [stated_in, extid, ref_url, retrieved]
        elif self.source == "europepmc":
            assert 'pmcid' in self.ids
            extid = wdi_core.WDString(self.ids['pmcid'], PROPS['PMCID'], is_reference=True)
            ref_url = wdi_core.WDUrl(self.ref_url, PROPS['reference URL'], is_reference=True)
            stated_in = wdi_core.WDItemID(self.SOURCES[self.source], PROPS['stated in'], is_reference=True)
            retrieved = wdi_core.WDTime(strftime("+%Y-%m-%dT00:00:00Z", gmtime()), PROPS['retrieved'],
                                        is_reference=True)
            self.reference = [stated_in, extid, ref_url, retrieved]
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_helpers.py View on Github external
def make_statements(self):
        s = []
        helper = self.helper
        # instance of edition
        s.append(wdi_core.WDItemID(helper.get_qid('Q3331189'), helper.get_pid("P31")))
        # edition or translation of
        s.append(wdi_core.WDItemID(self.edition_of_qid, helper.get_pid("P629")))
        # edition number
        s.append(wdi_core.WDString(self.edition, helper.get_pid("P393")))

        if self.archive_url:
            s.append(wdi_core.WDUrl(self.archive_url, helper.get_pid('P1065')))

        if self.pub_date:
            s.append(wdi_core.WDTime(self.pub_date, helper.get_pid('P577'), precision=self.date_precision))

        self.statements = s
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_core.py View on Github external
def set_value(self, value):
        if value is None:
            self.value = None
        else:
            protocols = ['http://', 'https://', 'ftp://', 'irc://']
            if True not in [True for x in protocols if value.startswith(x)]:
                raise ValueError('Invalid URL')

            self.value = value

        self.json_representation['datavalue'] = {
            'value': self.value,
            'type': 'string'
        }

        super(WDUrl, self).set_value(value=self.value)
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_helpers / release.py View on Github external
def make_statements(self):
        s = []
        helper = self.helper
        # instance of edition
        s.append(wdi_core.WDItemID(helper.get_qid('Q3331189'), helper.get_pid("P31")))
        # edition or translation of
        s.append(wdi_core.WDItemID(self.edition_of_qid, helper.get_pid("P629")))
        # edition number
        s.append(wdi_core.WDString(self.edition, helper.get_pid("P393")))

        if self.archive_url:
            s.append(wdi_core.WDUrl(self.archive_url, helper.get_pid('P1065')))

        if self.pub_date:
            s.append(wdi_core.WDTime(self.pub_date, helper.get_pid('P577'), precision=self.date_precision))

        self.statements = s
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_helpers / publication.py View on Github external
def make_reference(self):
        if self.source == "crossref":
            assert 'doi' in self.ids
            extid = wdi_core.WDString(self.ids['doi'], PROPS['DOI'], is_reference=True)
            ref_url = wdi_core.WDUrl(self.ref_url, PROPS['reference URL'], is_reference=True)
            stated_in = wdi_core.WDItemID(self.SOURCES[self.source], PROPS['stated in'], is_reference=True)
            retrieved = wdi_core.WDTime(strftime("+%Y-%m-%dT00:00:00Z", gmtime()), PROPS['retrieved'],
                                        is_reference=True)
            self.reference = [stated_in, extid, ref_url, retrieved]
        elif self.source == "europepmc":
            assert 'pmcid' in self.ids
            extid = wdi_core.WDString(self.ids['pmcid'], PROPS['PMCID'], is_reference=True)
            ref_url = wdi_core.WDUrl(self.ref_url, PROPS['reference URL'], is_reference=True)
            stated_in = wdi_core.WDItemID(self.SOURCES[self.source], PROPS['stated in'], is_reference=True)
            retrieved = wdi_core.WDTime(strftime("+%Y-%m-%dT00:00:00Z", gmtime()), PROPS['retrieved'],
                                        is_reference=True)
            self.reference = [stated_in, extid, ref_url, retrieved]
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_core.py View on Github external
def set_value(self, value):
        if value is None:
            self.value = None
        else:
            protocols = ['http://', 'https://', 'ftp://', 'irc://', 'mailto:']
            if True not in [True for x in protocols if value.startswith(x)]:
                raise ValueError('Invalid URL')

            self.value = value

        self.json_representation['datavalue'] = {
            'value': self.value,
            'type': 'string'
        }

        super(WDUrl, self).set_value(value=self.value)
github SuLab / WikidataIntegrator / wikidataintegrator / wdi_helpers.py View on Github external
def make_reference(self):
        if not self.meta['parsed']:
            self.parse_metadata()
        if 'pmcid' in self.meta and self.meta['pmcid']:
            extid = wdi_core.WDString(value=self.meta['pmcid'], prop_nr=self.PROPS['PMCID'], is_reference=True)
            ref_url = wdi_core.WDUrl("http://europepmc.org/abstract/{}/{}".format("PMC", self.meta['pmcid']),
                                     self.PROPS['reference URL'], is_reference=True)
        elif 'pmid' in self.meta and self.meta['pmid']:
            extid = wdi_core.WDString(value=self.meta['pmid'], prop_nr=self.PROPS['PubMed ID'], is_reference=True)
            ref_url = wdi_core.WDUrl("http://europepmc.org/abstract/{}/{}".format("MED", self.meta['pmid']),
                                     self.PROPS['reference URL'], is_reference=True)
        elif 'doi' in self.meta and self.meta['doi']:
            extid = wdi_core.WDString(value=self.meta['doi'], prop_nr=self.PROPS['DOI'], is_reference=True)
            ref_url = None
        else:
            raise ValueError("ref needs a pmcid, pmid, or doi")
        stated_in = wdi_core.WDItemID(value='Q5412157', prop_nr='P248', is_reference=True)
        retrieved = wdi_core.WDTime(strftime("+%Y-%m-%dT00:00:00Z", gmtime()), prop_nr='P813', is_reference=True)
        self.reference = [stated_in, extid, retrieved]
        if ref_url:
            self.reference.append(ref_url)