Use % instead of format for consistency (and Python 2.6 support)

This commit is contained in:
Guillaume Ayoub 2011-06-05 12:34:50 +02:00
parent dd6063ccb6
commit e9935ae1a6
2 changed files with 5 additions and 6 deletions

View File

@ -411,11 +411,11 @@ class Calendar(object):
def owner_url(self): def owner_url(self):
"""Get the calendar URL according to its owner.""" """Get the calendar URL according to its owner."""
if self.owner: if self.owner:
return '/{}/'.format(self.owner).replace('//', '/') return ('/%s/' % self.owner).replace('//', '/')
else: else:
return None return None
@property @property
def url(self): def url(self):
"""Get the standard calendar URL.""" """Get the standard calendar URL."""
return '/{}/'.format(self.local_path).replace('//', '/') return ('/%s/' % self.local_path).replace('//', '/')

View File

@ -224,7 +224,7 @@ def _propfind_response(path, item, props, user):
if item.owner_url: if item.owner_url:
tag.text = item.owner_url tag.text = item.owner_url
elif user: elif user:
tag.text = '/{}/'.format(user) tag.text = '/%s/' % user
else: else:
tag.text = path tag.text = path
element.append(tag) element.append(tag)
@ -245,7 +245,7 @@ def _propfind_response(path, item, props, user):
# pylint: enable=W0511 # pylint: enable=W0511
elif tag == _tag("D", "current-user-principal") and user: elif tag == _tag("D", "current-user-principal") and user:
tag = ET.Element(_tag("D", "href")) tag = ET.Element(_tag("D", "href"))
tag.text = '/{}/'.format(user) tag.text = '/%s/' % user
element.append(tag) element.append(tag)
elif tag == _tag("D", "current-user-privilege-set"): elif tag == _tag("D", "current-user-privilege-set"):
privilege = ET.Element(_tag("D", "privilege")) privilege = ET.Element(_tag("D", "privilege"))
@ -283,8 +283,7 @@ def _propfind_response(path, item, props, user):
is404 = True is404 = True
# Not for calendars # Not for calendars
elif tag == _tag("D", "getcontenttype"): elif tag == _tag("D", "getcontenttype"):
element.text = \ element.text = "text/calendar; component=%s" % item.tag.lower()
"text/calendar; component={}".format(item.tag.lower())
else: else:
is404 = True is404 = True