# Path: elbepack/pbuilderaction.py
# class PBuilderAction:
#     actiondict = {}
# 
#     @classmethod
#     def register(cls, action):
#         cls.actiondict[action.tag] = action
# 
#     @classmethod
#     def print_actions(cls):
#         print("available subcommands are:", file=sys.stderr)
#         for a in cls.actiondict:
#             print("   %s" % a, file=sys.stderr)
# 
#     def __new__(cls, node):
#         action = cls.actiondict[node]
#         return object.__new__(action)
# 
#     def __init__(self, node):
#         self.node = node
# 
#     def execute(self, _opt, _args):
#         raise NotImplementedError('execute() not implemented')
# 
# class PBuilderError(Exception):
#     def __init__(self, msg):
#         Exception.__init__(self, msg)
# 
# Path: elbepack/xmlpreprocess.py
# class PreprocessWrapper:
#     def __init__(self, xmlfile, opt):
#         self.xmlfile = xmlfile
#         self.outxml = None
#         self.options = ""
# 
#         if opt.variant:
#             self.options += ' --variants "%s"' % opt.variant
# 
#     def __enter__(self):
#         self.outxml = NamedTemporaryFile(prefix='elbe', suffix='xml')
# 
#         cmd = '%s preprocess %s -o %s %s' % (elbe_exe,
#                                              self.options,
#                                              self.outxml.name,
#                                              self.xmlfile)
#         ret, _, err = command_out_stderr(cmd)
#         if ret != 0:
#             print("elbe preprocess failed.", file=sys.stderr)
#             print(err, file=sys.stderr)
#             raise CommandError(cmd, ret)
# 
#         return self
# 
#     def __exit__(self, _typ, _value, _traceback):
#         self.outxml = None
# 
#     @staticmethod
#     def add_options(oparser):
#         # import it here because of cyclic imports
#         # pylint: disable=cyclic-import
#         from elbepack.commands.preprocess import add_pass_through_options
# 
#         group = OptionGroup(oparser,
#                             'Elbe preprocess options',
#                             'Options passed through to invocation of '
#                             '"elbe preprocess"')
#         add_pass_through_options(group)
#         oparser.add_option_group(group)
# 
#     @property
#     def preproc(self):
#         return self.outxml.name


import sys
from optparse import OptionParser
from elbepack.pbuilderaction import PBuilderAction, PBuilderError
from elbepack.xmlpreprocess import PreprocessWrapper

    oparser.add_option("--cross", dest="cross", default=False,
                       action="store_true",
                       help="Creates an environment for crossbuilding if "
                            "combined with create. Combined with build it"
                            " will use this environment.")

    oparser.add_option("--no-ccache", dest="noccache", default=False,
                       action="store_true",
                       help="Deactivates the compiler cache 'ccache'")

    oparser.add_option("--ccache-size", dest="ccachesize", default="10G",
                       action="store", type="string",
                       help="set a limit for the compiler cache size "
                            "(should be a number followed by an optional "
                            "suffix: k, M, G, T. Use 0 for no limit.)")

    PreprocessWrapper.add_options(oparser)

    (opt, args) = oparser.parse_args(argv)

    if not args:
        print("elbe pbuilder - no subcommand given", file=sys.stderr)
        PBuilderAction.print_actions()
        return

    try:
        action = PBuilderAction(args[0])
    except KeyError:
        print("elbe pbuilder - unknown subcommand", file=sys.stderr)

# Path: elbepack/pbuilderaction.py
# class PBuilderAction:
#     actiondict = {}
# 
#     @classmethod
#     def register(cls, action):
#         cls.actiondict[action.tag] = action
# 
#     @classmethod
#     def print_actions(cls):
#         print("available subcommands are:", file=sys.stderr)
#         for a in cls.actiondict:
#             print("   %s" % a, file=sys.stderr)
# 
#     def __new__(cls, node):
#         action = cls.actiondict[node]
#         return object.__new__(action)
# 
#     def __init__(self, node):
#         self.node = node
# 
#     def execute(self, _opt, _args):
#         raise NotImplementedError('execute() not implemented')
# 
# class PBuilderError(Exception):
#     def __init__(self, msg):
#         Exception.__init__(self, msg)
# 
# Path: elbepack/xmlpreprocess.py
# class PreprocessWrapper:
#     def __init__(self, xmlfile, opt):
#         self.xmlfile = xmlfile
#         self.outxml = None
#         self.options = ""
# 
#         if opt.variant:
#             self.options += ' --variants "%s"' % opt.variant
# 
#     def __enter__(self):
#         self.outxml = NamedTemporaryFile(prefix='elbe', suffix='xml')
# 
#         cmd = '%s preprocess %s -o %s %s' % (elbe_exe,
#                                              self.options,
#                                              self.outxml.name,
#                                              self.xmlfile)
#         ret, _, err = command_out_stderr(cmd)
#         if ret != 0:
#             print("elbe preprocess failed.", file=sys.stderr)
#             print(err, file=sys.stderr)
#             raise CommandError(cmd, ret)
# 
#         return self
# 
#     def __exit__(self, _typ, _value, _traceback):
#         self.outxml = None
# 
#     @staticmethod
#     def add_options(oparser):
#         # import it here because of cyclic imports
#         # pylint: disable=cyclic-import
#         from elbepack.commands.preprocess import add_pass_through_options
# 
#         group = OptionGroup(oparser,
#                             'Elbe preprocess options',
#                             'Options passed through to invocation of '
#                             '"elbe preprocess"')
#         add_pass_through_options(group)
#         oparser.add_option_group(group)
# 
#     @property
#     def preproc(self):
#         return self.outxml.name


# Path: elbepack/commands/pbuilder.py
import sys
from optparse import OptionParser
from elbepack.pbuilderaction import PBuilderAction, PBuilderError
from elbepack.xmlpreprocess import PreprocessWrapper


    oparser.add_option("--cross", dest="cross", default=False,
                       action="store_true",
                       help="Creates an environment for crossbuilding if "
                            "combined with create. Combined with build it"
                            " will use this environment.")

    oparser.add_option("--no-ccache", dest="noccache", default=False,
                       action="store_true",
                       help="Deactivates the compiler cache 'ccache'")

    oparser.add_option("--ccache-size", dest="ccachesize", default="10G",
                       action="store", type="string",
                       help="set a limit for the compiler cache size "
                            "(should be a number followed by an optional "
                            "suffix: k, M, G, T. Use 0 for no limit.)")

    PreprocessWrapper.add_options(oparser)

    (opt, args) = oparser.parse_args(argv)

    if not args:
        print("elbe pbuilder - no subcommand given", file=sys.stderr)
        PBuilderAction.print_actions()
        return

    try:
        action = PBuilderAction(args[0])
    except KeyError:
        print("elbe pbuilder - unknown subcommand", file=sys.stderr)

        PBuilderAction.print_actions()