- commit
- d849f0559c3a767e53e84c9d41829195b80b6d08
- parent
- 019e4523579ba5839e8cd9c10afcdf14d258c4a4
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2015-03-22 16:11
allow to compare claims
Diffstat
| M | projects.py | 8 | ++++++++ |
1 files changed, 8 insertions, 0 deletions
diff --git a/projects.py b/projects.py
@@ -1,3 +1,4 @@ -1 1 from functools import total_ordering 1 2 from xml.etree import ElementTree 2 3 import argparse 3 4 import json @@ -53,6 +54,7 @@ def r_get(d, *keys): 53 54 return r_get(d[keys[0]], *keys[1:]) 54 55 55 56 -1 57 @total_ordering 56 58 class Claims(object): 57 59 def __init__(self): 58 60 self._list = [] @@ -75,6 +77,9 @@ class Claims(object): 75 77 i = -1 76 78 self._list[i][1].append(source) 77 79 -1 80 def values(self): -1 81 return [value for value, sources in self._list] -1 82 78 83 def format(self, show_sources=True): 79 84 def _format_claim(value, sources): 80 85 s = str(value) @@ -83,6 +88,9 @@ class Claims(object): 83 88 return s 84 89 return '; '.join([_format_claim(v, srcs) for v, srcs in self._list]) 85 90 -1 91 def __lt__(self, other): -1 92 return self.values() < other.values() -1 93 86 94 87 95 class ClaimsDict(object): 88 96 def __init__(self, keys, short=9):