Merge lp:~zeitgeist/zeitgeist/timerange_and_event_value_fix into lp:zeitgeist/0.1

Proposed by Seif Lotfy
Status: Merged
Merged at revision: 1547
Proposed branch: lp:~zeitgeist/zeitgeist/timerange_and_event_value_fix
Merge into: lp:zeitgeist/0.1
Diff against target: 47 lines (+12/-4)
1 file modified
zeitgeist/datamodel.py (+12/-4)
To merge this branch: bzr merge lp:~zeitgeist/zeitgeist/timerange_and_event_value_fix
Reviewer Review Type Date Requested Status
Siegfried Gevatter Pending
Review via email: mp+32574@code.launchpad.net

Description of the change

I fixed the TimeRange.always to be consistent: so instead of (-maxint, maxint) it has become (0, maxint)

Also I check for values of the Event constructor new_for_values to detect faulty arguments and raise an exception

To post a comment you must log in.
1548. By Seif Lotfy

add subject value check and TimeRange.always starting from 0 explanation to docstring

Revision history for this message
Michal Hruby (mhr3) wrote :

Seif, with your changes TimeRange.always().is_always() will return False. I wouldn't call that a bugfix. :P

Revision history for this message
Seif Lotfy (seif) wrote :

> Seif, with your changes TimeRange.always().is_always() will return False. I
> wouldn't call that a bugfix. :P

Ok just fixed it....
Now will some1 acknowledge it

1549. By Seif Lotfy

fix the issue raised by mhr3 with the return of is_always

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'zeitgeist/datamodel.py'
--- zeitgeist/datamodel.py 2010-07-28 20:10:07 +0000
+++ zeitgeist/datamodel.py 2010-08-14 23:49:01 +0000
@@ -374,17 +374,17 @@
374 @classmethod374 @classmethod
375 def always(cls):375 def always(cls):
376 """376 """
377 Return a :class:`TimeRange` from the furtest past to the most377 Return a :class:`TimeRange` from 0 (January 1, 1970) to the most
378 distant future378 distant future
379 """379 """
380 return cls(-cls._max_stamp, cls._max_stamp)380 return cls(0, cls._max_stamp)
381 381
382 def is_always(self):382 def is_always(self):
383 """383 """
384 Returns True if this time range represents the furtest past to the most384 Returns True if this time range represents the 0 (January 1, 1970) to the most
385 distant future385 distant future
386 """386 """
387 return self.begin <= -TimeRange._max_stamp and self.end >= TimeRange._max_stamp387 return self.begin == 0 and self.end >= TimeRange._max_stamp
388 388
389 def intersect(self, time_range):389 def intersect(self, time_range):
390 """390 """
@@ -482,6 +482,9 @@
482 """482 """
483 self = Subject()483 self = Subject()
484 for key, value in values.iteritems():484 for key, value in values.iteritems():
485 if not key in ("uri", "interpretation", "manifestation", "origin",
486 "mimetype", "text", "storage"):
487 raise ValueError("Subject parameter '%s' is not supported" %key)
485 setattr(self, key, value)488 setattr(self, key, value)
486 return self489 return self
487 490
@@ -701,6 +704,11 @@
701 704
702 """705 """
703 self = cls()706 self = cls()
707 for key in values:
708 if not key in ("timestamp", "interpretation",
709 "manifestation", "actor", "subjects"):
710 raise ValueError("Event parameter '%s' is not supported" %key)
711
704 self.timestamp = values.get("timestamp", self.timestamp)712 self.timestamp = values.get("timestamp", self.timestamp)
705 self.interpretation = values.get("interpretation", "")713 self.interpretation = values.get("interpretation", "")
706 self.manifestation = values.get("manifestation", "")714 self.manifestation = values.get("manifestation", "")