Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/repository/
Date: Wed, 01 Jun 2011 12:30:36
Message-Id: 0a914c67bfd5caca8c3ac32ed468440c42991141.mgorny@gentoo
1 commit: 0a914c67bfd5caca8c3ac32ed468440c42991141
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 1 12:25:59 2011 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 1 12:25:59 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=0a914c67
7
8 Commonize category grabbing code.
9
10 ---
11 PMSTestSuite/repository/__init__.py | 18 +++++++++++-------
12 1 files changed, 11 insertions(+), 7 deletions(-)
13
14 diff --git a/PMSTestSuite/repository/__init__.py b/PMSTestSuite/repository/__init__.py
15 index 60a975d..6545035 100644
16 --- a/PMSTestSuite/repository/__init__.py
17 +++ b/PMSTestSuite/repository/__init__.py
18 @@ -40,16 +40,20 @@ class EbuildRepository(object):
19 if not self.repo_name:
20 raise ValueError('Repository %s has invalid name.' % path)
21
22 + def get_category_from_path(self, fn):
23 + head = fn
24 + while head:
25 + head, tail = os.path.split(head)
26 + if tail in ('eclass', 'profiles'):
27 + return None
28 + return tail
29 +
30 def write_files(self, files):
31 """ Write files from files dict to the repository. """
32 for fn in files:
33 - head = fn
34 - while head:
35 - head, tail = os.path.split(head)
36 - if tail in ('eclass', 'profiles'):
37 - pass
38 - elif tail not in self.categories:
39 - self.add_category(tail, files)
40 + cat = self.get_category_from_path(fn)
41 + if cat and cat not in self.categories:
42 + self.add_category(cat, files)
43
44 for fn, c in files.items():
45 fp = os.path.join(self.path, fn)