mirror of https://github.com/vitalif/phantomjs
Created yes/no argument action handler to simplify conversion process
Also added type=int to max-disk-cache-size1.4
parent
c90407b615
commit
6a5f3901a3
|
@ -59,13 +59,6 @@ def parseArgs(app, args):
|
||||||
args = arg_data[0]
|
args = arg_data[0]
|
||||||
args.script_args = arg_data[1]
|
args.script_args = arg_data[1]
|
||||||
|
|
||||||
args.disk_cache = False if args.disk_cache == 'no' else True
|
|
||||||
args.ignore_ssl_errors = False if args.ignore_ssl_errors == 'no' else True
|
|
||||||
args.load_images = True if args.load_images == 'yes' else False
|
|
||||||
args.load_plugins = False if args.load_plugins == 'no' else True
|
|
||||||
args.local_to_remote_url_access = False if args.local_to_remote_url_access == 'no' else True
|
|
||||||
args.max_disk_cache_size = int(args.max_disk_cache_size)
|
|
||||||
|
|
||||||
# register an alternative Message Handler
|
# register an alternative Message Handler
|
||||||
messageHandler = MessageHandler(args.verbose)
|
messageHandler = MessageHandler(args.verbose)
|
||||||
qInstallMsgHandler(messageHandler.process)
|
qInstallMsgHandler(messageHandler.process)
|
||||||
|
|
|
@ -50,6 +50,12 @@ license = '''
|
||||||
|
|
||||||
|
|
||||||
def argParser():
|
def argParser():
|
||||||
|
class YesOrNoAction(argparse.Action):
|
||||||
|
'''Converts yes or no arguments to True/False respectively'''
|
||||||
|
def __call__(self, parser, namespace, value, option_string=None):
|
||||||
|
answer = False if value == 'no' else True
|
||||||
|
setattr(namespace, self.dest, answer)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Minimalistic headless WebKit-based JavaScript-driven tool',
|
description='Minimalistic headless WebKit-based JavaScript-driven tool',
|
||||||
usage='%(prog)s [options] script.[js|coffee] [script argument [script argument ...]]',
|
usage='%(prog)s [options] script.[js|coffee] [script argument [script argument ...]]',
|
||||||
|
@ -69,27 +75,27 @@ def argParser():
|
||||||
parser.add_argument('--cookies-file', metavar='/path/to/cookies.txt',
|
parser.add_argument('--cookies-file', metavar='/path/to/cookies.txt',
|
||||||
help='Sets the file name to store the persistent cookies'
|
help='Sets the file name to store the persistent cookies'
|
||||||
)
|
)
|
||||||
parser.add_argument('--disk-cache', default='no',
|
parser.add_argument('--disk-cache', default=False, action=YesOrNoAction,
|
||||||
choices=['yes', 'no'],
|
choices=['yes', 'no'],
|
||||||
help='Enable disk cache (default: %(default)s)'
|
help='Enable disk cache (default: no)'
|
||||||
)
|
)
|
||||||
parser.add_argument('--ignore-ssl-errors', default='no',
|
parser.add_argument('--ignore-ssl-errors', default=False, action=YesOrNoAction,
|
||||||
choices=['yes', 'no'],
|
choices=['yes', 'no'],
|
||||||
help='Ignore SSL errors (default: %(default)s)'
|
help='Ignore SSL errors (default: no)'
|
||||||
)
|
)
|
||||||
parser.add_argument('--load-images', default='yes',
|
parser.add_argument('--load-images', default=True, action=YesOrNoAction,
|
||||||
choices=['yes', 'no'],
|
choices=['yes', 'no'],
|
||||||
help='Load all inlined images (default: %(default)s)'
|
help='Load all inlined images (default: yes)'
|
||||||
)
|
)
|
||||||
parser.add_argument('--load-plugins', default='no',
|
parser.add_argument('--load-plugins', default=False, action=YesOrNoAction,
|
||||||
choices=['yes', 'no'],
|
choices=['yes', 'no'],
|
||||||
help='Load all plugins (i.e. Flash, Silverlight, ...) (default: %(default)s)'
|
help='Load all plugins (i.e. Flash, Silverlight, ...) (default: no)'
|
||||||
)
|
)
|
||||||
parser.add_argument('--local-to-remote-url-access', default='no',
|
parser.add_argument('--local-to-remote-url-access', default=False, action=YesOrNoAction,
|
||||||
choices=['yes', 'no'],
|
choices=['yes', 'no'],
|
||||||
help='Local content can access remote URL (default: %(default)s)'
|
help='Local content can access remote URL (default: no)'
|
||||||
)
|
)
|
||||||
parser.add_argument('--max-disk-cache-size', default=-1, metavar='size',
|
parser.add_argument('--max-disk-cache-size', default=-1, metavar='size', type=int,
|
||||||
help='Limits the size of disk cache (in KB)'
|
help='Limits the size of disk cache (in KB)'
|
||||||
)
|
)
|
||||||
parser.add_argument('--output-encoding', default='System', metavar='encoding',
|
parser.add_argument('--output-encoding', default='System', metavar='encoding',
|
||||||
|
|
Loading…
Reference in New Issue