1 |
commit: 8b3a2bcf2b3f49a6b1a29ff76c2242e0e99a8c0f |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun May 29 17:45:45 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun May 29 17:45:45 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=8b3a2bcf |
7 |
|
8 |
Use argv in main()/_start() instead of __init__(). |
9 |
|
10 |
--- |
11 |
PMSTestSuite/cli.py | 10 ++++------ |
12 |
ebuild-generator | 12 ++++-------- |
13 |
2 files changed, 8 insertions(+), 14 deletions(-) |
14 |
|
15 |
diff --git a/PMSTestSuite/cli.py b/PMSTestSuite/cli.py |
16 |
index a0d957c..746d9f8 100644 |
17 |
--- a/PMSTestSuite/cli.py |
18 |
+++ b/PMSTestSuite/cli.py |
19 |
@@ -25,16 +25,13 @@ class PMSTestSuiteCLI(object): |
20 |
- repository (EbuildRepository). |
21 |
""" |
22 |
|
23 |
- def __init__(self, prog): |
24 |
+ def __init__(self): |
25 |
""" |
26 |
Initialize the class. Set the option parser up. |
27 |
|
28 |
<prog> - program name for optparse output (argv[0]) |
29 |
""" |
30 |
- opt = OptionParser( |
31 |
- prog = os.path.basename(prog), |
32 |
- version = PV |
33 |
- ) |
34 |
+ opt = OptionParser(version = PV) |
35 |
|
36 |
# XXX: -r for getting through PM's repo_name |
37 |
opt.add_option('-R', '--repository-path', dest='repo_path', |
38 |
@@ -49,7 +46,7 @@ class PMSTestSuiteCLI(object): |
39 |
|
40 |
self.optparser = opt |
41 |
|
42 |
- def _start(self, args): |
43 |
+ def _start(self, prog, *args): |
44 |
""" |
45 |
Initialize the program. Parse command-line args. Instantiate classes |
46 |
encapsulating the Package Manager, test library and repository. |
47 |
@@ -57,6 +54,7 @@ class PMSTestSuiteCLI(object): |
48 |
<args> - command line args (argv[1:]) |
49 |
""" |
50 |
opt = self.optparser |
51 |
+ opt.prog = os.path.basename(prog) |
52 |
(opts, args) = opt.parse_args(list(args)) |
53 |
|
54 |
if not opts.repo_path: |
55 |
|
56 |
diff --git a/ebuild-generator b/ebuild-generator |
57 |
index 94b227a..caac6ba 100755 |
58 |
--- a/ebuild-generator |
59 |
+++ b/ebuild-generator |
60 |
@@ -8,12 +8,8 @@ import sys |
61 |
from PMSTestSuite.cli import PMSTestSuiteCLI |
62 |
|
63 |
class EbuildGenCLI(PMSTestSuiteCLI): |
64 |
- def __init__(self, prog, *args): |
65 |
- PMSTestSuiteCLI.__init__(self, prog) |
66 |
- self._args = args |
67 |
- |
68 |
- def main(self): |
69 |
- self._start(self._args) |
70 |
+ def main(self, argv): |
71 |
+ self._start(*argv) |
72 |
|
73 |
files = {} |
74 |
for t in self.test_library: |
75 |
@@ -25,5 +21,5 @@ class EbuildGenCLI(PMSTestSuiteCLI): |
76 |
return 0 |
77 |
|
78 |
if __name__ == '__main__': |
79 |
- cli = EbuildGenCLI(*sys.argv) |
80 |
- sys.exit(cli.main()) |
81 |
+ cli = EbuildGenCLI() |
82 |
+ sys.exit(cli.main(sys.argv)) |