Commit 33bbaf49 authored by Vincent Pelletier's avatar Vincent Pelletier

Allow specifying multiple bases per argument.

Also, rename storage to be easier to understand in --help output.
parent 6e829ee5
......@@ -352,13 +352,15 @@ class AggregateSiteUrl(argparse.Action):
}
def __call__(self, parser, namespace, values, option_string=None):
action = self.__argument_to_aggregator[option_string]
if action is not None:
if values[-1:] == '/':
offset = -1
else:
offset = 0
action = partial(action, prefix=values.count('/') + offset)
getattr(namespace, self.dest).append((values, action))
dest = getattr(namespace, self.dest)
for value in values:
if action is not None:
if value[-1:] == '/':
offset = -1
else:
offset = 0
action = partial(action, prefix=value.count('/') + offset)
dest.append((value, action))
def _asDayString(timestamp):
dt, tz = timestamp.split(' ')
......@@ -388,15 +390,15 @@ def main():
help='Include detailed report (url & referers) for error statuses.')
parser.add_argument('-d', '--default',
help='Caption for lines matching no prefix, or skip them if not provided.')
parser.add_argument('--base', dest='site_list', default=[],
parser.add_argument('--base', dest='path', default=[], nargs='+',
action=AggregateSiteUrl,
help='Absolute base url of some part of a site (see also '
'--erp5-base).')
parser.add_argument('--erp5-base', dest='site_list',
parser.add_argument('--erp5-base', dest='path', nargs='+',
action=AggregateSiteUrl,
help='Absolute base url of some part of an ERP5 site (extra '
'stats).')
parser.add_argument('--skip-base', dest='site_list',
parser.add_argument('--skip-base', dest='path', nargs='+',
action=AggregateSiteUrl,
help='Absolute base url to ignore.')
parser.add_argument('-l', '--logformat',
......@@ -440,7 +442,7 @@ def main():
matchline = re.compile(line_regex).match
matchrequest = REQUEST_PATTERN.match
asDate, decimator = period_parser[args.period]
site_list = args.site_list
site_list = args.path
default_site = args.default
if default_site is None:
default_action = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment