1 |
commit: 4759a27d5fd878b59201fb48233e066eccf03be2 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Mar 8 00:04:15 2017 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 8 00:04:15 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=4759a27d |
7 |
|
8 |
ekeyword: misc source touchups |
9 |
|
10 |
No functional changes here! |
11 |
|
12 |
src/ekeyword/ekeyword.py | 8 ++++++-- |
13 |
src/ekeyword/ekeyword_unittest.py | 7 +++++++ |
14 |
2 files changed, 13 insertions(+), 2 deletions(-) |
15 |
|
16 |
diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py |
17 |
index 56e284b..6d09001 100755 |
18 |
--- a/src/ekeyword/ekeyword.py |
19 |
+++ b/src/ekeyword/ekeyword.py |
20 |
@@ -99,6 +99,10 @@ def sort_keywords(arches): |
21 |
keywords.append(g) |
22 |
|
23 |
def arch_key(keyword): |
24 |
+ """Callback for python sorting functions |
25 |
+ |
26 |
+ Used to turn a Gentoo keyword into a sortable form. |
27 |
+ """ |
28 |
# Sort independent of leading marker (~ or -). |
29 |
arch = keyword_to_arch(keyword) |
30 |
|
31 |
@@ -306,8 +310,8 @@ def process_ebuild(ebuild, ops, arch_status=None, verbose=0, quiet=0, |
32 |
dry_run: Do not make any changes to |ebuild|; show what would be done |
33 |
style: The diff style |
34 |
|
35 |
- Returns: |
36 |
- Whether any updates were processed |
37 |
+ Returns: |
38 |
+ Whether any updates were processed |
39 |
""" |
40 |
with io.open(ebuild, encoding='utf8') as f: |
41 |
updated, content = process_content( |
42 |
|
43 |
diff --git a/src/ekeyword/ekeyword_unittest.py b/src/ekeyword/ekeyword_unittest.py |
44 |
index be84cc1..3465dfb 100755 |
45 |
--- a/src/ekeyword/ekeyword_unittest.py |
46 |
+++ b/src/ekeyword/ekeyword_unittest.py |
47 |
@@ -7,6 +7,8 @@ |
48 |
|
49 |
"""Unittests for ekeyword""" |
50 |
|
51 |
+from __future__ import print_function |
52 |
+ |
53 |
import os |
54 |
import tempfile |
55 |
import unittest |
56 |
@@ -21,14 +23,17 @@ class TestSortKeywords(unittest.TestCase): |
57 |
"""Tests for sort_keywords""" |
58 |
|
59 |
def _test(self, input_data, exp_data): |
60 |
+ """Sort |input_data| and make sure it matches |exp_data|""" |
61 |
output_data = ekeyword.sort_keywords(input_data.split()) |
62 |
self.assertEqual(exp_data.split(), output_data) |
63 |
|
64 |
def testNull(self): |
65 |
+ """Verify whitespace is collapsed""" |
66 |
self._test('', '') |
67 |
self._test(' ', '') |
68 |
|
69 |
def testGlob(self): |
70 |
+ """Verify globs get sorted before all others""" |
71 |
self._test('* arm', '* arm') |
72 |
self._test('arm -* x86', '-* arm x86') |
73 |
self._test('hppa ~* amd64', '~* amd64 hppa') |
74 |
@@ -356,6 +361,7 @@ class TestLoadProfileData(unittest.TestCase): |
75 |
|
76 |
|
77 |
class TestArgToOps(unittest.TestCase): |
78 |
+ """Tests for arg_to_op()""" |
79 |
|
80 |
def _test(self, arg, op): |
81 |
self.assertEqual(ekeyword.arg_to_op(arg), ekeyword.Op(*op)) |
82 |
@@ -377,6 +383,7 @@ class TestArgToOps(unittest.TestCase): |
83 |
|
84 |
|
85 |
class TestMain(unittest.TestCase): |
86 |
+ """Tests for the main entry point""" |
87 |
|
88 |
def testSmoke(self): |
89 |
ekeyword.main(['arm', '--dry-run', os.path.join(TESTDIR, 'process-1.ebuild')]) |