launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12998
[Merge] lp:~jtv/maas/maascli-command-breakout into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/maascli-command-breakout into lp:maas.
Commit message:
Preparatory cleanup: move maascli Command class out into its own module.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/maascli-command-breakout/+merge/128159
I'm making some structural changes to maascli. The work's complicated slightly by some incestuous import relationships involving __init__.py. It's one of those reasons why it's not very nice to have lots of code in __init__.py. Here I extract some of that code to a separate module, which gives me a bit more freedom to move other things about. Doing this in my other branch would incur disproportionate diff bloat.
With this isolated branch I can say simply that the code does not change. It just moves. The __all__ was bogus before, so I'm fixing that as well.
Jeroen
--
https://code.launchpad.net/~jtv/maas/maascli-command-breakout/+merge/128159
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/maascli-command-breakout into lp:maas.
=== modified file 'src/maascli/__init__.py'
--- src/maascli/__init__.py 2012-10-04 08:11:17 +0000
+++ src/maascli/__init__.py 2012-10-05 04:50:23 +0000
@@ -11,15 +11,9 @@
__metaclass__ = type
__all__ = [
- "Command",
- "CommandError",
- "register",
+ "main",
]
-from abc import (
- ABCMeta,
- abstractmethod,
- )
import argparse
import locale
import sys
@@ -76,26 +70,6 @@
parser.error("%s" % error)
-class Command:
- """A base class for composing commands.
-
- This adheres to the expectations of `register`.
- """
-
- __metaclass__ = ABCMeta
-
- def __init__(self, parser):
- super(Command, self).__init__()
- self.parser = parser
-
- @abstractmethod
- def __call__(self, options):
- """Execute this command."""
-
-
-CommandError = SystemExit
-
-
def register(module, parser, prefix="cmd_"):
"""Register commands in `module` with the given argument parser.
=== modified file 'src/maascli/api.py'
--- src/maascli/api.py 2012-10-04 20:05:30 +0000
+++ src/maascli/api.py 2012-10-05 04:50:23 +0000
@@ -33,7 +33,7 @@
from apiclient.multipart import encode_multipart_data
from apiclient.utils import ascii_url
import httplib2
-from maascli import (
+from maascli.command import (
Command,
CommandError,
)
=== added file 'src/maascli/command.py'
--- src/maascli/command.py 1970-01-01 00:00:00 +0000
+++ src/maascli/command.py 2012-10-05 04:50:23 +0000
@@ -0,0 +1,41 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Command-related classes."""
+
+from __future__ import (
+ absolute_import,
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+__all__ = [
+ 'Command',
+ 'CommandError',
+ ]
+
+from abc import (
+ ABCMeta,
+ abstractmethod,
+ )
+
+
+class Command:
+ """A base class for composing commands.
+
+ This adheres to the expectations of `register`.
+ """
+
+ __metaclass__ = ABCMeta
+
+ def __init__(self, parser):
+ super(Command, self).__init__()
+ self.parser = parser
+
+ @abstractmethod
+ def __call__(self, options):
+ """Execute this command."""
+
+
+CommandError = SystemExit
=== modified file 'src/maascli/tests/test_api.py'
--- src/maascli/tests/test_api.py 2012-10-04 20:05:30 +0000
+++ src/maascli/tests/test_api.py 2012-10-05 04:50:23 +0000
@@ -20,10 +20,8 @@
from apiclient.creds import convert_tuple_to_string
import httplib2
-from maascli import (
- api,
- CommandError,
- )
+from maascli import api
+from maascli.command import CommandError
from maastesting.factory import factory
from maastesting.testcase import TestCase
from mock import sentinel