| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 82b8902 commit b48e4d3
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,12 +23,14 @@ class Commit(base.Object, Iterable, diff.Diffable, utils.Traversable): | |||
| 23 | 23 | ||
| 24 | 24 | # object configuration | |
| 25 | 25 | type = "commit" | |
| 26 | - __slots__ = ("tree", "author", "authored_date", "committer", "committed_date", | ||
| 27 | - "message", "parents") | ||
| 26 | + __slots__ = ("tree", | ||
| 27 | + "author", "authored_date", "author_tz_offset", | ||
| 28 | + "committer", "committed_date", "committer_tz_offset", | ||
| 29 | + "message", "parents") | ||
| 28 | 30 | _id_attribute_ = "sha" | |
| 29 | 31 | ||
| 30 | - def __init__(self, repo, sha, tree=None, author=None, authored_date=None, | ||
| 31 | - committer=None, committed_date=None, message=None, parents=None): | ||
| 32 | + def __init__(self, repo, sha, tree=None, author=None, authored_date=None, author_tz_offset=None, | ||
| 33 | + committer=None, committed_date=None, committer_tz_offset=None, message=None, parents=None): | ||
| 32 | 34 | """ | |
| 33 | 35 | Instantiate a new Commit. All keyword arguments taking None as default will | |
| 34 | 36 | be implicitly set if id names a valid sha. | |
@@ -51,13 +53,19 @@ def __init__(self, repo, sha, tree=None, author=None, authored_date=None, | |||
| 51 | 53 | is the authored DateTime - use time.gmtime() to convert it into a | |
| 52 | 54 | different format | |
| 53 | 55 | ||
| 56 | + ``author_tz_offset``: int_seconds_west_of_utc | ||
| 57 | + is the timezone that the authored_date is in | ||
| 58 | + | ||
| 54 | 59 | ``committer`` : Actor | |
| 55 | 60 | is the committer string | |
| 56 | 61 | ||
| 57 | 62 | ``committed_date`` : int_seconds_since_epoch | |
| 58 | 63 | is the committed DateTime - use time.gmtime() to convert it into a | |
| 59 | 64 | different format | |
| 60 | 65 | ||
| 66 | + ``committer_tz_offset``: int_seconds_west_of_utc | ||
| 67 | + is the timezone that the authored_date is in | ||
| 68 | + | ||
| 61 | 69 | ``message`` : string | |
| 62 | 70 | is the commit message | |
| 63 | 71 | ||
@@ -94,8 +102,10 @@ def _set_cache_(self, attr): | |||
| 94 | 102 | self.tree = temp.tree | |
| 95 | 103 | self.author = temp.author | |
| 96 | 104 | self.authored_date = temp.authored_date | |
| 105 | + self.author_tz_offset = temp.author_tz_offset | ||
| 97 | 106 | self.committer = temp.committer | |
| 98 | 107 | self.committed_date = temp.committed_date | |
| 108 | + self.committer_tz_offset = temp.committer_tz_offset | ||
| 99 | 109 | self.message = temp.message | |
| 100 | 110 | else: | |
| 101 | 111 | super(Commit, self)._set_cache_(attr) | |
@@ -253,8 +263,8 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream, from_rev_list): | |||
| 253 | 263 | parents.append(parent_line.split()[-1]) | |
| 254 | 264 | # END for each parent line | |
| 255 | 265 | ||
| 256 | - author, authored_date = utils.parse_actor_and_date(next_line) | ||
| 257 | - committer, committed_date = utils.parse_actor_and_date(stream.next()) | ||
| 266 | + author, authored_date, author_tz_offset = utils.parse_actor_and_date(next_line) | ||
| 267 | + committer, committed_date, committer_tz_offset = utils.parse_actor_and_date(stream.next()) | ||
| 258 | 268 | ||
| 259 | 269 | # empty line | |
| 260 | 270 | stream.next() | |
@@ -276,8 +286,10 @@ def _iter_from_process_or_stream(cls, repo, proc_or_stream, from_rev_list): | |||
| 276 | 286 | # END message parsing | |
| 277 | 287 | message = '\n'.join(message_lines) | |
| 278 | 288 | ||
| 279 | - yield Commit(repo, id, parents=tuple(parents), tree=tree, author=author, authored_date=authored_date, | ||
| 280 | - committer=committer, committed_date=committed_date, message=message) | ||
| 289 | + yield Commit(repo, id, parents=tuple(parents), tree=tree, | ||
| 290 | + author=author, authored_date=authored_date, author_tz_offset=author_tz_offset, | ||
| 291 | + committer=committer, committed_date=committed_date, committer_tz_offset=committer_tz_offset, | ||
| 292 | + message=message) | ||
| 281 | 293 | # END for each line in stream | |
| 282 | 294 | ||
| 283 | 295 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,10 +15,10 @@ class TagObject(base.Object): | |||
| 15 | 15 | to. | |
| 16 | 16 | """ | |
| 17 | 17 | type = "tag" | |
| 18 | - __slots__ = ( "object", "tag", "tagger", "tagged_date", "message" ) | ||
| 18 | + __slots__ = ( "object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message" ) | ||
| 19 | 19 | ||
| 20 | 20 | def __init__(self, repo, sha, object=None, tag=None, | |
| 21 | - tagger=None, tagged_date=None, message=None): | ||
| 21 | + tagger=None, tagged_date=None, tagger_tz_offset=None, message=None): | ||
| 22 | 22 | """ | |
| 23 | 23 | Initialize a tag object with additional data | |
| 24 | 24 | ||
@@ -40,6 +40,10 @@ def __init__(self, repo, sha, object=None, tag=None, | |||
| 40 | 40 | ``tagged_date`` : int_seconds_since_epoch | |
| 41 | 41 | is the DateTime of the tag creation - use time.gmtime to convert | |
| 42 | 42 | it into a different format | |
| 43 | + | ||
| 44 | + ``tagged_tz_offset``: int_seconds_west_of_utc | ||
| 45 | + is the timezone that the authored_date is in | ||
| 46 | + | ||
| 43 | 47 | """ | |
| 44 | 48 | super(TagObject, self).__init__(repo, sha ) | |
| 45 | 49 | self._set_self_from_args_(locals()) | |
@@ -58,7 +62,7 @@ def _set_cache_(self, attr): | |||
| 58 | 62 | self.tag = lines[2][4:] # tag <tag name> | |
| 59 | 63 | ||
| 60 | 64 | tagger_info = lines[3][7:]# tagger <actor> <date> | |
| 61 | - self.tagger, self.tagged_date = utils.parse_actor_and_date(tagger_info) | ||
| 65 | + self.tagger, self.tagged_date, self.tagger_tz_offset = utils.parse_actor_and_date(tagger_info) | ||
| 62 | 66 | ||
| 63 | 67 | # line 4 empty - it could mark the beginning of the next header | |
| 64 | 68 | # in csse there really is no message, it would not exist. Otherwise | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,7 @@ def get_object_type_by_name(object_type_name): | |||
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | 41 | # precompiled regex | |
| 42 | - _re_actor_epoch = re.compile(r'^.+? (.*) (\d+) .*$') | ||
| 42 | + _re_actor_epoch = re.compile(r'^.+? (.*) (\d+) ([+-]\d+).*$') | ||
| 43 | 43 | ||
| 44 | 44 | def parse_actor_and_date(line): | |
| 45 | 45 | """ | |
@@ -48,11 +48,11 @@ def parse_actor_and_date(line): | |||
| 48 | 48 | author Tom Preston-Werner <tom@mojombo.com> 1191999972 -0700 | |
| 49 | 49 | ||
| 50 | 50 | Returns | |
| 51 | - [Actor, int_seconds_since_epoch] | ||
| 51 | + [Actor, int_seconds_since_epoch, int_timezone_offset] | ||
| 52 | 52 | """ | |
| 53 | 53 | m = _re_actor_epoch.search(line) | |
| 54 | - actor, epoch = m.groups() | ||
| 55 | - return (Actor._from_string(actor), int(epoch)) | ||
| 54 | + actor, epoch, offset = m.groups() | ||
| 55 | + return (Actor._from_string(actor), int(epoch), -int(float(offset)/100*3600)) | ||
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | 58 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ def test_bake(self): | |||
| 18 | 18 | assert_equal("byronimo@gmail.com", commit.author.email) | |
| 19 | 19 | assert commit.author == commit.committer | |
| 20 | 20 | assert isinstance(commit.authored_date, int) and isinstance(commit.committed_date, int) | |
| 21 | + assert isinstance(commit.author_tz_offset, int) and isinstance(commit.committer_tz_offset, int) | ||
| 21 | 22 | assert commit.message == "Added missing information to docstrings of commit and stats module" | |
| 22 | 23 | ||
| 23 | 24 | ||
@@ -46,6 +47,8 @@ def check_entries(d): | |||
| 46 | 47 | assert commit.committer == michael | |
| 47 | 48 | assert commit.authored_date == 1210193388 | |
| 48 | 49 | assert commit.committed_date == 1210193388 | |
| 50 | + assert commit.author_tz_offset == 14400, commit.author_tz_offset | ||
| 51 | + assert commit.committer_tz_offset == 14400, commit.committer_tz_offset | ||
| 49 | 52 | assert commit.message == "initial project" | |
| 50 | 53 | ||
| 51 | 54 | def test_traversal(self): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments