Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/
Date: Wed, 27 Jul 2011 09:02:05
Message-Id: f6fc5c0432450ae6d30c347b3da4d34d2f88c9f0.mgorny@gentoo
1 commit: f6fc5c0432450ae6d30c347b3da4d34d2f88c9f0
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jul 27 07:44:19 2011 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jul 27 07:44:19 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=f6fc5c04
7
8 SpaceSepTuple: support getting items by text.
9
10 ---
11 gentoopm/util.py | 5 +++++
12 1 files changed, 5 insertions(+), 0 deletions(-)
13
14 diff --git a/gentoopm/util.py b/gentoopm/util.py
15 index f80d4a5..961c7d9 100644
16 --- a/gentoopm/util.py
17 +++ b/gentoopm/util.py
18 @@ -120,6 +120,11 @@ class SpaceSepTuple(tuple):
19 s = s.split()
20 return tuple.__new__(self, s)
21
22 + def __getitem__(self, k):
23 + if isinstance(k, str):
24 + return self[self.index(k)]
25 + return tuple.__getitem__(self, k)
26 +
27 def __str__(self):
28 return ' '.join(self)