Example #1
0
def get_dois(record, internal_only_p=False):
    """
    Return the list of DOIs in the given record. If C{internal_only_p}
    is set to True, only those DOIs that are considered owned/managed
    by this installation (as defined in
    CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN) will be returned.

    @param record: the record we want to get DOIs from
    @type record: BibRecord object
    @param internal_only_p: if True, returns only DOIs managed/owned by the system
    @type internal_only_p: bool
    @rtype: list(string)
    """
    return [doi for doi in record_extract_dois(record) if \
            not internal_only_p or re.compile(CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN).match(doi)]
Example #2
0
def get_dois(record, internal_only_p=False):
    """
    Return the list of DOIs in the given record. If C{internal_only_p}
    is set to True, only those DOIs that are considered owned/managed
    by this installation (as defined in
    CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN) will be returned.

    @param record: the record we want to get DOIs from
    @type record: BibRecord object
    @param internal_only_p: if True, returns only DOIs managed/owned by the system
    @type internal_only_p: bool
    @rtype: list(string)
    """
    return [doi for doi in record_extract_dois(record) if \
            not internal_only_p or re.compile(CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN).match(doi)]
Example #3
0
def format_element(bfo, var=''):
    '''
    Print several server specific variables.
    @param var: the name of the desired variable. Can be one of: CFG_SITE_NAME, CFG_SITE_NAME_INTL, CFG_SITE_LANG, CFG_VERSION, CFG_SITE_ADMIN_EMAIL, CFG_SITE_SUPPORT_EMAIL, CFG_SITE_URL, searchurl, recurl
           CFG_SITE_NAME: the name of the server
           CFG_SITE_NAME_INTL: internationalized name
           CFG_SITE_LANG: the default language of the server
           CFG_VERSION: the software version
           CFG_SITE_ADMIN_EMAIL: the admin email
           CFG_SITE_SUPPORT_EMAIL: the support email
           CFG_SITE_URL: the base url for the server
           searchurl: the search url for the server
           recurl: the base url for the record
           recinternaldoiurl_or_recurl: the base url for the record, as an internal CFG_SITE_URL + '/doi' URL when DOI is available and matched by CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN
    '''
    dois = []
    if var == 'recinternaldoiurl_or_recurl':
        # Prepare list of internal DOIs of that record
        dois = [doi for doi in record_extract_dois(bfo.get_record()) if \
                re.compile(CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN).match(doi)]

    recID = bfo.recID
    if var == '':
        out = ''
    elif var in ['name', 'CFG_SITE_NAME']:
        out = CFG_SITE_NAME
    elif var in ['i18n_name', 'CFG_SITE_NAME_INTL']:
        out = CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME)
    elif var in ['lang', 'CFG_SITE_LANG']:
        out = CFG_SITE_LANG
    elif var == 'CFG_VERSION':
        out = 'Invenio v' + str(CFG_VERSION)
    elif var in ['email', 'admin_email', 'CFG_SITE_ADMIN_EMAIL']:
        out = CFG_SITE_ADMIN_EMAIL
    elif var in ['support_email', 'CFG_SITE_SUPPORT_EMAIL']:
        out = CFG_SITE_SUPPORT_EMAIL
    elif var in ['CFG_SITE_RECORD']:
        out = CFG_SITE_RECORD
    elif var in ['weburl', 'CFG_SITE_URL']:
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
    elif var in ['CFG_BASE_URL']:
        out = CFG_BASE_URL
        if not out.endswith('/'):
            out += '/'
    elif var == 'searchurl':
        out = CFG_BASE_URL + '/search'
        if not out.endswith('/'):
            out += '/'
    elif var == 'absolutesearchurl':
        out = CFG_SITE_URL + '/search'
        if not out.endswith('/'):
            out += '/'
    elif var == 'absoluterecurl':
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
        out += CFG_SITE_RECORD + '/' + str(recID)
    elif var == 'recinternaldoiurl_or_recurl' and \
             dois:
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
        out += 'doi/' + urllib.quote(dois[0])
    elif var in ('recurl', 'recinternaldoiurl_or_recurl'):
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
        out += CFG_SITE_RECORD +'/' + str(recID)
    else:
        out = 'Unknown variable: %s' % (var)
    return out
def format_element(bfo, var=''):
    '''
    Print several server specific variables.
    @param var: the name of the desired variable. Can be one of: CFG_SITE_NAME, CFG_SITE_NAME_INTL, CFG_SITE_LANG, CFG_VERSION, CFG_SITE_ADMIN_EMAIL, CFG_SITE_SUPPORT_EMAIL, CFG_SITE_URL, searchurl, recurl
           CFG_SITE_NAME: the name of the server
           CFG_SITE_NAME_INTL: internationalized name
           CFG_SITE_LANG: the default language of the server
           CFG_VERSION: the software version
           CFG_SITE_ADMIN_EMAIL: the admin email
           CFG_SITE_SUPPORT_EMAIL: the support email
           CFG_SITE_URL: the base url for the server
           searchurl: the search url for the server
           recurl: the base url for the record
           recinternaldoiurl_or_recurl: the base url for the record, as an internal CFG_SITE_URL + '/doi' URL when DOI is available and matched by CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN
    '''
    dois = []
    if var == 'recinternaldoiurl_or_recurl':
        # Prepare list of internal DOIs of that record
        dois = [doi for doi in record_extract_dois(bfo.get_record()) if \
                re.compile(CFG_BIBUPLOAD_INTERNAL_DOI_PATTERN).match(doi)]

    recID = bfo.recID
    if var == '':
        out = ''
    elif var in ['name', 'CFG_SITE_NAME']:
        out = CFG_SITE_NAME
    elif var in ['i18n_name', 'CFG_SITE_NAME_INTL']:
        out = CFG_SITE_NAME_INTL.get(bfo.lang, CFG_SITE_NAME)
    elif var in ['lang', 'CFG_SITE_LANG']:
        out = CFG_SITE_LANG
    elif var == 'CFG_VERSION':
        out = 'Invenio v' + str(CFG_VERSION)
    elif var in ['email', 'admin_email', 'CFG_SITE_ADMIN_EMAIL']:
        out = CFG_SITE_ADMIN_EMAIL
    elif var in ['support_email', 'CFG_SITE_SUPPORT_EMAIL']:
        out = CFG_SITE_SUPPORT_EMAIL
    elif var in ['CFG_SITE_RECORD']:
        out = CFG_SITE_RECORD
    elif var in ['weburl', 'CFG_SITE_URL']:
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
    elif var in ['CFG_BASE_URL']:
        out = CFG_BASE_URL
        if not out.endswith('/'):
            out += '/'
    elif var == 'searchurl':
        out = CFG_BASE_URL + '/search'
        if not out.endswith('/'):
            out += '/'
    elif var == 'absolutesearchurl':
        out = CFG_SITE_URL + '/search'
        if not out.endswith('/'):
            out += '/'
    elif var == 'absoluterecurl':
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
        out += CFG_SITE_RECORD + '/' + str(recID)
    elif var == 'recinternaldoiurl_or_recurl' and \
             dois:
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
        out += 'doi/' + urllib.quote(dois[0])
    elif var in ('recurl', 'recinternaldoiurl_or_recurl'):
        out = CFG_SITE_URL
        if not out.endswith('/'):
            out += '/'
        out += CFG_SITE_RECORD + '/' + str(recID)
    else:
        out = 'Unknown variable: %s' % (var)
    return out