Ejemplo n.º 1
0
 def params(self, params):
     if params:
         return '?' + '&'.join(
             '%s=%s' % (uquote(str(k)), uquote(str(v)))
             for k, v in params.items()
         )
     return ''
Ejemplo n.º 2
0
def possible_doi(author, title, n=10):
    '''
    Takes in an author and title,
    returns a doi, and the best leven dist.
    '''
    url = "https://api.crossref.org/works?rows={}&query.author={}&query.title={}"
    r = requests.get(url.format(n, uquote(author), uquote(title)))
    print(r, title)
    d = r.json()
    doi_list = []  # List of tuples
    for item in d['message']['items']:
        doi_title = item['title']
        print(doi_title)
        doi = item['DOI']
        ratio = fuzz.ratio(doi_title, title)
        doi_list.append((doi_title, doi, ratio))

    return max(doi_list, key=itemgetter(2))[1:]
Ejemplo n.º 3
0
def quote(value, safe="", encoding="utf-8"):
    return uquote(value.encode(encoding), safe)
Ejemplo n.º 4
0
def quote(value, safe='', encoding='utf-8'):
    return uquote(value.encode(encoding), safe)
Ejemplo n.º 5
0
def quote(url, safe='/', encoding=None, errors=None):
    """Wrapper for urllib.parse.quote"""
    return uquote(url, safe=safe, encoding=encoding, errors=errors)
Ejemplo n.º 6
0
def unquote(string):
    try:
        return uquote(string)
    except:  # pylint: disable=bare-except
        return string