[CalendarServer-changes] [13216] CalendarServer/trunk/txdav/xml

source_changes at macosforge.org source_changes at macosforge.org
Tue Apr 8 22:14:38 PDT 2014


Revision: 13216
          http://trac.calendarserver.org//changeset/13216
Author:   gaya at apple.com
Date:     2014-04-08 22:14:38 -0700 (Tue, 08 Apr 2014)
Log Message:
-----------
Use format() instead of %

Modified Paths:
--------------
    CalendarServer/trunk/txdav/xml/rfc2518.py
    CalendarServer/trunk/txdav/xml/rfc3744.py

Modified: CalendarServer/trunk/txdav/xml/rfc2518.py
===================================================================
--- CalendarServer/trunk/txdav/xml/rfc2518.py	2014-04-09 04:19:17 UTC (rev 13215)
+++ CalendarServer/trunk/txdav/xml/rfc2518.py	2014-04-09 05:14:38 UTC (rev 13216)
@@ -78,7 +78,7 @@
 
         depth = str(self)
         if depth not in ("0", "1", "infinity"):
-            raise ValueError("Invalid depth: %s" % (depth,))
+            raise ValueError("Invalid depth: {0}".format(depth,))
 
 
 
@@ -307,22 +307,35 @@
                 propstat_count += 1
 
         if resource_count < 1:
-            raise ValueError("%s element must have at least one %s."
-                             % (cls.sname(), HRef.sname()))
+            raise ValueError(
+                "{0} element must have at least one {1}.".format(
+                    cls.sname(), HRef.sname()
+                )
+        )
 
         if status_count is 0:
             if propstat_count is 0:
-                raise ValueError("%s element must have one of %s or %s"
-                                 % (cls.sname(), Status.sname(), PropertyStatus.sname()))
+                raise ValueError(
+                    "{0} element must have one of {1} or {2}".format(
+                        cls.sname(), Status.sname(), PropertyStatus.sname()
+                    )
+                )
 
             if resource_count > 1:
-                raise ValueError("%s element with %s may only have one %s"
-                                 % (cls.sname(), PropertyStatus.sname(), HRef.sname()))
+                raise ValueError(
+                    "{0} element with {1} may only have one {2}".format(
+                        cls.sname(), PropertyStatus.sname(), HRef.sname()
+                    )
+            )
 
             return PropertyStatusResponse.__new__(PropertyStatusResponse, *children)
 
         if status_count > 1:
-            raise ValueError("%s element may only have one %s" % (cls.sname(), Status.sname()))
+            raise ValueError(
+                "{0} element may only have one {1}".format(
+                    cls.sname(), Status.sname()
+                )
+            )
 
         return StatusResponse.__new__(StatusResponse, *children)
 
@@ -393,9 +406,9 @@
         txweb2.responsecode.RESPONSES.keys()
         """
         if code not in responsecode.RESPONSES:
-            raise ValueError("Invalid response code: %r" % (code,))
+            raise ValueError("Invalid response code: {0!r}".format(code,))
 
-        return cls(PCDATAElement("HTTP/1.1 %d %s" % (code, responsecode.RESPONSES[code])))
+        return cls(PCDATAElement("HTTP/1.1 {0} {1}".format(code, responsecode.RESPONSES[code])))
 
 
     def __init__(self, *children, **attributes):
@@ -403,11 +416,11 @@
 
         status = str(self)
         if not status.startswith("HTTP/1.1 "):
-            raise ValueError("Invalid WebDAV status: %s" % (status,))
+            raise ValueError("Invalid WebDAV status: {0}".format(status,))
 
         code = int(status[9:12])
         if code not in responsecode.RESPONSES:
-            raise ValueError("Invalid status code: %s" % (code,))
+            raise ValueError("Invalid status code: {0}".format(code,))
 
         self.code = code
 
@@ -475,8 +488,9 @@
 
         if len(self.children) != 1:
             raise ValueError(
-                "Exactly one of DAV:omit, DAV:keepalive required for %s, got: %s"
-                % (self.sname(), self.children)
+                "Exactly one of DAV:omit, DAV:keepalive required for {0}, got: {1}".format(
+                    self.sname(), self.children
+                )
             )
 
         self.behavior = children[0]
@@ -508,13 +522,14 @@
                 type = child.qname()
             elif child.qname() != type:
                 raise ValueError(
-                    "Only one of DAV:href or PCDATA allowed for %s, got: %s"
-                    % (self.sname(), self.children)
+                    "Only one of DAV:href or PCDATA allowed for {0}, got: {1}".format(
+                        self.sname(), self.children
+                    )
                 )
 
         if type == "#PCDATA":
             if str(self) != "*":
-                raise ValueError("Invalid keepalive value: %r", (str(self),))
+                raise ValueError("Invalid keepalive value: {0!r}".format(str(self),))
 
 
 
@@ -592,8 +607,9 @@
 
         if len(self.children) != 1:
             raise ValueError(
-                "Exactly one of DAV:allprop, DAV:propname or DAV:prop is required for %s, got: %r"
-                % (self.sname(), self.children)
+                "Exactly one of DAV:allprop, DAV:propname or DAV:prop is required for {0}, got: {1!r}".format(
+                    self.sname(), self.children
+                )
             )
 
 

Modified: CalendarServer/trunk/txdav/xml/rfc3744.py
===================================================================
--- CalendarServer/trunk/txdav/xml/rfc3744.py	2014-04-09 04:19:17 UTC (rev 13215)
+++ CalendarServer/trunk/txdav/xml/rfc3744.py	2014-04-09 05:14:38 UTC (rev 13216)
@@ -187,8 +187,9 @@
             raise ValueError(
                 "Exactly one of DAV:href, DAV:all, DAV:authenticated, "
                 "DAV:unauthenticated, DAV:property or DAV:self is required for "
-                "%s, got: %r"
-                % (self.sname(), self.children)
+                "{0}, got: {1!r}".format(
+                    self.sname(), self.children
+                )
             )
 
 
@@ -504,8 +505,9 @@
                 if name in ("principal", "invert"):
                     if self.principal is not None:
                         raise ValueError(
-                            "Only one of DAV:principal or DAV:invert allowed in %s, got: %s"
-                            % (self.sname(), self.children)
+                            "Only one of DAV:principal or DAV:invert allowed in {0}, got: {1}".format(
+                                self.sname(), self.children
+                            )
                         )
                     if name == "invert":
                         self.invert = True
@@ -517,8 +519,9 @@
                 elif name in ("grant", "deny"):
                     if self.allow is not None:
                         raise ValueError(
-                            "Only one of DAV:grant or DAV:deny allowed in %s, got: %s"
-                            % (self.sname(), self.children)
+                            "Only one of DAV:grant or DAV:deny allowed in {0}, got: {1}".format(
+                                self.sname(), self.children
+                            )
                         )
                     self.allow = (name == "grant")
                     self.privileges = child.children
@@ -535,15 +538,17 @@
 
         if self.principal is None:
             raise ValueError(
-                "One of DAV:principal or DAV:invert is required in %s, got: %s"
-                % (self.sname(), self.children)
+                "One of DAV:principal or DAV:invert is required in {0}, got: {1}".format(
+                    self.sname(), self.children
+                )
             )
         assert self.invert is not None
 
         if self.allow is None:
             raise ValueError(
-                "One of DAV:grant or DAV:deny is required in %s, got: %s"
-                % (self.sname(), self.children)
+                "One of DAV:grant or DAV:deny is required in {0}, got: {1}".format(
+                    self.sname(), self.children
+                )
             )
         assert self.privileges is not None
 
@@ -740,8 +745,9 @@
             elif child.qname() != type:
                 raise ValueError(
                     "Only one of DAV:all, DAV:authenticated, DAV:unauthenticated, "
-                    "DAV:self, DAV:href or DAV:property allowed for %s, got: %s"
-                    % (self.sname(), self.children)
+                    "DAV:self, DAV:href or DAV:property allowed for {0}, got: {1}".format(
+                        self.sname(), self.children
+                    )
                 )
 
 
@@ -835,8 +841,9 @@
             if child.qname() == (dav_namespace, "prop"):
                 if prop:
                     raise ValueError(
-                        "Only one DAV:prop allowed for %s, got: %s"
-                        % (self.sname(), self.children)
+                        "Only one DAV:prop allowed for {0}, got: {1}".format(
+                            self.sname(), self.children
+                        )
                     )
                 prop = True
 
@@ -873,15 +880,17 @@
             if (namespace == dav_namespace) and name in ("principal-property", "self"):
                 if principalPropertyOrSelf:
                     raise ValueError(
-                        "Only one of DAV:principal-property or DAV:self allowed in %s, got: %s"
-                        % (self.sname(), self.children)
+                        "Only one of DAV:principal-property or DAV:self allowed in {0}, got: {1}".format(
+                            self.sname(), self.children
+                        )
                     )
                 principalPropertyOrSelf = True
 
         if not principalPropertyOrSelf:
             raise ValueError(
-                "One of DAV:principal-property or DAV:self is required in %s, got: %s"
-                % (self.sname(), self.children)
+                "One of DAV:principal-property or DAV:self is required in {0}, got: {1}".format(
+                    self.sname(), self.children
+                )
             )
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140408/0a2acc6b/attachment-0001.html>


More information about the calendarserver-changes mailing list