From 7bfc17a51def496236ce8b4c3900e7fe19540d12 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 1 Mar 2012 10:40:15 +0100 Subject: [PATCH] Use " instead of ' (you can laugh at me) --- radicale/__init__.py | 10 +++++----- radicale/__main__.py | 10 +++++----- radicale/config.py | 4 ++-- radicale/ical.py | 5 ++--- radicale/storage/filesystem.py | 2 +- radicale/xmlutils.py | 18 +++++++++--------- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 894daff2..aa240873 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -114,7 +114,7 @@ class Application(object): self.acl = acl.load() storage.load() self.encoding = config.get("encoding", "request") - if config.getboolean('logging', 'full_environment'): + if config.getboolean("logging", "full_environment"): self.headers_log = lambda environ: environ # This method is overriden in __init__ if full_environment is set @@ -342,10 +342,10 @@ class Application(object): """Manage MKCALENDAR request.""" collection = collections[0] props = xmlutils.props_from_request(content) - timezone = props.get('C:calendar-timezone') + timezone = props.get("C:calendar-timezone") if timezone: - collection.replace('', timezone) - del props['C:calendar-timezone'] + collection.replace("", timezone) + del props["C:calendar-timezone"] with collection.props as collection_props: for key, value in props.items(): collection_props[key] = value @@ -443,7 +443,7 @@ class Application(object): def report(self, environ, collections, content, user): """Manage REPORT request.""" collection = collections[0] - headers = {'Content-Type': 'text/xml'} + headers = {"Content-Type": "text/xml"} answer = xmlutils.report(environ["PATH_INFO"], content, collection) return client.MULTI_STATUS, headers, answer diff --git a/radicale/__main__.py b/radicale/__main__.py index a789864b..b2a0da6f 100644 --- a/radicale/__main__.py +++ b/radicale/__main__.py @@ -95,7 +95,7 @@ def run(): if pid: try: if options.pid: - open(options.pid, 'w').write(str(pid)) + open(options.pid, "w").write(str(pid)) finally: sys.exit() sys.stdout = sys.stderr = open(os.devnull, "w") @@ -116,9 +116,9 @@ def run(): server_class = radicale.HTTPSServer if options.ssl else radicale.HTTPServer shutdown_program = threading.Event() - for host in options.hosts.split(','): - address, port = host.strip().rsplit(':', 1) - address, port = address.strip('[] '), int(port) + for host in options.hosts.split(","): + address, port = host.strip().rsplit(":", 1) + address, port = address.strip("[] "), int(port) servers.append( make_server(address, port, radicale.Application(), server_class, radicale.RequestHandler)) @@ -174,5 +174,5 @@ def run(): # pylint: enable=R0912,R0914 -if __name__ == '__main__': +if __name__ == "__main__": run() diff --git a/radicale/config.py b/radicale/config.py index 31b0d531..887a3260 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -83,8 +83,8 @@ for section, values in INITIAL_CONFIG.items(): _CONFIG_PARSER.read("/etc/radicale/config") _CONFIG_PARSER.read(os.path.expanduser("~/.config/radicale/config")) -if 'RADICALE_CONFIG' in os.environ: - _CONFIG_PARSER.read(os.environ['RADICALE_CONFIG']) +if "RADICALE_CONFIG" in os.environ: + _CONFIG_PARSER.read(os.environ["RADICALE_CONFIG"]) # Wrap config module into ConfigParser instance sys.modules[__name__] = _CONFIG_PARSER diff --git a/radicale/ical.py b/radicale/ical.py index 18164d61..d4608c7a 100644 --- a/radicale/ical.py +++ b/radicale/ical.py @@ -177,7 +177,7 @@ class Collection(object): """ self.encoding = "utf-8" split_path = path.split("/") - self.path = path if path != '.' else '' + self.path = path if path != "." else "" if principal and split_path and self.is_node(self.path): # Already existing principal collection self.owner = split_path[0] @@ -428,8 +428,7 @@ class Collection(object): def name(self): """Collection name.""" with self.props as props: - return props.get('D:displayname', - self.path.split(os.path.sep)[-1]) + return props.get("D:displayname", self.path.split(os.path.sep)[-1]) @property def headers(self): diff --git a/radicale/storage/filesystem.py b/radicale/storage/filesystem.py index 54b4c595..546a32f4 100644 --- a/radicale/storage/filesystem.py +++ b/radicale/storage/filesystem.py @@ -110,7 +110,7 @@ class Collection(ical.Collection): yield properties # On exit self._create_dirs() - with open(self._props_path, 'w') as prop_file: + with open(self._props_path, "w") as prop_file: json.dump(properties, prop_file) diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index ea3843e4..b0ae4fb7 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -106,11 +106,11 @@ def _tag_from_clark(name): """ match = CLARK_TAG_REGEX.match(name) - if match and match.group('namespace') in NAMESPACES_REV: + if match and match.group("namespace") in NAMESPACES_REV: args = { - 'ns': NAMESPACES_REV[match.group('namespace')], - 'tag': match.group('tag')} - return '%(ns)s:%(tag)s' % args + "ns": NAMESPACES_REV[match.group("namespace")], + "tag": match.group("tag")} + return "%(ns)s:%(tag)s" % args return name @@ -257,7 +257,7 @@ def _propfind_response(path, item, props, user): # pylint: enable=W0511 elif tag == _tag("D", "current-user-principal") and user: tag = ET.Element(_tag("D", "href")) - tag.text = '/%s/' % user + tag.text = "/%s/" % user element.append(tag) elif tag == _tag("D", "current-user-privilege-set"): privilege = ET.Element(_tag("D", "privilege")) @@ -339,10 +339,10 @@ def _add_propstat_to(element, tag, status_number): prop = ET.Element(_tag("D", "prop")) propstat.append(prop) - if '{' in tag: + if "{" in tag: clark_tag = tag else: - clark_tag = _tag(*tag.split(':', 1)) + clark_tag = _tag(*tag.split(":", 1)) prop_tag = ET.Element(clark_tag) prop.append(prop_tag) @@ -359,8 +359,8 @@ def proppatch(path, xml_request, collection): """ # Reading request root = ET.fromstring(xml_request.encode("utf8")) - props_to_set = props_from_request(root, actions=('set',)) - props_to_remove = props_from_request(root, actions=('remove',)) + props_to_set = props_from_request(root, actions=("set",)) + props_to_remove = props_from_request(root, actions=("remove",)) # Writing answer multistatus = ET.Element(_tag("D", "multistatus"))