/usr/lib/python2.7/dist-packages/_paver_ext/paver_consume_args.py is in python-parse-type 0.3.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # -*- coding: utf-8 -*-
"""
"""
class Cmdline(object):
"""
Simplify to process consuming args of a task w/o specifying the command line.
Splits up into options and args.
SPECIFICATION:
* An option starts with a dash ('-') or dashdash ('--').
* If an option has a value long options should be used, like:
--my-long-option=value
EXAMPLE:
@task
@consume_args
def hello(args):
cmdline = Cmdline.consume(args, default_args=options.default_args)
...
"""
def __init__(self, args=None, options=None):
self.args = args or []
self.options = options or []
def join_args(self, separator=" "):
return separator.join(self.args)
def join_options(self, separator=" "):
return separator.join(self.options)
@classmethod
def consume(cls, args, default_args=None, default_options=None):
args_ = []
options_ = []
for arg in args:
if arg.startswith("-"):
options_.append(arg)
else:
args_.append(arg)
if not args_:
args_ = default_args
if not options_:
options_ = default_options
return cls(args_, options_)
|