#NEWLINE# def main( ) : #NEWLINE# #INDENT# global config #NEWLINE# parser = argparse . ArgumentParser ( description = 'Generate a simple HTML diary' ) #NEWLINE# parser . add_argument ( 'config' , help = 'Path to config file' ) #NEWLINE# parser . add_argument ( '-d' , '--debug' , action = 'store_true' ) #NEWLINE# args = parser . parse_args ( ) #NEWLINE# if args . debug : #NEWLINE# #INDENT# logging . basicConfig ( level = logging . DEBUG ) #NEWLINE# logging . debug ( 'Debugging enabled' ) #NEWLINE# #UNINDENT# config = configparser . RawConfigParser ( ) #NEWLINE# config . read ( args . config ) #NEWLINE# try : #NEWLINE# #INDENT# for check in [ 'input' , 'output_dir' , 'title' , 'author_name' , 'site_root' ] : #NEWLINE# #INDENT# val = config . get ( 'rstdiary' , check ) #NEWLINE# logging . debug ( ( 'config: %s=%s' % ( check , val ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# except configparser . NoOptionError : #NEWLINE# #INDENT# sys . stderr . write ( ( "Config file doesn't contain: %s\n" % check ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# except configparser . NoSectionError : #NEWLINE# #INDENT# sys . stderr . write ( "Config file doesn't contain section [rstdiary]\n" ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# if ( not os . path . isdir ( config . get ( 'rstdiary' , 'output_dir' ) ) ) : #NEWLINE# #INDENT# sys . stderr . write ( ( 'output_dir <%s>: not a directory\n' % output_dir ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# input_filename = config . get ( 'rstdiary' , 'input' ) #NEWLINE# logging . debug ( ( 'input_filename = %s' % val ) ) #NEWLINE# if ( not os . path . isfile ( input_filename ) ) : #NEWLINE# #INDENT# sys . stderr . write ( ( 'Invalid input: %s\n' % input_filename ) ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# parse_entries ( input_filename ) #NEWLINE# write_html ( ) #NEWLINE# write_atom ( )