From 58d692e2a1d7e3894dbed68efbcf7166d6ec3fb7 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 15 Oct 2009 10:33:13 +0200 Subject: All times are not stored as time_struct, but as simple int to consume less memory time imports cleaned up and mostly removed as they were not required (anymore) --- lib/git/objects/utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/git/objects/utils.py') diff --git a/lib/git/objects/utils.py b/lib/git/objects/utils.py index 15c1d114..9b9e0c52 100644 --- a/lib/git/objects/utils.py +++ b/lib/git/objects/utils.py @@ -6,7 +6,9 @@ """ Module for general utility functions """ +import re import commit, tag, blob, tree +from git.actor import Actor def get_object_type_by_name(object_type_name): """ @@ -34,3 +36,20 @@ def get_object_type_by_name(object_type_name): return tree.Tree else: raise ValueError("Cannot handle unknown object type: %s" % object_type_name) + + +# precompiled regex +_re_actor_epoch = re.compile(r'^.+? (.*) (\d+) .*$') + +def parse_actor_and_date(line): + """ + Parse out the actor (author or committer) info from a line like:: + + author Tom Preston-Werner 1191999972 -0700 + + Returns + [Actor, int_seconds_since_epoch] + """ + m = _re_actor_epoch.search(line) + actor, epoch = m.groups() + return (Actor._from_string(actor), int(epoch)) -- cgit v1.2.1