Exemple #1
0
def show(identifier):
    """Display the JSON for the single item in the database.
    The identifier may be a PMID, DOI, email, API key, label, ISSN, ISSN-L,
    ORCID, or IUID of the document.
    """
    db = utils.get_db()
    for designname, viewname, operation in [
        ("publication", "pmid", _asis),
        ("publication", "doi", _asis),
        ("account", "email", _asis),
        ("account", "api_key", _asis),
        ("label", "normalized_value", _normalized),
        ("journal", "issn", _asis),
        ("journal", "issn_l", _asis),
        ("researcher", "orcid", _asis),
        ("blacklist", "doi", _asis),
        ("blacklist", "pmid", _asis),
    ]:
        try:
            doc = utils.get_doc(db, designname, viewname,
                                operation(identifier))
            break
        except KeyError:
            pass
    else:
        try:
            doc = db[identifier]
        except couchdb2.NotFoundError:
            raise click.ClickException("No such item in the database.")
    click.echo(json.dumps(doc, ensure_ascii=False, indent=2))
Exemple #2
0
 def select_orcid(self, orcid):
     "Select publications by researcher ORCID."
     try:
         researcher = utils.get_doc(self.db, "researcher", "orcid", orcid)
         iuid = researcher["_id"]
     except KeyError:
         iuid = "-"
     self._select("publication", "researcher", key=iuid)
 def get_doc(self, designname, viewname, key):
     """Get the document with the given id, or from the given view.
     Raise KeyError if not found.
     """
     return utils.get_doc(self.db, designname, viewname, key)
Exemple #4
0
def get_doi(db, doi):
    "Get an existing publication for the DOI."
    try:
        return utils.get_doc(db, doi, viewname='publication/doi')
    except KeyError:
        return None
Exemple #5
0
def get_pmid(db, pmid):
    "Get an existing publication for the PMID."
    try:
        return utils.get_doc(db, pmid, viewname='publication/pmid')
    except KeyError:
        return None