splat/citations.py
def nsfbib(biblibrary,file=''):
    '''
    Purpose
        Takes a biblibrary and generates an NSF-formatted reference list, based on the following requirements:
        "Each reference must include the names of all authors (in the same sequence in which they 
        appear in the publication), the article and journal title, book title, volume number, page numbers, a
        and year of publication. If the proposer has a website 
        address readily available, that information should be included in the citation."

    :Required parameters:

        :param biblibrary: .bib file containing the bibtex entries

    :Optional parameters:
        :param file: Filename to save latex output (default='citations.tex') 

    :Output:
        A latex file containing relevant bibliographic information

    '''

    try:
        cites = processBiblibrary(biblibrary,verbose=True)
    except:
        raise ValueError('Could not parse biblibrary input {}; make sure this a full path to the .bib file'.format(biblibrary))

# process into a set of strings
    output = []
    for c in list(cites.keys()):
        line = cites[c]['author']
        li = line.rsplit(' and ',1)
        line = ', & '.join(li)
        line = line.replace(' and ',', ').replace('~','')
        line = line+' "'+cites[c]['title']+'." '+cites[c]['year']
# article?  
        if cites[c]['type'] == 'article':
            if 'journal' in list(cites[c].keys()): line=line+', '+cites[c]['journal']
            if 'volume' in list(cites[c].keys()): line=line+', '+cites[c]['volume']
            if 'pages' in list(cites[c].keys()): line=line+', '+cites[c]['pages']
# book?  
        if cites[c]['type'] == 'book':
            if 'publisher' in list(cites[c].keys()): line=line+', '+cites[c]['publisher']
# add url
        if 'adsurl' in list(cites[c].keys()): line=line+' ('+cites[c]['adsurl']+')'
        elif 'bdsk-url-1' in list(cites[c].keys()): line=line+' ('+cites[c]['bdsk-url-1']+')'
        else: pass
        output.append(line)
    output.sort()

# save to file if provided
    if file != '':
        try:
            f = open(os.path.normpath(file),'w')
            for o in output: f.write(o+'\n')
            f.close()
            return True
        except:
            print('Warning: problem saving to output file {}'.format(file))

    line = ''
    for o in output: line=line+o+'\n'
    return line

    Purpose
        Takes a biblibrary and generates an NSF-formatted reference list, based on the following requirements:
        "Each reference must include the names of all authors (in the same sequence in which they 
        appear in the publication), the article and journal title, book title, volume number, page numbers, a
        and year of publication. If the proposer has a website 
        address readily available, that information should be included in the citation."

    :Required parameters:

        :param biblibrary: .bib file containing the bibtex entries

    :Optional parameters:
        :param file: Filename to save latex output (default='citations.tex') 

    :Output:
        A latex file containing relevant bibliographic information

    
Purpose
Takes a biblibrary and generates an NSF-formatted reference list, based on the following requirements:
"Each reference must include the names of all authors (in the same sequence in which they
appear in the publication), the article and journal title, book title, volume number, page numbers, a
and year of publication. If the proposer has a website
address readily available, that information should be included in the citation."
Purpose Takes a biblibrary and generates an NSF - formatted reference list based on the following requirements : " Each reference must include the names of all authors ( in the same sequence in which they appear in the publication ) the article and journal title book title volume number page numbers a and year of publication . If the proposer has a website address readily available that information should be included in the citation . "
def nsfbib(biblibrary,file=''):
    try:
        cites = processBiblibrary(biblibrary,verbose=True)
    except:
        raise ValueError('Could not parse biblibrary input {}; make sure this a full path to the .bib file'.format(biblibrary))
    output = []
    for c in list(cites.keys()):
        line = cites[c]['author']
        li = line.rsplit(' and ',1)
        line = ', & '.join(li)
        line = line.replace(' and ',', ').replace('~','')
        line = line+' "'+cites[c]['title']+'." '+cites[c]['year']
        if cites[c]['type'] == 'article':
            if 'journal' in list(cites[c].keys()): line=line+', '+cites[c]['journal']
            if 'volume' in list(cites[c].keys()): line=line+', '+cites[c]['volume']
            if 'pages' in list(cites[c].keys()): line=line+', '+cites[c]['pages']
        if cites[c]['type'] == 'book':
            if 'publisher' in list(cites[c].keys()): line=line+', '+cites[c]['publisher']
        if 'adsurl' in list(cites[c].keys()): line=line+' ('+cites[c]['adsurl']+')'
        elif 'bdsk-url-1' in list(cites[c].keys()): line=line+' ('+cites[c]['bdsk-url-1']+')'
        else: pass
        output.append(line)
    output.sort()
    if file != '':
        try:
            f = open(os.path.normpath(file),'w')
            for o in output: f.write(o+'\n')
            f.close()
            return True
        except:
            print('Warning: problem saving to output file {}'.format(file))
    line = ''
    for o in output: line=line+o+'\n'
    return line
def nsfbib ( biblibrary , file = '' ) : try : cites = processBiblibrary ( biblibrary , verbose = True ) except : raise ValueError ( 'Could not parse biblibrary input {}; make sure this a full path to the .bib file' . format ( biblibrary ) ) output = [ ] for c in list ( cites . keys ( ) ) : line = cites [ c ] [ 'author' ] li = line . rsplit ( ' and ' , 1 ) line = ', & ' . join ( li ) line = line . replace ( ' and ' , ', ' ) . replace ( '~' , '' ) line = line + ' "' + cites [ c ] [ 'title' ] + '." ' + cites [ c ] [ 'year' ] if cites [ c ] [ 'type' ] == 'article' : if 'journal' in list ( cites [ c ] . keys ( ) ) : line = line + ', ' + cites [ c ] [ 'journal' ] if 'volume' in list ( cites [ c ] . keys ( ) ) : line = line + ', ' + cites [ c ] [ 'volume' ] if 'pages' in list ( cites [ c ] . keys ( ) ) : line = line + ', ' + cites [ c ] [ 'pages' ] if cites [ c ] [ 'type' ] == 'book' : if 'publisher' in list ( cites [ c ] . keys ( ) ) : line = line + ', ' + cites [ c ] [ 'publisher' ] if 'adsurl' in list ( cites [ c ] . keys ( ) ) : line = line + ' (' + cites [ c ] [ 'adsurl' ] + ')' elif 'bdsk-url-1' in list ( cites [ c ] . keys ( ) ) : line = line + ' (' + cites [ c ] [ 'bdsk-url-1' ] + ')' else : pass output . append ( line ) output . sort ( ) if file != '' : try : f = open ( os . path . normpath ( file ) , 'w' ) for o in output : f . write ( o + '\n' ) f . close ( ) return True except : print ( 'Warning: problem saving to output file {}' . format ( file ) ) line = '' for o in output : line = line + o + '\n' return line
Purpose
Takes a biblibrary and generates an NSF-formatted reference list, based on the following requirements:
"Each reference must include the names of all authors (in the same sequence in which they
appear in the publication), the article and journal title, book title, volume number, page numbers, a
and year of publication.
Purpose Takes a biblibrary and generates an NSF - formatted reference list based on the following requirements : " Each reference must include the names of all authors ( in the same sequence in which they appear in the publication ) the article and journal title book title volume number page numbers a and year of publication .
'''
    Purpose
        Takes a biblibrary and generates an NSF-formatted reference list, based on the following requirements:
        "Each reference must include the names of all authors (in the same sequence in which they 
        appear in the publication), the article and journal title, book title, volume number, page numbers, a
        and year of publication. If the proposer has a website 
        address readily available, that information should be included in the citation."

    :Required parameters:

        :param biblibrary: .bib file containing the bibtex entries

    :Optional parameters:
        :param file: Filename to save latex output (default='citations.tex') 

    :Output:
        A latex file containing relevant bibliographic information

    ''' # process into a set of strings # article?   # book?   # add url # save to file if provided
biblibrary
file
Required
:param biblibrary: .bib file containing the bibtex entries
: param biblibrary : . bib file containing the bibtex entries
Optional
:param file: Filename to save latex output (default='citations.tex')
: param file : Filename to save latex output ( default = ' citations . tex ' )
Output
A latex file containing relevant bibliographic information
A latex file containing relevant bibliographic information