From 33ebe7acec14b25c5f84f35a664803fcab2f7781 Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Wed, 7 May 2008 16:49:48 -0400 Subject: initial project --- lib/git_python/actor.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/git_python/actor.py (limited to 'lib/git_python/actor.py') diff --git a/lib/git_python/actor.py b/lib/git_python/actor.py new file mode 100644 index 00000000..235c3e21 --- /dev/null +++ b/lib/git_python/actor.py @@ -0,0 +1,33 @@ +import re + +class Actor(object): + def __init__(self, name, email): + self.name = name + self.email = email + + def __str__(self): + return self.name + + def __repr__(self): + return '">' % (self.name, self.email) + + @classmethod + def from_string(cls, string): + """ + Create an Actor from a string. + + ``str`` + is the string, which is expected to be in regular git format + + Format + John Doe + + Returns + Actor + """ + if re.search(r'<.+>', string): + m = re.search(r'(.*) <(.+?)>', string) + name, email = m.groups() + return Actor(name, email) + else: + return Actor(string, None) -- cgit v1.2.1