commit b89d9da5ce6ecf46dd1dfe7bbf4522d8776ca322 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Nov 6 20:51:20 2012 -0500
Make tweaks based on comments by gsathya (#6471). --- task-6471/python/pygeodate.py | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/task-6471/python/pygeodate.py b/task-6471/python/pygeodate.py index 83169e5..72f13d8 100644 --- a/task-6471/python/pygeodate.py +++ b/task-6471/python/pygeodate.py @@ -42,22 +42,15 @@ class Database: for line in input_file.readlines(): line = line.strip() if line.startswith('!'): - self.add_date(line) - continue + date = line.split("!")[1] + if date not in self.dates: + bisect.insort(self.dates, date) else: - self.add_range(line) + r = Range(line) + self.data.append((r.key, r)) self.data.sort() self.keys = [r[0] for r in self.data]
- def add_date(self, line): - date = line.split("!")[1] - if date not in self.dates: - bisect.insort(self.dates, date) - - def add_range(self, line): - r = Range(line) - self.data.append((r.key, r)) - def lookup_address_and_date(self, address_string, date_string): if len(self.data) == 0: return '??'