- Timestamp:
- 03/26/08 00:21:15 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/commandline.py
r3341 r3355 28 28 29 29 from pykota import version 30 from pykota.utils import loginvalidparam 30 from pykota.utils import loginvalidparam, getdefaultcharset 31 31 32 32 def checkandset_pagesize(option, opt, value, optionparser) : … … 74 74 else : 75 75 setattr(optionparser.values, option.dest, value) 76 77 def load_arguments_file(option, opt, value, optionparser) : 78 """Checks if an option argument is comprised between 0.0 included and 100.0 not included, and validates the option if it is the case.""" 79 setattr(optionparser.values, option.dest, value) 80 try : 81 argsfile = open(value.encode(getdefaultcharset(), "replace"), "r") 82 except IOError : 83 loginvalidparam(opt, value, additionalinfo=_("this option will be ignored")) 84 else : 85 arguments = [ l.strip().decode(getdefaultcharset(), "replace") for l in argsfile.readlines() ] 86 argsfile.close() 87 for i in range(len(arguments)) : 88 argi = arguments[i] 89 if argi.startswith('"') and argi.endswith('"') : 90 arguments[i] = argi[1:-1] 91 arguments.reverse() 92 for arg in arguments : 93 optionparser.rargs.insert(0, arg) 76 94 77 95 class PyKotaOptionParser(optparse.OptionParser) : … … 197 215 action="version", 198 216 help=_("show the version number and exit")) 217 self.add_option("-A", "--arguments", 218 action="callback", 219 type="string", 220 dest="argumentsfile", 221 callback=load_arguments_file, 222 help=_("loads additional options and arguments from a file, one per line"))