1 |
commit: 9b8e3b50dd05b6a799a919c40e992dd1f987e9c4 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jun 1 12:15:18 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jun 1 12:15:18 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=9b8e3b50 |
7 |
|
8 |
Update files dict in add_category() instead of spawning a new write. |
9 |
|
10 |
--- |
11 |
PMSTestSuite/repository/__init__.py | 20 +++++++++++--------- |
12 |
1 files changed, 11 insertions(+), 9 deletions(-) |
13 |
|
14 |
diff --git a/PMSTestSuite/repository/__init__.py b/PMSTestSuite/repository/__init__.py |
15 |
index 70f3727..9af204a 100644 |
16 |
--- a/PMSTestSuite/repository/__init__.py |
17 |
+++ b/PMSTestSuite/repository/__init__.py |
18 |
@@ -49,7 +49,7 @@ class EbuildRepository(object): |
19 |
if tail in ('eclass', 'profiles'): |
20 |
pass |
21 |
elif tail not in self.categories: |
22 |
- self.add_category(tail) |
23 |
+ self.add_category(tail, files) |
24 |
|
25 |
fp = os.path.join(self.path, fn) |
26 |
if not os.path.exists(os.path.dirname(fp)): |
27 |
@@ -63,8 +63,11 @@ class EbuildRepository(object): |
28 |
dirs = frozenset([os.path.join(self.path, os.path.dirname(f)) for f in files]) |
29 |
pm.remanifest(dirs) |
30 |
|
31 |
- def add_category(self, catname): |
32 |
- """ Add category <catname> to profiles/categories. """ |
33 |
+ def add_category(self, catname, files): |
34 |
+ """ |
35 |
+ Add category <catname> to profiles/categories. Update |
36 |
+ the profiles/categories file in <files> dict. |
37 |
+ """ |
38 |
raise ValueError("The repository doesn't support %s category." % catname) |
39 |
|
40 |
class NewEbuildRepository(EbuildRepository): |
41 |
@@ -87,11 +90,10 @@ class NewEbuildRepository(EbuildRepository): |
42 |
f.close() |
43 |
|
44 |
EbuildRepository.__init__(self, path) |
45 |
- |
46 |
- def add_category(self, catname): |
47 |
+ |
48 |
+ def add_category(self, catname, files): |
49 |
+ # XXX: profiles/categories can contain new categories already |
50 |
+ # and they may not be in self.categories |
51 |
self.categories.append(catname) |
52 |
newcats = '\n'.join(self.categories) |
53 |
- files = { |
54 |
- os.path.join('profiles', 'categories'): newcats |
55 |
- } |
56 |
- self.write_files(files) |
57 |
+ files[os.path.join('profiles', 'categories')] = newcats |