<s> """<STR_LIT>""" <EOL> import shelve <EOL> import sys <EOL> from commands import getoutput <EOL> from datetime import datetime <EOL> from fnmatch import fnmatch , filter <EOL> from os import getcwd , listdir , sep as SEP , stat , environ , walk <EOL> from os . path import abspath , basename , dirname , join as join_path , isfile , isdir <EOL> from os . path import split as split_path , splitext , isabs <EOL> from optparse import OptionParser <EOL> from pickle import load as load_pickle , dump as dump_pickle <EOL> from re import compile <EOL> from time import time <EOL> from genshi . template import MarkupTemplate , TemplateLoader <EOL> from pygments import highlight <EOL> from pygments . formatters import HtmlFormatter <EOL> from pygments . lexers import PythonLexer <EOL> from . . service . rst import render_rst <EOL> LINE = '<STR_LIT:->' * <NUM_LIT> <EOL> HOME = getcwd ( ) <EOL> MORE_LINE = '<STR_LIT>' <EOL> SEPARATORS = ( '<STR_LIT:->' , '<STR_LIT::>' ) <EOL> SVN_INFO = "<STR_LIT>" <EOL> SVN_CACHE = { } <EOL> AUTHORS_CACHE = { } <EOL> TRACKER_CACHE = { } <EOL> SYNTAX_FORMATTER = HtmlFormatter ( cssclass = '<STR_LIT>' , lineseparator = '<STR_LIT>' ) <EOL> INDEX_FILES = ( <EOL> ( '<STR_LIT>' , <NUM_LIT:2> , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:0> , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ) <EOL> match_non_whitespace_regex = compile ( r'<STR_LIT>' ) . match <EOL> docstring_regex = compile ( r'<STR_LIT>' ) <EOL> def strip_leading_indent ( text ) : <EOL> """<STR_LIT>""" <EOL> lines = text . split ( '<STR_LIT:\n>' ) <EOL> if len ( lines ) == <NUM_LIT:1> : <EOL> return lines [ <NUM_LIT:0> ] . lstrip ( ) <EOL> last_line = lines . pop ( ) <EOL> if match_non_whitespace_regex ( last_line ) : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> indent = len ( last_line ) <EOL> return '<STR_LIT:\n>' . join ( line [ indent : ] for line in lines ) . strip ( ) <EOL> def get_svn_info ( path , pattern ) : <EOL> """<STR_LIT>""" <EOL> if ( path , pattern ) in SVN_CACHE : <EOL> return SVN_CACHE [ ( path , pattern ) ] <EOL> environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> svn_info = getoutput ( SVN_INFO % path ) <EOL> info = { } <EOL> item = None <EOL> for line in svn_info . splitlines ( ) : <EOL> if not line : <EOL> continue <EOL> key , value = line . split ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> if key == '<STR_LIT>' : <EOL> if item : <EOL> item [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> info [ item_path ] = item <EOL> item = { '<STR_LIT>' : value } <EOL> item_path = value <EOL> elif item : <EOL> if key == '<STR_LIT>' : <EOL> item [ '<STR_LIT>' ] = value . replace ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> elif key == '<STR_LIT>' and value == '<STR_LIT>' : <EOL> item = None <EOL> elif key == '<STR_LIT>' : <EOL> item [ '<STR_LIT>' ] = value <EOL> elif key == '<STR_LIT>' : <EOL> date , time , tz = value . split ( ) [ : <NUM_LIT:3> ] <EOL> if tz != '<STR_LIT>' : <EOL> raise ValueError ( <EOL> "<STR_LIT>" % tz <EOL> ) <EOL> item [ '<STR_LIT>' ] = datetime ( * [ <EOL> int ( j ) for i , segment in enumerate ( ( date , time ) ) <EOL> for j in segment . split ( SEPARATORS [ i ] ) <EOL> ] ) <EOL> items = info . items ( ) <EOL> info = { } <EOL> for item_path , item in items : <EOL> if pattern : <EOL> if not fnmatch ( item_path , pattern ) : <EOL> continue <EOL> if '<STR_LIT>' not in item : <EOL> item [ '<STR_LIT>' ] = datetime . utcfromtimestamp ( <EOL> stat ( item_path ) . st_mtime <EOL> ) <EOL> info [ item_path ] = item <EOL> return SVN_CACHE . setdefault ( ( path , pattern ) , info ) <EOL> def get_git_info ( filename , path ) : <EOL> environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> git_info = getoutput ( '<STR_LIT>' % filename ) <EOL> info = { } <EOL> info [ '<STR_LIT>' ] = path <EOL> info [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( not git_info ) or git_info . startswith ( '<STR_LIT>' ) : <EOL> info [ '<STR_LIT>' ] = datetime . utcfromtimestamp ( <EOL> stat ( filename ) . st_mtime <EOL> ) <EOL> return info <EOL> info [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> for line in git_info . splitlines ( ) : <EOL> if line . startswith ( '<STR_LIT>' ) : <EOL> email , timestamp , tz = line . split ( ) [ - <NUM_LIT:3> : ] <EOL> email = email . lstrip ( '<STR_LIT:<>' ) . rstrip ( '<STR_LIT:>>' ) <EOL> if '<STR_LIT:(>' in email : <EOL> email = email . split ( '<STR_LIT:(>' ) [ <NUM_LIT:0> ] . strip ( ) <EOL> info [ '<STR_LIT>' ] = email <EOL> info [ '<STR_LIT>' ] = datetime . utcfromtimestamp ( float ( timestamp ) ) <EOL> break <EOL> return info <EOL> def parse_authors_file ( file ) : <EOL> if file in AUTHORS_CACHE : <EOL> return AUTHORS_CACHE [ file ] <EOL> authors_file = open ( file , '<STR_LIT:rb>' ) <EOL> author = False <EOL> authors = { } <EOL> for line in authors_file . readlines ( ) : <EOL> if line . startswith ( '<STR_LIT:*>' ) : <EOL> if author : <EOL> authors [ author ] = info <EOL> author = line . replace ( '<STR_LIT:*>' , '<STR_LIT>' ) . strip ( ) <EOL> info = [ ] <EOL> elif line . startswith ( '<STR_LIT>' ) : <EOL> break <EOL> elif author : <EOL> line = line . strip ( ) <EOL> if not line : <EOL> continue <EOL> line = line . split ( '<STR_LIT>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] <EOL> if line [ <NUM_LIT:0> ] == '<STR_LIT:\\>' : <EOL> line = line [ <NUM_LIT:1> : ] <EOL> if '<STR_LIT:(>' in line : <EOL> line = line . split ( '<STR_LIT:(>' ) [ <NUM_LIT:0> ] . strip ( ) <EOL> info . append ( line ) <EOL> if author : <EOL> authors [ author ] = info <EOL> return AUTHORS_CACHE . setdefault ( file , authors ) <EOL> def parse_tracker_file ( filename ) : <EOL> if filename in TRACKER_CACHE : <EOL> return TRACKER_CACHE [ filename ] <EOL> info = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : datetime . utcfromtimestamp ( stat ( filename ) . st_mtime ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:title>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> tracker_file = open ( filename , '<STR_LIT:rb>' ) <EOL> tracker_data = tracker_file . read ( ) <EOL> tracker_file . close ( ) <EOL> return { } <EOL> return TRACKER_CACHE . setdefault ( filename , info ) <EOL> def blog ( args ) : <EOL> title = u'<STR_LIT:U+0020>' . join ( args ) <EOL> filename = '<STR_LIT:->' . join ( '<STR_LIT>' . join ( <EOL> ( c . lower ( ) for c in title if ( c . isalnum ( ) or c . isspace ( ) ) ) <EOL> ) . split ( ) ) <EOL> filename = join_path ( output_path , filename + '<STR_LIT>' ) <EOL> if isfile ( filename ) : <EOL> raise IOError ( "<STR_LIT>" % filename ) <EOL> title_length = len ( title ) <EOL> if verbose : <EOL> print "<STR_LIT>" , filename <EOL> article = open ( filename , '<STR_LIT:wb>' ) <EOL> article . write ( '<STR_LIT:=>' * title_length ) <EOL> article . write ( '<STR_LIT:\n>' ) <EOL> article . write ( title ) <EOL> article . write ( '<STR_LIT:\n>' ) <EOL> article . write ( '<STR_LIT:=>' * title_length ) <EOL> article . write ( '<STR_LIT>' % datetime . utcnow ( ) . strftime ( '<STR_LIT>' ) ) <EOL> article . close ( ) <EOL> return filename <EOL> def get_relative_path ( path1 , path2 ) : <EOL> """<STR_LIT>""" <EOL> common , segment1 , segment2 = get_common_path ( <EOL> path1 . split ( SEP ) , path2 . split ( SEP ) , [ ] <EOL> ) <EOL> elements = [ ] <EOL> if segment1 : <EOL> elements . append ( '<STR_LIT>' * ( len ( segment1 ) - <NUM_LIT:1> ) ) <EOL> elements . extend ( segment2 ) <EOL> return join_path ( * elements ) <EOL> def get_common_path ( segment1 , segment2 , common ) : <EOL> if len ( segment1 ) < <NUM_LIT:1> or len ( segment2 ) < <NUM_LIT:1> : <EOL> return ( common , segment1 , segment2 ) <EOL> if segment1 [ <NUM_LIT:0> ] != segment2 [ <NUM_LIT:0> ] : <EOL> return ( common , segment1 , segment2 ) <EOL> return commonpath ( segment1 [ <NUM_LIT:1> : ] , segment2 [ <NUM_LIT:1> : ] , common + [ segment1 [ <NUM_LIT:0> ] ] ) <EOL> def main ( argv , genfiles = None ) : <EOL> op = OptionParser ( ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT:-c>' , dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT:utf-8>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT:html>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT:utf-8>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = HOME , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" ) <EOL> op . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , default = False , action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" ) <EOL> try : <EOL> options , args = op . parse_args ( argv ) <EOL> except SystemExit : <EOL> return <EOL> authors = options . authors <EOL> if authors : <EOL> if not isfile ( authors ) : <EOL> raise IOError ( "<STR_LIT>" % authors ) <EOL> authors = parse_authors_file ( authors ) <EOL> else : <EOL> authors = { } <EOL> email2author = { '<STR_LIT>' : '<STR_LIT>' } <EOL> author2link = { '<STR_LIT>' : '<STR_LIT>' } <EOL> for author , author_info in authors . iteritems ( ) : <EOL> for _info in author_info : <EOL> if _info . startswith ( '<STR_LIT>' ) or _info . startswith ( '<STR_LIT>' ) : <EOL> if author not in author2link : <EOL> author2link [ author ] = _info <EOL> elif '<STR_LIT:@>' in _info : <EOL> email2author [ _info ] = author <EOL> authors [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> output_path = options . output_path . rstrip ( '<STR_LIT:/>' ) <EOL> if not isdir ( output_path ) : <EOL> raise IOError ( "<STR_LIT>" % output_path ) <EOL> root_path = options . root_path <EOL> siteinfo = join_path ( output_path , '<STR_LIT>' ) <EOL> if isfile ( siteinfo ) : <EOL> env = { } <EOL> execfile ( siteinfo , env ) <EOL> siteinfo = env [ '<STR_LIT>' ] <EOL> else : <EOL> siteinfo = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> stdout = sys . stdout if options . stdout else None <EOL> verbose = False if stdout else ( not options . quiet ) <EOL> format = options . format <EOL> if format not in ( '<STR_LIT:html>' , '<STR_LIT>' ) : <EOL> raise ValueError ( "<STR_LIT>" % format ) <EOL> if ( format == '<STR_LIT>' ) or ( not options . template ) : <EOL> template = False <EOL> elif not isfile ( options . template ) : <EOL> raise IOError ( "<STR_LIT>" % options . template ) <EOL> else : <EOL> template_path = abspath ( options . template ) <EOL> template_root = dirname ( template_path ) <EOL> template_loader = TemplateLoader ( [ template_root ] ) <EOL> template_file = open ( template_path , '<STR_LIT:rb>' ) <EOL> template = MarkupTemplate ( <EOL> template_file . read ( ) , loader = template_loader , encoding = '<STR_LIT:utf-8>' <EOL> ) <EOL> template_file . close ( ) <EOL> data_file = options . data_file <EOL> if data_file : <EOL> if isfile ( data_file ) : <EOL> data_file_obj = open ( data_file , '<STR_LIT:rb>' ) <EOL> data_dict = load_pickle ( data_file_obj ) <EOL> data_file_obj . close ( ) <EOL> else : <EOL> data_dict = { } <EOL> input_encoding = options . input_encoding <EOL> output_encoding = options . output_encoding <EOL> if genfiles : <EOL> files = genfiles <EOL> elif options . package : <EOL> package_root = options . package <EOL> files = [ ] <EOL> add_file = files . append <EOL> package = None <EOL> for part in reversed ( package_root . split ( SEP ) ) : <EOL> if part : <EOL> package = part <EOL> break <EOL> if package is None : <EOL> raise ValueError ( "<STR_LIT>" % package_root ) <EOL> for dirpath , dirnames , filenames in walk ( package_root ) : <EOL> for filename in filenames : <EOL> if not filename . endswith ( '<STR_LIT>' ) : <EOL> continue <EOL> filename = join_path ( dirpath , filename ) <EOL> module = package + filename [ len ( package_root ) : ] <EOL> if module . endswith ( '<STR_LIT>' ) : <EOL> module = module [ : - <NUM_LIT:12> ] <EOL> else : <EOL> module = module [ : - <NUM_LIT:3> ] <EOL> module = '<STR_LIT:.>' . join ( module . split ( SEP ) ) <EOL> module_file = open ( filename , '<STR_LIT:rb>' ) <EOL> module_source = module_file . read ( ) <EOL> module_file . close ( ) <EOL> docstring = docstring_regex . search ( module_source ) <EOL> if docstring : <EOL> docstring = docstring . group ( <NUM_LIT:0> ) <EOL> if docstring . startswith ( '<STR_LIT:r>' ) : <EOL> docstring = docstring [ <NUM_LIT:4> : - <NUM_LIT:3> ] <EOL> else : <EOL> docstring = docstring [ <NUM_LIT:3> : - <NUM_LIT:3> ] <EOL> if docstring and docstring . strip ( ) . startswith ( '<STR_LIT>' ) : <EOL> docstring = strip_leading_indent ( docstring ) <EOL> module_source = docstring_regex . sub ( '<STR_LIT>' , module_source , <NUM_LIT:1> ) <EOL> else : <EOL> docstring = '<STR_LIT>' <EOL> info = { } <EOL> if root_path and isabs ( filename ) and filename . startswith ( root_path ) : <EOL> info [ '<STR_LIT>' ] = filename [ len ( root_path ) + <NUM_LIT:1> : ] <EOL> else : <EOL> info [ '<STR_LIT>' ] = filename <EOL> info [ '<STR_LIT>' ] = datetime . utcfromtimestamp ( <EOL> stat ( filename ) . st_mtime <EOL> ) <EOL> info [ '<STR_LIT>' ] = output_path <EOL> info [ '<STR_LIT>' ] = '<STR_LIT>' + module <EOL> info [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> info [ '<STR_LIT>' ] = module <EOL> info [ '<STR_LIT>' ] = highlight ( module_source , PythonLexer ( ) , SYNTAX_FORMATTER ) <EOL> add_file ( ( docstring , '<STR_LIT>' , info ) ) <EOL> else : <EOL> files = [ ] <EOL> add_file = files . append <EOL> for filename in args : <EOL> if not isfile ( filename ) : <EOL> raise IOError ( "<STR_LIT>" % filename ) <EOL> if root_path and isabs ( filename ) and filename . startswith ( root_path ) : <EOL> path = filename [ len ( root_path ) + <NUM_LIT:1> : ] <EOL> else : <EOL> path = filename <EOL> info = get_git_info ( filename , path ) <EOL> source_file = open ( filename , '<STR_LIT:rb>' ) <EOL> source = source_file . read ( ) <EOL> source_file . close ( ) <EOL> if MORE_LINE in source : <EOL> source_lead = source . split ( MORE_LINE ) [ <NUM_LIT:0> ] <EOL> source = source . replace ( MORE_LINE , '<STR_LIT>' ) <EOL> else : <EOL> source_lead = '<STR_LIT>' <EOL> filebase , filetype = splitext ( basename ( filename ) ) <EOL> info [ '<STR_LIT>' ] = output_path <EOL> info [ '<STR_LIT>' ] = filebase . lower ( ) <EOL> info [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> info [ '<STR_LIT>' ] = filebase . replace ( '<STR_LIT:->' , '<STR_LIT:U+0020>' ) <EOL> add_file ( ( source , source_lead , info ) ) <EOL> for source , source_lead , info in files : <EOL> if verbose : <EOL> print <EOL> print LINE <EOL> print '<STR_LIT>' % ( <EOL> info [ '<STR_LIT>' ] , info [ '<STR_LIT>' ] , split_path ( output_path ) [ <NUM_LIT:1> ] <EOL> ) <EOL> print LINE <EOL> print <EOL> if template : <EOL> output , props = render_rst ( <EOL> source , format , input_encoding , True <EOL> ) <EOL> info [ '<STR_LIT>' ] = output . encode ( output_encoding ) <EOL> info . update ( props ) <EOL> if source_lead : <EOL> info [ '<STR_LIT>' ] = render_rst ( <EOL> source_lead , format , input_encoding , True <EOL> ) [ <NUM_LIT:0> ] . encode ( output_encoding ) <EOL> output = template . generate ( <EOL> content = output , <EOL> info = info , <EOL> authors = authors , <EOL> email2author = email2author , <EOL> author2link = author2link , <EOL> ** siteinfo <EOL> ) . render ( '<STR_LIT>' , encoding = output_encoding ) <EOL> else : <EOL> output , props = render_rst ( <EOL> source , format , input_encoding , True , as_whole = True <EOL> ) <EOL> info . update ( props ) <EOL> output = output . encode ( output_encoding ) <EOL> info [ '<STR_LIT>' ] = output <EOL> if source_lead : <EOL> info [ '<STR_LIT>' ] = render_rst ( <EOL> source_lead , format , input_encoding , True , as_whole = True <EOL> ) [ <NUM_LIT:0> ] . encode ( output_encoding ) <EOL> if data_file : <EOL> data_dict [ info [ '<STR_LIT>' ] ] = info <EOL> if stdout : <EOL> print output <EOL> else : <EOL> output_filename = join_path ( <EOL> output_path , '<STR_LIT>' % ( info [ '<STR_LIT>' ] , format ) <EOL> ) <EOL> output_file = open ( output_filename , '<STR_LIT:wb>' ) <EOL> output_file . write ( output ) <EOL> output_file . close ( ) <EOL> if verbose : <EOL> print '<STR_LIT>' <EOL> if data_file : <EOL> data_file_obj = open ( data_file , '<STR_LIT:wb>' ) <EOL> dump_pickle ( data_dict , data_file_obj ) <EOL> data_file_obj . close ( ) <EOL> if options . pattern : <EOL> pattern = options . pattern <EOL> items = [ <EOL> item <EOL> for item in data_dict . itervalues ( ) <EOL> if item [ '<STR_LIT>' ] == pattern <EOL> ] <EOL> import json <EOL> index_js_template = join_path ( output_path , '<STR_LIT>' ) <EOL> if isfile ( index_js_template ) : <EOL> index_json = json . dumps ( [ <EOL> [ _art [ '<STR_LIT>' ] , _art [ '<STR_LIT:title>' ] . encode ( '<STR_LIT:utf-8>' ) ] <EOL> for _art in sorted ( <EOL> [ item for item in items if item . get ( '<STR_LIT>' ) and <EOL> item . get ( '<STR_LIT>' , '<STR_LIT>' ) == '<STR_LIT>' ] , <EOL> key = lambda i : i [ '<STR_LIT>' ] <EOL> ) <EOL> ] ) <EOL> index_js_template = open ( index_js_template , '<STR_LIT:rb>' ) . read ( ) <EOL> index_js = open ( join_path ( output_path , '<STR_LIT>' ) , '<STR_LIT:wb>' ) <EOL> index_js . write ( index_js_template % index_json ) <EOL> index_js . close ( ) <EOL> for name , mode , format in INDEX_FILES : <EOL> pname = name . split ( '<STR_LIT:.>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> template_file = None <EOL> if siteinfo [ '<STR_LIT>' ] : <EOL> template_path = join_path ( <EOL> template_root , '<STR_LIT>' % ( pname , siteinfo [ '<STR_LIT>' ] ) <EOL> ) <EOL> if isfile ( template_path ) : <EOL> template_file = open ( template_path , '<STR_LIT:rb>' ) <EOL> if not template_file : <EOL> template_path = join_path ( template_root , '<STR_LIT>' % pname ) <EOL> template_file = open ( template_path , '<STR_LIT:rb>' ) <EOL> page_template = MarkupTemplate ( <EOL> template_file . read ( ) , loader = template_loader , encoding = '<STR_LIT:utf-8>' <EOL> ) <EOL> template_file . close ( ) <EOL> poutput = page_template . generate ( <EOL> items = items [ : ] , <EOL> authors = authors , <EOL> email2author = email2author , <EOL> author2link = author2link , <EOL> root_path = output_path , <EOL> ** siteinfo <EOL> ) . render ( format ) <EOL> poutput = unicode ( poutput , output_encoding ) <EOL> if mode : <EOL> output = template . generate ( <EOL> alternative_content = poutput , <EOL> authors = authors , <EOL> ** siteinfo <EOL> ) . render ( format ) <EOL> else : <EOL> output = poutput <EOL> if isinstance ( output , unicode ) : <EOL> output = output . encode ( output_encoding ) <EOL> output_file = open ( join_path ( output_path , name ) , '<STR_LIT:wb>' ) <EOL> output_file . write ( output ) <EOL> output_file . close ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
