Return the badge for a DOI.
324338
def get_badge_image_url(pid, ext='svg'):
    """"""
    return url_for('invenio_formatter_badges.badge',
                   title=pid.pid_type, value=pid.pid_value, ext=ext)
591251
def doc2id(self, doc):
        
        doc = map(self.process_token, doc)
        return [self.token_to_id(token) for token in doc]
1131467
def get_id(self):
        """"""
        if self._id_attr is None or not hasattr(self, self._id_attr):
            return None
        return getattr(self, self._id_attr)
1051900
def _printable_id_code(self):
        
        code = str(self.id_code)
        while len(code) < self._code_size:
            code = '0' + code

        return code
1191882
def getmakeidfobject(idf, key, name):
    """"""
    idfobject = idf.getobject(key, name)
    if not idfobject:
        return idf.newidfobject(key, Name=name)
    else:
        return idfobject
309996
def to_det_id(self, det_id_or_det_oid):
        """"""
        try:
            int(det_id_or_det_oid)
        except ValueError:
            return self.get_det_id(det_id_or_det_oid)
        else:
            return det_id_or_det_oid
1209928
def _get_id(self):
        """"""
        return ''.join(map(str,
                           filter(is_not_None,
                                  [self.Prefix, self.Name])))
864941
def _id(self):
        """"""
        result = ''
        while self.char is not None and (self.char.isalnum() or self.char == '_'):
            result += self.char
            self.advance()

        token = RESERVED_KEYWORDS.get(result, Token(Nature.ID, result))
        return token
687336
function _fetchDOI (doi) {
  const url = ENDPOINT + doi
  return sendRequest({ url: url, method: 'GET', header: { 'accept': 'application/vnd.citationstyles.csl+json' } })
}
170362
def badge_width(self):
        
        return self.get_text_width('   ' + ' ' * int(float(self.num_padding_chars) * 2.0)) \
            + self.label_width + self.value_width
139939
def get(self, doc_id):
        """"""
        resp_dict = self._get_query(q='id:{}'.format(doc_id))
        if resp_dict['response']['numFound'] > 0:
            return resp_dict['response']['docs'][0]
186343
def _get_uid(name):
    """"""
    if getpwnam is None or name is None:
        return None
    try:
        result = getpwnam(name)
    except KeyError:
        result = None
    if result is not None:
        return result[2]
    return None
1305247
def _id_resolv(self, iid, named=True, uid=True):
        '''
        
        '''

        if not self.local_identity:
            self.local_identity['users'] = self._get_local_users()
            self.local_identity['groups'] = self._get_local_groups()

        if not named:
            return iid

        for name, meta in self.local_identity[uid and 'users' or 'groups'].items():
            if (uid and int(meta.get('uid', -1)) == iid) or (not uid and int(meta.get('gid', -1)) == iid):
                return name

        return iid
1151859
def get(self, id=None, **kwargs):
        
        if id is not None:
            return self._get('metrics/%s' % id, data=kwargs)
        else:
            return self._get('metrics', data=kwargs)
1005870
def get_data(doi_id):
    

    fetch_dict = {}

    try:
        # Send request to grab metadata at URL
        print("Requesting : {}".format(doi_id))
        url = "http://dx.doi.org/" + doi_id
        headers = {"accept": "application/rdf+xml;q=0.5, application/citeproc+json;q=1.0"}
        r = requests.get(url, headers=headers)


        # DOI 404. Data not retrieved. Log and return original pub
        if r.status_code == 400 or r.status_code == 404:
            print("HTTP 404: DOI not found, {}".format(doi_id))

        # Ignore other status codes. Run when status is 200 (good response)
        elif r.status_code == 200:
            # Load data from http response
            raw = json.loads(r.text)
            # Create a new pub dictionary with metadata received
            fetch_dict = compile_fetch(raw, doi_id)
            fetch_dict['pubDataUrl'] = 'doi.org'

    except urllib.error.URLError as e:
        fetch_dict["ERROR"] = e
        fetch_dict["doi"] = doi_id
        print("get_data: URLError: malformed doi: {}, {}".format(doi_id, e))
    except Exception as e:
        fetch_dict["ERROR"] = e
        fetch_dict["doi"] = doi_id
        print("get_data: ValueError: cannot resolve dois from this publisher: {}, {}".format(doi_id, e))
    return fetch_dict
528442
def rm_empty_doi(d):
    
    logger_misc.info("enter remove_empty_doi")
    try:
        # Check each publication dictionary
        for pub in d['pub']:
            # If no identifier, then we can quit here. If identifier, then keep going.
            if 'identifier' in pub:
                if 'id' in pub['identifier'][0]:
                    # If there's a DOI id, but it's EMPTY
                    if pub['identifier'][0]['id'] in EMPTY:
                        del pub['identifier']
                else:
                    # If there's an identifier section, with no DOI id
                    del pub['identifier']
    except KeyError as e:
        # What else could go wrong?
        logger_misc.warn("remove_empty_doi: KeyError: publication key not found, {}".format(e))
    logger_misc.info("exit remove_empty_doi")
    return d
553355
def badge_color(self):
        """"""
        # If no thresholds were passed then return the default color
        if not self.thresholds:
            return self.default_color

        if self.value_type == str:
            if self.value in self.thresholds:
                return self.thresholds[self.value]
            else:
                return self.default_color

        # Convert the threshold dictionary into a sorted list of lists
        threshold_list = [[self.value_type(i[0]), i[1]] for i in self.thresholds.items()]
        threshold_list.sort(key=lambda x: x[0])

        color = None

        for threshold, color in threshold_list:
            if float(self.value) < float(threshold):
                return color

        # If we drop out the top of the range then return the last max color
        if color and self.use_max_when_value_exceeds:
            return color
        else:
            return self.default_color