Files
deb-python-requestbuilder/requestbuilder/util.py
Garrett Holmstrom a4f8ed4277 Gather args from services and auth handlers
This change allows services and auth handlers to specify their own ARGS
lists that requests can then gather and feed into the ArgumentParsers
they create.  Arg routes are now actual objects (or for declarative use,
attrgetters) as opposed to magic values.  Requests needing to call other
requests can re-use their own service objects to propagate the args that
the latter gathered from the command line.

Configuration files are parsed much earlier than they used to be and can
now cause BaseCommand.__init__() to fail.  BaseCommand.run() handles
this.

Config objects gained the concept of a "current" region and user, which
services can set as they parse their command line args.  These values
are used as defaults when one goes to look up options.

BaseCommand.DEFAULT_ROUTE is now an attribute/property, default_route.

BaesCommand.print_result is now a noop.  Define it yourself if you need
a tool to output something during that step.

BaseRequest.ACTION is now BaseRequest.NAME.

This change breaks a large number of internal APIs.  Docstrings are
horribly out of date at this point and should be fixed fairly soon in a
future commit.
2013-02-01 22:51:47 -08:00

24 lines
1.1 KiB
Python

# Copyright (c) 2013, Eucalyptus Systems, Inc.
#
# Permission to use, copy, modify, and/or distribute this software for
# any purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
def aggregate_subclass_fields(cls, field_name):
values = []
# pylint doesn't know about classes' built-in mro() method
# pylint: disable-msg=E1101
for m_class in cls.mro():
# pylint: enable-msg=E1101
if field_name in vars(m_class):
values.extend(getattr(m_class, field_name))
return values