Commit 1c554471 authored by Dan Pascu's avatar Dan Pascu

Refactored global variable as a class attribute

parent 8e968c34
...@@ -79,6 +79,7 @@ class HistoryManager(object): ...@@ -79,6 +79,7 @@ class HistoryManager(object):
class HistoryEntry(object): class HistoryEntry(object):
phone_number_re = re.compile(r'^(?P<number>(0|00|\+)[1-9]\d{7,14})@')
def __init__(self, remote_identity, target_uri, account_id, call_time, duration, reason=None): def __init__(self, remote_identity, target_uri, account_id, call_time, duration, reason=None):
self.remote_identity = remote_identity self.remote_identity = remote_identity
...@@ -106,9 +107,9 @@ class HistoryEntry(object): ...@@ -106,9 +107,9 @@ class HistoryEntry(object):
display_name = remote_identity.display_name display_name = remote_identity.display_name
else: else:
display_name = contact.name display_name = contact.name
m = phone_number_re.match(remote_uri_str) match = self.phone_number_re.match(remote_uri_str)
if m: if match:
remote_uri_str = m.group('number') remote_uri_str = match.group('number')
if display_name and display_name != remote_uri_str: if display_name and display_name != remote_uri_str:
remote_identity_str = '%s <%s>' % (display_name, remote_uri_str) remote_identity_str = '%s <%s>' % (display_name, remote_uri_str)
else: else:
...@@ -132,8 +133,6 @@ class HistoryEntry(object): ...@@ -132,8 +133,6 @@ class HistoryEntry(object):
return u'%s%s%s%s' % (self.remote_identity, time, duration, reason) return u'%s%s%s%s' % (self.remote_identity, time, duration, reason)
phone_number_re = re.compile(r'^(?P<number>(0|00|\+)[1-9]\d{7,14})@')
def format_date(dt): def format_date(dt):
now = datetime.now() now = datetime.now()
delta = now - dt delta = now - dt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment