1#!/usr/bin/env python 2# -*- Mode: python -*- 3 4# Copyright (C) 2007 Artifex Software Inc. 5# All Rights Reserved. 6# 7# This software is provided AS-IS with no warranty, either express or 8# implied. 9# 10# This software is distributed under license and may not be copied, modified 11# or distributed except as expressly authorized under the terms of that 12# license. Refer to licensing information at http://www.artifex.com/ 13# or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, 14# San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information. 15 16import optparse 17import sys, os 18import types 19 20def parseCommandLineBasic(optionsParser=None,args=sys.argv): 21 optionsParser.add_option('--verbose','-v',action='store_true',help="noisy execution") 22 23 myself=os.path.basename(args[0]) 24 options,arguments=optionsParser.parse_args() 25 options.myself=myself 26 return (options,arguments) 27 28def parseCommandLine(optionsParser=None,args=sys.argv,revisionSkip=False,testfileSkip=False,listfileSkip=False,deviceSkip=False): 29 if not optionsParser: 30 optionsParser=optparse.OptionParser() 31 32 if not testfileSkip: 33 optionsParser.add_option('--testfile','-t',action='store',help="testfile:\"test\"",default="test") 34 35 if not listfileSkip: 36 optionsParser.add_option('--listfile','-l',action='store',help="listfile:\"list\"",default="list") 37 38 if not revisionSkip: 39 optionsParser.add_option('--revision','-e',action='store',help="revision:HEAD",default="HEAD") 40 41 if not deviceSkip: 42 optionsParser.add_option('--device','-d',action='store',help="output device:ppmraw",default="ppmraw") 43 optionsParser.add_option('--resolution','-r',action='store',help="output resolution:300",default="300") 44 optionsParser.add_option('--banding','-b',action='store',help="output banding:False",default=False) 45 46 optionsParser.add_option('--quiet','-q',action='store_true',help="quiet execution") 47 optionsParser.add_option('--verbose','-v',action='store_true',help="noisy execution") 48 49 optionsParser.add_option('--nocleanup','-k',action='store_true',help="do not delete intermediate files") 50 51 myself=os.path.basename(args[0]) 52 options,arguments=optionsParser.parse_args() 53 options.myself=myself 54 return (options,arguments) 55 56if __name__ == "__main__": 57 58 optionsParser=optparse.OptionParser() 59 optionsParser.add_option('--option','-o',action='store_true',help="sample additional option") 60 optionsParser.add_option('--nosvn','-s',action='store_true',help="no not update from svn") 61 optionsParser.add_option('--nomake','-m',action='store_true',help="no not make") 62 63 (options,arguments)=myoptparse.parseCommandLine(optionsParser) 64 print options.revision 65 print options.testfile 66 print arguments 67 68# (options,arguments)=parseCommandLine(optionsParser,revisionSkip=True) 69# (options,arguments)=parseCommandLine(optionsParser,revisionSkip=True,testfileSkip=True,listfileSkip=True,deviceSkip=True): 70