<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12595] CalendarServer/trunk/txweb2/dav/http.py</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12595">12595</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2014-02-06 14:50:28 -0800 (Thu, 06 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>logging, linting</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxweb2davhttppy">CalendarServer/trunk/txweb2/dav/http.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktxweb2davhttppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txweb2/dav/http.py (12594 => 12595)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txweb2/dav/http.py        2014-02-06 21:45:18 UTC (rev 12594)
+++ CalendarServer/trunk/txweb2/dav/http.py        2014-02-06 22:50:28 UTC (rev 12595)
</span><span class="lines">@@ -7,10 +7,10 @@
</span><span class="cx"> # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span><span class="cx"> # copies of the Software, and to permit persons to whom the Software is
</span><span class="cx"> # furnished to do so, subject to the following conditions:
</span><del>-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
</del><ins>+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
</ins><span class="cx"> # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx"> # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx"> # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> log = Logger()
</span><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> class ErrorResponse(Response):
</span><span class="cx"> """
</span><span class="cx"> A L{Response} object which contains a status code and a L{element.Error}
</span><span class="lines">@@ -79,7 +80,9 @@
</span><span class="cx">
</span><span class="cx"> self.description = description
</span><span class="cx"> if self.description:
</span><del>- output = element.Error(error, element.ErrorDescription(self.description)).toxml()
</del><ins>+ output = element.Error(
+ error, element.ErrorDescription(self.description)
+ ).toxml()
</ins><span class="cx"> else:
</span><span class="cx"> output = element.Error(error).toxml()
</span><span class="cx">
</span><span class="lines">@@ -91,9 +94,14 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> def __repr__(self):
</span><del>- return "<%s %s %s>" % (self.__class__.__name__, self.code, self.error.sname())
</del><ins>+ return (
+ "<%s %s %s>"
+ % (self.__class__.__name__, self.code, self.error.sname())
+ )
</ins><span class="cx">
</span><del>-class NeedPrivilegesResponse (ErrorResponse):
</del><ins>+
+
+class NeedPrivilegesResponse(ErrorResponse):
</ins><span class="cx"> def __init__(self, base_uri, errors):
</span><span class="cx"> """
</span><span class="cx"> An error response which is due to unsufficient privileges, as
</span><span class="lines">@@ -112,12 +120,17 @@
</span><span class="cx"> uri = joinURL(base_uri, subpath)
</span><span class="cx">
</span><span class="cx"> for p in privileges:
</span><del>- denials.append(element.Resource(element.HRef(uri),
- element.Privilege(p)))
</del><ins>+ denials.append(
+ element.Resource(element.HRef(uri), element.Privilege(p))
+ )
</ins><span class="cx">
</span><del>- super(NeedPrivilegesResponse, self).__init__(responsecode.FORBIDDEN, element.NeedPrivileges(*denials))
</del><ins>+ super(NeedPrivilegesResponse, self).__init__(
+ responsecode.FORBIDDEN, element.NeedPrivileges(*denials)
+ )
</ins><span class="cx">
</span><del>-class MultiStatusResponse (Response):
</del><ins>+
+
+class MultiStatusResponse(Response):
</ins><span class="cx"> """
</span><span class="cx"> Multi-status L{Response} object.
</span><span class="cx"> Renders itself as a DAV:multi-status XML document.
</span><span class="lines">@@ -131,15 +144,17 @@
</span><span class="cx">
</span><span class="cx"> self.headers.setHeader("content-type", MimeType("text", "xml"))
</span><span class="cx">
</span><del>-class ResponseQueue (object):
</del><ins>+
+
+class ResponseQueue(object):
</ins><span class="cx"> """
</span><span class="cx"> Stores a list of (typically error) responses for use in a
</span><span class="cx"> L{MultiStatusResponse}.
</span><span class="cx"> """
</span><span class="cx"> def __init__(self, path_basename, method, success_response):
</span><span class="cx"> """
</span><del>- @param path_basename: the base path for all responses to be added to the
- queue.
</del><ins>+ @param path_basename: the base path for all responses to be added to
+ the queue.
</ins><span class="cx"> All paths for responses added to the queue must start with
</span><span class="cx"> C{path_basename}, which will be stripped from the beginning of each
</span><span class="cx"> path to determine the response's URI.
</span><span class="lines">@@ -173,8 +188,11 @@
</span><span class="cx"> else:
</span><span class="cx"> raise AssertionError("Unknown data type: %r" % (what,))
</span><span class="cx">
</span><del>- if code > 400: # Error codes only
- log.error("Error during %s for %s: %s" % (self.method, path, message))
</del><ins>+ if code > 400: # Error codes only
+ log.error(
+ "Error during {method} for {path}: {message}",
+ method=self.method, path=path, message=message
+ )
</ins><span class="cx">
</span><span class="cx"> uri = path[self.path_basename_len:]
</span><span class="cx">
</span><span class="lines">@@ -199,7 +217,9 @@
</span><span class="cx"> else:
</span><span class="cx"> return self.success_response
</span><span class="cx">
</span><del>-class PropertyStatusResponseQueue (object):
</del><ins>+
+
+class PropertyStatusResponseQueue(object):
</ins><span class="cx"> """
</span><span class="cx"> Stores a list of propstat elements for use in a L{Response}
</span><span class="cx"> in a L{MultiStatusResponse}.
</span><span class="lines">@@ -235,10 +255,15 @@
</span><span class="cx">
</span><span class="cx"> if len(property.children) > 0:
</span><span class="cx"> # Re-instantiate as empty element.
</span><del>- property = element.WebDAVUnknownElement.withName(property.namespace, property.name)
</del><ins>+ property = element.WebDAVUnknownElement.withName(
+ property.namespace, property.name
+ )
</ins><span class="cx">
</span><del>- if code > 400: # Error codes only
- log.error("Error during %s for %s: %s" % (self.method, property, message))
</del><ins>+ if code > 400: # Error codes only
+ log.error(
+ "Error during {method} for {property}: {message}",
+ method=self.method, property=property, message=message
+ )
</ins><span class="cx">
</span><span class="cx"> children = []
</span><span class="cx"> children.append(element.PropertyContainer(property))
</span><span class="lines">@@ -251,7 +276,8 @@
</span><span class="cx">
</span><span class="cx"> def error(self):
</span><span class="cx"> """
</span><del>- Convert any 2xx codes in the propstat responses to 424 Failed Dependency.
</del><ins>+ Convert any 2xx codes in the propstat responses to 424 Failed
+ Dependency.
</ins><span class="cx"> """
</span><span class="cx"> for index, propstat in enumerate(self.propstats):
</span><span class="cx"> # Check the status
</span><span class="lines">@@ -286,6 +312,7 @@
</span><span class="cx"> element.Status.fromResponseCode(self.success_response)
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> ##
</span><span class="cx"> # Exceptions and response codes
</span><span class="cx"> ##
</span><span class="lines">@@ -299,7 +326,7 @@
</span><span class="cx"> """
</span><span class="cx"> def msg(err):
</span><span class="cx"> if what is not None:
</span><del>- log.debug("%s while %s" % (err, what))
</del><ins>+ log.debug("{err} while {what}", err=err, what=what)
</ins><span class="cx">
</span><span class="cx"> if failure.check(IOError, OSError):
</span><span class="cx"> e = failure.value[0]
</span><span class="lines">@@ -327,12 +354,14 @@
</span><span class="cx"> else:
</span><span class="cx"> failure.raiseException()
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> def errorForFailure(failure):
</span><span class="cx"> if failure.check(HTTPError) and isinstance(failure.value.response, ErrorResponse):
</span><span class="cx"> return element.Error(failure.value.response.error)
</span><span class="cx"> else:
</span><span class="cx"> return None
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> def messageForFailure(failure):
</span><span class="cx"> if failure.check(HTTPError):
</span><span class="cx"> if isinstance(failure.value.response, ErrorResponse):
</span></span></pre>
</div>
</div>
</body>
</html>