How to use the wikidataintegrator.wdi_login.WDLogin 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
try:
        from local import WDUSER, WDPASS
    except ImportError:
        if "WDUSER" in os.environ and "WDPASS" in os.environ:
            WDUSER = os.environ['WDUSER']
            WDPASS = os.environ['WDPASS']
        else:
            raise ValueError("WDUSER and WDPASS must be specified in local.py or as environment variables")

    parser = argparse.ArgumentParser(description='run publication creator')
    parser.add_argument("ext_id", help="comma-separated list of IDs")
    parser.add_argument("--source", help="API to use (crossref or europepmc)", default="crossref")
    parser.add_argument("--idtype", help="external id type (doi, pmcid, pmid, etc...)", default="doi")
    args = parser.parse_args()

    login = wdi_login.WDLogin(WDUSER, WDPASS)

    ext_ids = sorted(list(set(map(str.strip, args.ext_id.split(",")))))
    id_type = args.idtype
    source = args.source

    with open("log.txt", "a") as f:
        for ext_id in ext_ids:
            try:
                p = PublicationHelper(ext_id, id_type=id_type, source=source)
                qid, warnings, success = p.get_or_create(login)
                print("{},{},{},{}".format(ext_id, qid, "|".join(warnings), success))
                print("{},{},{},{}".format(ext_id, qid, "|".join(warnings), success), file=f)
                sleep(3)
            except Exception as e:
                print("{},{},{},{}".format(ext_id, None, e, False))
                print("{},{},{},{}".format(ext_id, None, e, False), file=f)
github pyOpenSci / pyApiToolkit / code / wikidata.py View on Github external
def login(user, password):
	login_instance = wdi_login.WDLogin(user=user, pwd=password)
github WikiDP / wikidp-portal / wikidp / wikidata.py View on Github external
def test_query():
    login_instance = wdi_login.WDLogin(user=APP.config.WIKIDATA_USER_NAME, pwd=APP.config.WIKIDATA_PASSWORD)
    results = wdi_core.WDItemEngine.execute_sparql_query(QUERIES['list-formats'].replace('\n', ''))
    return results