djblets.util.compat.django.core.management.base¶
Compatibility module for management commands.
-
class
OptionParserWrapper
(parser)[source]¶ Bases:
object
Compatibility wrapper for OptionParser.
This exports a more modern
ArgumentParser
-based API forOptionParser
, for use when adding arguments in management commands. This only contains a subset of the functionality ofArgumentParser
.-
__init__
(parser)[source]¶ Initialize the wrapper.
Parameters: parser (optparse.OptionParser) – The option parser.
-
add_argument
(*args, **kwargs)[source]¶ Add an argument to the parser.
This is a simple wrapper that provides compatibility with most of
argparse.ArgumentParser.add_argument()
. It supports the types thatoptparse.OptionParser.add_option()
supports (though those types should be passed as the primitive types and not as the string names).Parameters: - *args (tuple) – Positional arguments to pass to
optparse.OptionParser.add_option()
. - **kwargs (dict) – Keyword arguments to pass to
optparse.OptionParser.add_option()
.
- *args (tuple) – Positional arguments to pass to
-
-
class
BaseCommand
(stdout=None, stderr=None, no_color=False)[source]¶ Bases:
django.core.management.base.BaseCommand
Base command compatible with a range of Django versions.
This is a version of
django.core.management.base.BaseCommand
that supports the modern way of adding arguments while retaining compatibility with older versions of Django. See the parent class’s documentation for details on usage.-
__getattribute__
(name)[source]¶ Return an attribute from the command.
If the attribute name is “option_list”, some special work will be done to ensure we’re returning a valid list that the caller can work with, even if the options were created in
add_arguments()
.Parameters: name (unicode) – The attribute name. Returns: The attribute value. Return type: object
-