<s> """<STR_LIT>""" <EOL> __docformat__ = "<STR_LIT>" <EOL> __authors__ = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> __version__ = "<STR_LIT>" <EOL> __needs__ = '<STR_LIT>' <EOL> import string , sys , os <EOL> import logging <EOL> logging . basicConfig ( format = '<STR_LIT>' ) <EOL> bibsearch_logger = logging . getLogger ( '<STR_LIT>' ) <EOL> from bibstuff import bibfile , bibgrammar , bibstyles <EOL> def main ( ) : <EOL> """<STR_LIT>""" <EOL> from optparse import OptionParser <EOL> usage = "<STR_LIT>" <EOL> parser = OptionParser ( usage = usage , version = "<STR_LIT>" + __version__ ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , <EOL> default = False , help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , <EOL> default = False , help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , <EOL> default = False , help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store>" , dest = "<STR_LIT>" , default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" , metavar = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store>" , type = "<STR_LIT:string>" , dest = "<STR_LIT>" , <EOL> default = None , <EOL> help = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , dest = "<STR_LIT>" , default = False , <EOL> help = "<STR_LIT>" ) <EOL> ( options , args ) = parser . parse_args ( ) <EOL> if options . verbose : <EOL> bibsearch_logger . setLevel ( logging . INFO ) <EOL> if options . very_verbose : <EOL> bibsearch_logger . setLevel ( logging . DEBUG ) <EOL> bibsearch_logger . debug ( "<STR_LIT>" <EOL> % ( args , options . stylefile ) <EOL> ) <EOL> try : <EOL> src = open ( args [ <NUM_LIT:0> ] ) . read ( ) <EOL> except : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if len ( args ) < <NUM_LIT:2> : <EOL> searches = string . split ( sys . stdin . read ( ) ) <EOL> else : <EOL> searches = args [ <NUM_LIT:1> : ] <EOL> parsed_bibfile = bibfile . BibFile ( ) <EOL> bibgrammar . Parse ( src , parsed_bibfile ) <EOL> entrylist = [ ] <EOL> if options . field : <EOL> for s in searches : <EOL> entrylist . extend ( parsed_bibfile . search_entries ( s , field = options . field ) ) <EOL> elif options . search_input : <EOL> for s in searches : <EOL> entrylist . extend ( parsed_bibfile . search_entries ( s ) ) <EOL> else : <EOL> entrylist = parsed_bibfile . get_entrylist ( searches , discard = True ) <EOL> if entrylist : <EOL> result = "<STR_LIT>" <EOL> if options . citekey_output : <EOL> result = "<STR_LIT:\n>" . join ( e . citekey for e in entrylist ) <EOL> elif options . long_output : <EOL> result = "<STR_LIT:\n>" . join ( str ( e ) for e in entrylist ) <EOL> else : <EOL> style_stmt = "<STR_LIT>" % os . path . splitext ( options . stylefile ) [ <NUM_LIT:0> ] <EOL> exec style_stmt in globals ( ) <EOL> citation_manager = style . CitationManager ( [ parsed_bibfile ] , <EOL> citekeys = [ e . citekey for e in entrylist ] , <EOL> citation_template = style . CITATION_TEMPLATE ) <EOL> cite_processor = bibstyles . shared . CiteRefProcessor ( citation_manager ) <EOL> result = citation_manager . make_citations ( ) <EOL> print ( result ) <EOL> else : <EOL> bibsearch_logger . info ( "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
