#NEWLINE# def main( ) : #NEWLINE# #INDENT# my_format = '%(levelname)s\t%(message)s' #NEWLINE# stderr_handler = logging . StreamHandler ( sys . stderr ) #NEWLINE# stderr_handler . setFormatter ( logging . Formatter ( my_format ) ) #NEWLINE# stderr_handler . setLevel ( logging . WARNING ) #NEWLINE# stdout_handler = logging . StreamHandler ( sys . stdout ) #NEWLINE# stdout_handler . setFormatter ( logging . Formatter ( my_format ) ) #NEWLINE# stdout_handler . setLevel ( logging . DEBUG ) #NEWLINE# stdout_handler . addFilter ( LessThanLevelFilter ( logging . WARNING ) ) #NEWLINE# LOGGER . addHandler ( stderr_handler ) #NEWLINE# LOGGER . addHandler ( stdout_handler ) #NEWLINE# parser = argparse . ArgumentParser ( description = ( 'Record and restore the state of your ' + 'openFrameworks projects and archive their files.' ) ) #NEWLINE# parent_parser = argparse . ArgumentParser ( add_help = False ) #NEWLINE# parent_parser . add_argument ( '-p' , '--project' , default = os . getcwd ( ) , help = ( ( 'Path to the desired project directory,' + ' defaults to the current directory if' ) + ' this option is not given' ) ) #NEWLINE# parent_parser . add_argument ( '-n' , '--name' , help = ( 'Name of the desired snapshot. Defaults ' + 'to "latest", except when using list.' ) ) #NEWLINE# parent_parser . add_argument ( '-v' , '--verbose' , action = 'store_true' , help = 'Switch on debug logging.' ) #NEWLINE# subparsers = parser . add_subparsers ( help = 'Available commands' ) #NEWLINE# record_parser = subparsers . add_parser ( 'record' , help = ( ( 'Record the state of all ' + 'relevant components into a ' ) + 'snapshot' ) , parents = [ parent_parser ] ) #NEWLINE# record_parser . add_argument ( '-u' , '--update' , action = 'store_true' , help = ( 'If name already exists, ' + 'overwrite existing entry' ) ) #NEWLINE# record_parser . add_argument ( '-d' , '--description' , default = '' , help = ( ( ( 'Short message describing the snapshot ' + 'in more detail than the name. Do not ' ) + 'forget " " around DESCRIPTION if it ' ) + 'contains whitespace.' ) ) #NEWLINE# record_parser . set_defaults ( func = record ) #NEWLINE# checkout_parser = subparsers . add_parser ( 'checkout' , help = ( ( 'Check out the complete ' + 'named or latest snapshot ' ) + 'of your project and OF' ) , parents = [ parent_parser ] ) #NEWLINE# checkout_parser . set_defaults ( func = checkout ) #NEWLINE# archive_parser = subparsers . add_parser ( 'archive' , help = ( ( 'Archive all relevant ' + 'components for the named or' ) + ' latest snapshot' ) , parents = [ parent_parser ] ) #NEWLINE# archive_parser . set_defaults ( func = archive ) #NEWLINE# list_parser = subparsers . add_parser ( 'list' , help = ( ( 'List available snapshots. -n ' + 'gives more detailed info about' ) + ' named snapshot' ) , parents = [ parent_parser ] ) #NEWLINE# list_parser . set_defaults ( func = list_command ) #NEWLINE# args = parser . parse_args ( ) #NEWLINE# if ( not args . name ) : #NEWLINE# #INDENT# setattr ( args , 'name' , 'latest' ) #NEWLINE# setattr ( args , 'name_was_given' , False ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( args , 'name_was_given' , True ) #NEWLINE# #UNINDENT# if ( args . verbose is True ) : #NEWLINE# #INDENT# LOGGER . setLevel ( logging . DEBUG ) #NEWLINE# my_format = '%(levelname)s\t%(funcName)s: %(message)s' #NEWLINE# stdout_handler . setFormatter ( logging . Formatter ( my_format ) ) #NEWLINE# stderr_handler . setFormatter ( logging . Formatter ( my_format ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOGGER . setLevel ( logging . INFO ) #NEWLINE# #UNINDENT# LOGGER . debug ( args ) #NEWLINE# metadata_filename = 'metadata.json' #NEWLINE# LOGGER . debug ( ( 'Metadata filename: ' + metadata_filename ) ) #NEWLINE# LOGGER . info ( 'Start processing.' ) #NEWLINE# ret = args . func ( args , metadata_filename ) #NEWLINE# if ( ret != 0 ) : #NEWLINE# #INDENT# LOGGER . critical ( 'An error occurred! Aborting execution.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOGGER . info ( 'Successfully finished processing!' ) #NEWLINE# #UNINDENT# logging . shutdown ( ) #NEWLINE# return ret