[Calypso] [PATCH 2/4] M-x delete-trailing-whitespace
Guido Günther
agx at sigxcpu.org
Sat Apr 8 11:59:18 PDT 2017
---
calypso.py | 6 +++---
calypso/__init__.py | 10 +++++-----
calypso/paths.py | 1 -
calypso/webdav.py | 14 +++++++-------
calypso/xmlutils.py | 6 +++---
tests/test_matchfilterelement.py | 1 -
6 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/calypso.py b/calypso.py
index 09fe62d..693b75e 100755
--- a/calypso.py
+++ b/calypso.py
@@ -23,7 +23,7 @@
# This file is just a script, allow [a-z0-9]* variable names
# pylint: disable-msg=C0103
-# ``import calypso`` refers to the ``calypso`` module, not ``calypso.py``
+# ``import calypso`` refers to the ``calypso`` module, not ``calypso.py``
# pylint: disable-msg=W0406
"""
@@ -88,7 +88,7 @@ parser.add_option(
"-P", "--pid-file", dest="pidfile",
default=calypso.config.get("server", "pidfile"),
help="set location of process-id file")
-
+
(options, args) = parser.parse_args()
# Update Calypso configuration according to options
@@ -111,7 +111,7 @@ else:
log.setLevel(logging.WARN)
ch.setLevel(logging.WARN)
logging.basicConfig(level=logging.WARN)
-
+
# Run import if requested
if options.import_dest:
diff --git a/calypso/__init__.py b/calypso/__init__.py
index 9819d4c..a2ed176 100644
--- a/calypso/__init__.py
+++ b/calypso/__init__.py
@@ -134,7 +134,7 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
# Decorator checking rights before performing request
check_rights = lambda function: lambda request: _check(request, function)
-
+
# We do set Content-Length on all replies, so we can use HTTP/1.1
# with multiple requests (as desired by the android CalDAV sync program
@@ -316,7 +316,7 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
self.send_calypso_response(client.NOT_FOUND, 0)
self.end_headers()
return
-
+
if is_get:
try:
self._answer = answer_text.encode(self._encoding,"xmlcharrefreplace")
@@ -359,7 +359,7 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
if item and self.if_match(item):
# No ETag precondition or precondition verified, delete item
self._answer = xmlutils.delete(self.path, self._collection, context=context)
-
+
self.send_calypso_response(client.NO_CONTENT, len(self._answer))
self.send_header("Content-Type", "text/xml")
self.end_headers()
@@ -430,7 +430,7 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
log.exception("Failed SEARCH for %s", self.path)
self.send_calypso_response(client.BAD_REQUEST, 0)
self.end_headers()
-
+
@check_rights
def do_PUT(self, context):
"""Manage PUT request."""
@@ -445,7 +445,7 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
# Case 3: Item and no Etag precondition: Force modifying item
webdav_request = self._decode(self.xml_request)
new_item = xmlutils.put(self.path, webdav_request, self._collection, context=context)
-
+
log.debug("item_name %s new_name %s", item_name, new_item.name)
etag = new_item.etag
#log.debug("replacement etag %s", etag)
diff --git a/calypso/paths.py b/calypso/paths.py
index 8483fff..8457f36 100644
--- a/calypso/paths.py
+++ b/calypso/paths.py
@@ -157,4 +157,3 @@ def collection_from_path(path):
log.debug('Path %s results in collection: %s', path, collection)
return collection
-
diff --git a/calypso/webdav.py b/calypso/webdav.py
index f472e1a..f4e41b0 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -97,7 +97,7 @@ class Item(object):
break
if not name:
name = hashlib.sha1(text).hexdigest()
-
+
self.object.add("X-CALYPSO-NAME").value = name
else:
names = self.object.contents[u'x-calypso-name']
@@ -286,7 +286,7 @@ class Collection(object):
old_items.append(old_item)
for old_item in old_items:
self.my_items.remove(old_item)
-
+
def scan_file(self, path):
self.remove_file(path)
self.insert_file(path)
@@ -378,7 +378,7 @@ class Collection(object):
def __repr__(self):
return "<Calendar %s>" % (self.name)
-
+
def has_git(self):
return True
@@ -408,7 +408,7 @@ class Collection(object):
if self.has_git():
subprocess.check_call(["git", "add", os.path.basename(path)], cwd=self.path)
self.git_commit(context=context)
-
+
def git_rm(self, path, context):
if self.has_git():
subprocess.check_call(["git", "rm", os.path.basename(path)], cwd=self.path)
@@ -423,7 +423,7 @@ class Collection(object):
os.utime(self.path, None)
except Exception, ex:
self.log.exception("Failed to set directory mtime")
-
+
def write_file(self, item):
fd, path = tempfile.mkstemp(item.file_extension, item.file_prefix, dir=self.path)
self.log.debug('Trying to write to %s', path)
@@ -484,7 +484,7 @@ class Collection(object):
except Exception, ex:
self.log.exception("Failed to rewrite %s", item.path)
raise
-
+
def get_item(self, name):
"""Get collection item called ``name``."""
for item in self.my_items:
@@ -526,7 +526,7 @@ class Collection(object):
for old_item in self.my_items:
if old_item.name == name:
self.destroy_file(old_item, context=context)
-
+
def replace(self, name, text, context):
"""Replace content by ``text`` in objet named ``name`` in collection."""
diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
index d692b32..4adfbd6 100644
--- a/calypso/xmlutils.py
+++ b/calypso/xmlutils.py
@@ -118,7 +118,7 @@ def propfind(path, xml_request, collection, depth, context):
_tag("D", "getcontentlength"),
_tag("D", "getlastmodified")]
-
+
# Writing answer
multistatus = ET.Element(_tag("D", "multistatus"))
@@ -378,7 +378,7 @@ def report(path, xml_request, collection):
path = hreference
items = collection.items
-
+
for item in items:
if not match_filter(item, filter_element):
continue
@@ -411,5 +411,5 @@ def report(path, xml_request, collection):
propstat.append(status)
reply = ET.tostring(multistatus, config.get("encoding", "request"))
-
+
return reply
diff --git a/tests/test_matchfilterelement.py b/tests/test_matchfilterelement.py
index ea070f7..a811cdc 100644
--- a/tests/test_matchfilterelement.py
+++ b/tests/test_matchfilterelement.py
@@ -85,4 +85,3 @@ missing.
with self.assertRaisesRegexp(ValueError, "time-range missing both start and stop attribute"):
xmlutils.match_filter(item, filter_element)
# The text vcalendar entry is either before or after the cutoff point.
-
--
2.11.0
More information about the Calypso
mailing list