<s> import os <EOL> import re <EOL> import subprocess <EOL> import sys <EOL> import mistune <EOL> CURRENT_DIRECTORY = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> """<STR_LIT>""" <EOL> res = subprocess . check_output ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> if "<STR_LIT>" not in res : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def get_path ( filename ) : <EOL> return os . path . join ( CURRENT_DIRECTORY , "<STR_LIT:..>" , "<STR_LIT>" , "<STR_LIT>" % filename ) <EOL> readme_path = os . path . join ( CURRENT_DIRECTORY , "<STR_LIT:..>" , "<STR_LIT>" ) <EOL> with open ( readme_path , '<STR_LIT:r>' ) as readme_file : <EOL> readme = readme_file . read ( ) <EOL> for filename , title_begin , title_end in ( <EOL> ( "<STR_LIT:index>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ) : <EOL> with open ( get_path ( filename ) , '<STR_LIT:r>' ) as f : <EOL> raw = f . read ( ) <EOL> cropped = "<STR_LIT:\n>" . join ( raw . split ( "<STR_LIT:\n>" ) [ <NUM_LIT:2> : ] ) <EOL> readme = re . sub ( <EOL> "<STR_LIT>" % ( title_begin , title_end ) , <EOL> r"<STR_LIT>" % cropped , <EOL> readme , <EOL> flags = re . MULTILINE | re . DOTALL <EOL> ) <EOL> with open ( readme_path , '<STR_LIT:w>' ) as readme_file : <EOL> readme_file . write ( readme ) <EOL> subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> raw = "<STR_LIT>" <EOL> for filename in [ "<STR_LIT:index>" , "<STR_LIT>" , "<STR_LIT>" ] : <EOL> with open ( get_path ( filename ) , '<STR_LIT:r>' ) as f : <EOL> raw += f . read ( ) <EOL> raw += "<STR_LIT>" <EOL> subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> html = mistune . markdown ( raw ) <EOL> index_path = os . path . join ( "<STR_LIT>" ) <EOL> with open ( index_path , '<STR_LIT:r>' ) as index_file : <EOL> index = index_file . read ( ) <EOL> index = re . sub ( <EOL> r"<STR_LIT>" , <EOL> r"<STR_LIT>" % html , <EOL> index , <EOL> flags = re . MULTILINE | re . DOTALL <EOL> ) <EOL> with open ( index_path , '<STR_LIT:w>' ) as index_file : <EOL> index_file . write ( index ) <EOL> subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> subprocess . call ( [ "<STR_LIT>" , "<STR_LIT>" ] ) </s>
