diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-03-26 08:25:27 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-03-26 08:25:27 +0200 |
commit | 567672be7bef7dcbecf70589dddbe6e193588475 (patch) | |
tree | f1d526c7709a5fce2d01c9574583db21c0be2266 /skeletons/opt_parse.py.erb | |
parent | 1e2061952df01fe87209156062e060fb69e19ed8 (diff) | |
download | vim-567672be7bef7dcbecf70589dddbe6e193588475.zip vim-567672be7bef7dcbecf70589dddbe6e193588475.tar.gz |
add skeletons
Diffstat (limited to 'skeletons/opt_parse.py.erb')
-rw-r--r-- | skeletons/opt_parse.py.erb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/skeletons/opt_parse.py.erb b/skeletons/opt_parse.py.erb new file mode 100644 index 0000000..658f9c0 --- /dev/null +++ b/skeletons/opt_parse.py.erb @@ -0,0 +1,60 @@ +<%= header 'python.hdr' %> + +""" Module Description """ + +#---------------------------------------------------------------------------- + +__version__ = '0.1.0' + +#---------------------------------------------------------------------------- + +#import + +#---------------------------------------------------------------------------- + +__all__ = [ + '<%= @filename_base %>' + ] + +#---------------------------------------------------------------------------- +class <%= @filename_base %>: + + def __init__( self, parser, options ): + self.parser = parser + self.options = options + +#---------------------------------------------------------------------------- +def my_callback( option, opt, value, parser ): + print "option : %s" % option + print "opt : %s" % opt + print "value : %s" % value + print "parser : %s" % parser + +#---------------------------------------------------------------------------- +def main( ): + from optparse import OptionParser + parser = OptionParser( usage="usage : %prog [-h] [-v]", version= "%prog version " + __version__ ) +# action store store_true store_false store_const append count callback help +# type string int long choice float complex +# dest action="store*" +# default +# nargs int +# const action="store_const" +# choices +# callback +# callback_args +# callback_kwargs +# help help tring +# metavar + parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="produces noisy outputs." ) + parser.add_option("-c", "--callback", action="callback", callback=my_callback, help="print callback args" ) + parser.add_option("-s", "--string", action="store", type="string", dest="string", help="memorize a string" ) + ( options, args) = parser.parse_args( ) + print 'verbose : %s' % options.verbose + return 0 + +#---------------------------------------------------------------------------- + +if __name__ == '__main__': + import sys + sys.exit( main( ) ) |