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
1=== modified file 'zeitgeist/datamodel.py'
2--- zeitgeist/datamodel.py 2010-07-28 20:10:07 +0000
3+++ zeitgeist/datamodel.py 2010-08-14 23:49:01 +0000
4@@ -374,17 +374,17 @@
5 @classmethod
6 def always(cls):
7 """
8- Return a :class:`TimeRange` from the furtest past to the most
9+ Return a :class:`TimeRange` from 0 (January 1, 1970) to the most
10 distant future
11 """
12- return cls(-cls._max_stamp, cls._max_stamp)
13+ return cls(0, cls._max_stamp)
14
15 def is_always(self):
16 """
17- Returns True if this time range represents the furtest past to the most
18+ Returns True if this time range represents the 0 (January 1, 1970) to the most
19 distant future
20 """
21- return self.begin <= -TimeRange._max_stamp and self.end >= TimeRange._max_stamp
22+ return self.begin == 0 and self.end >= TimeRange._max_stamp
23
24 def intersect(self, time_range):
25 """
26@@ -482,6 +482,9 @@
27 """
28 self = Subject()
29 for key, value in values.iteritems():
30+ if not key in ("uri", "interpretation", "manifestation", "origin",
31+ "mimetype", "text", "storage"):
32+ raise ValueError("Subject parameter '%s' is not supported" %key)
33 setattr(self, key, value)
34 return self
35
36@@ -701,6 +704,11 @@
37
38 """
39 self = cls()
40+ for key in values:
41+ if not key in ("timestamp", "interpretation",
42+ "manifestation", "actor", "subjects"):
43+ raise ValueError("Event parameter '%s' is not supported" %key)
44+
45 self.timestamp = values.get("timestamp", self.timestamp)
46 self.interpretation = values.get("interpretation", "")
47 self.manifestation = values.get("manifestation", "")