[CalendarServer-changes] [10706] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Feb 12 14:16:23 PST 2013


Revision: 10706
          http://trac.calendarserver.org//changeset/10706
Author:   cdaboo at apple.com
Date:     2013-02-12 14:16:23 -0800 (Tue, 12 Feb 2013)
Log Message:
-----------
Fix pyflake complaints.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py
    CalendarServer/trunk/twistedcaldav/memcacheprops.py
    CalendarServer/trunk/twistedcaldav/resource.py
    CalendarServer/trunk/twistedcaldav/sharing.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/txdav/base/propertystore/appledouble_xattr.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py

Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2013-02-12 21:44:50 UTC (rev 10705)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_proxyprincipalmembers.py	2013-02-12 22:16:23 UTC (rev 10706)
@@ -142,7 +142,7 @@
     def _proxyForTest(self, recordType, recordName, expectedProxies, read_write):
         principal = self._getPrincipalByShortName(recordType, recordName)
         proxies = (yield principal.proxyFor(read_write))
-        proxies = sorted([principal.displayName() for principal in proxies])
+        proxies = sorted([_principal.displayName() for _principal in proxies])
         self.assertEquals(proxies, sorted(expectedProxies))
 
 

Modified: CalendarServer/trunk/twistedcaldav/memcacheprops.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/memcacheprops.py	2013-02-12 21:44:50 UTC (rev 10705)
+++ CalendarServer/trunk/twistedcaldav/memcacheprops.py	2013-02-12 22:16:23 UTC (rev 10706)
@@ -7,10 +7,10 @@
 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 # copies of the Software, and to permit persons to whom the Software is
 # furnished to do so, subject to the following conditions:
-# 
+#
 # The above copyright notice and this permission notice shall be included in all
 # copies or substantial portions of the Software.
-# 
+#
 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -55,6 +55,7 @@
         self.collection = collection
         self.cacheTimeout = cacheTimeout
 
+
     @classmethod
     def memcacheClient(cls, refresh=False):
         if not hasattr(MemcachePropertyCollection, "_memcacheClient"):
@@ -71,6 +72,7 @@
 
         return MemcachePropertyCollection._memcacheClient
 
+
     def propertyCache(self):
         # The property cache has this format:
         #  {
@@ -88,6 +90,7 @@
             self._propertyCache = self._loadCache()
         return self._propertyCache
 
+
     def childCache(self, child):
         path = child.fp.path
         key = self._keyForPath(path)
@@ -105,6 +108,7 @@
 
         return propertyCache, key, childCache, token
 
+
     def _keyForPath(self, path):
         key = "|".join((
             self.__class__.__name__,
@@ -112,6 +116,7 @@
         ))
         return md5(key).hexdigest()
 
+
     def _loadCache(self, childNames=None):
         if childNames is None:
             abortIfMissing = False
@@ -134,7 +139,7 @@
             for childName in childNames
         ))
 
-        result = self._split_gets_multi((key for key, name in keys),
+        result = self._split_gets_multi((key for key, _ignore_name in keys),
             client.gets_multi)
 
         if self.logger.willLogAtLevel("debug"):
@@ -145,7 +150,7 @@
             self.log_debug("Loaded keys for %schildren of %s: %s" % (
                 missing,
                 self.collection,
-                [name for key, name in keys],
+                [name for _ignore_key, name in keys],
             ))
 
         missing = tuple((
@@ -187,6 +192,7 @@
             results.update(func(subset))
         return results
 
+
     def _split_set_multi(self, values, func, time=0, chunksize=250):
         """
         Splits set_multi into chunks to avoid a memcacheclient timeout due
@@ -221,6 +227,7 @@
             self._split_set_multi(values, client.set_multi,
                 time=self.cacheTimeout)
 
+
     def _buildCache(self, childNames=None):
         if childNames is None:
             childNames = self.collection.listChildren()
@@ -247,13 +254,14 @@
 
         return cache
 
+
     def setProperty(self, child, property, uid, delete=False):
         propertyCache, key, childCache, token = self.childCache(child)
 
         if delete:
             qname = property
             qnameuid = qname + (uid,)
-            if childCache.has_key(qnameuid):
+            if qnameuid in childCache:
                 del childCache[qnameuid]
         else:
             qname = property.qname()
@@ -286,7 +294,7 @@
                 propertyCache, key, childCache, token = self.childCache(child)
 
                 if delete:
-                    if childCache.has_key(qnameuid):
+                    if qnameuid in childCache:
                         del childCache[qnameuid]
                 else:
                     childCache[qnameuid] = property
@@ -301,9 +309,11 @@
                     child
                 ))
 
+
     def deleteProperty(self, child, qname, uid):
         return self.setProperty(child, qname, uid, delete=True)
 
+
     def flushCache(self, child):
         path = child.fp.path
         key = self._keyForPath(path)
@@ -318,9 +328,11 @@
             if not result:
                 raise MemcacheError("Unable to flush cache on %s" % (child,))
 
+
     def propertyStoreForChild(self, child, childPropertyStore):
         return self.ChildPropertyStore(self, child, childPropertyStore)
 
+
     class ChildPropertyStore (LoggingMixIn):
         def __init__(self, parentPropertyCollection, child, childPropertyStore):
             self.parentPropertyCollection = parentPropertyCollection
@@ -393,14 +405,13 @@
                 propertyCache = self.propertyCache()
                 results = propertyCache.keys()
                 if filterByUID:
-                    return [ 
+                    return [
                         (namespace, name)
                         for namespace, name, propuid in results
                         if propuid == uid
                     ]
                 else:
                     return results
-                
 
             self.log_debug("List for %s"
                            % (self.childPropertyStore.resource.fp.path,))

Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py	2013-02-12 21:44:50 UTC (rev 10705)
+++ CalendarServer/trunk/twistedcaldav/resource.py	2013-02-12 22:16:23 UTC (rev 10706)
@@ -1450,7 +1450,7 @@
 
                         # Always test against the current etag first just in case schedule-etags is out of sync
                         etag = (yield self.etag())
-                        etags = (etag,) + tuple([http_headers.ETag(etag) for etag in etags])
+                        etags = (etag,) + tuple([http_headers.ETag(schedule_etag) for schedule_etag in etags])
 
                         # Loop over each tag and succeed if any one matches, else re-raise last exception
                         exists = self.exists()
@@ -1974,7 +1974,7 @@
         elif namespace == carddav_namespace and self.addressBooksEnabled():
             if name == "addressbook-home-set":
                 returnValue(carddavxml.AddressBookHomeSet(
-                    *[element.HRef(url) for url in self.addressBookHomeURLs()]
+                    *[element.HRef(abhome_url) for abhome_url in self.addressBookHomeURLs()]
                  ))
             elif name == "directory-gateway" and self.directoryAddressBookEnabled():
                 returnValue(carddavxml.DirectoryGateway(

Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py	2013-02-12 21:44:50 UTC (rev 10705)
+++ CalendarServer/trunk/twistedcaldav/sharing.py	2013-02-12 22:16:23 UTC (rev 10706)
@@ -516,7 +516,7 @@
         if type(cn) is not list:
             cn = [cn]
 
-        dl = [self.inviteSingleUserToShare(user, cn, ace, summary, request) for user, cn in zip(userid, cn)]
+        dl = [self.inviteSingleUserToShare(_user, _cn, ace, summary, request) for _user, _cn in zip(userid, cn)]
         return self._processShareActionList(dl, resultIsList)
 
 
@@ -546,7 +546,7 @@
         if type(cn) is not list:
             cn = [cn]
 
-        dl = [self.inviteSingleUserUpdateToShare(user, cn, aceOLD, aceNEW, summary, request) for user, cn in zip(userid, cn)]
+        dl = [self.inviteSingleUserUpdateToShare(_user, _cn, aceOLD, aceNEW, summary, request) for _user, _cn in zip(userid, cn)]
         return self._processShareActionList(dl, resultIsList)
 
 

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2013-02-12 21:44:50 UTC (rev 10705)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2013-02-12 22:16:23 UTC (rev 10706)
@@ -1282,17 +1282,17 @@
 
     configDict.AdminACEs = tuple(
         davxml.ACE(
-            davxml.Principal(davxml.HRef(principal)),
+            davxml.Principal(davxml.HRef(admin_principal)),
             davxml.Grant(davxml.Privilege(davxml.All())),
             davxml.Protected(),
             TwistedACLInheritable(),
         )
-        for principal in configDict.AdminPrincipals
+        for admin_principal in configDict.AdminPrincipals
     )
 
     configDict.ReadACEs = tuple(
         davxml.ACE(
-            davxml.Principal(davxml.HRef(principal)),
+            davxml.Principal(davxml.HRef(read_principal)),
             davxml.Grant(
                 davxml.Privilege(davxml.Read()),
                 davxml.Privilege(davxml.ReadCurrentUserPrivilegeSet()),
@@ -1300,7 +1300,7 @@
             davxml.Protected(),
             TwistedACLInheritable(),
         )
-        for principal in configDict.ReadPrincipals
+        for read_principal in configDict.ReadPrincipals
     )
 
     configDict.RootResourceACL = davxml.ACL(
@@ -1320,7 +1320,7 @@
         # Add read and read-acl access for admins
         * [
             davxml.ACE(
-                davxml.Principal(davxml.HRef(principal)),
+                davxml.Principal(davxml.HRef(_principal)),
                 davxml.Grant(
                     davxml.Privilege(davxml.Read()),
                     davxml.Privilege(davxml.ReadACL()),
@@ -1328,7 +1328,7 @@
                 ),
                 davxml.Protected(),
             )
-            for principal in configDict.AdminPrincipals
+            for _principal in configDict.AdminPrincipals
         ]
     )
 

Modified: CalendarServer/trunk/txdav/base/propertystore/appledouble_xattr.py
===================================================================
--- CalendarServer/trunk/txdav/base/propertystore/appledouble_xattr.py	2013-02-12 21:44:50 UTC (rev 10705)
+++ CalendarServer/trunk/txdav/base/propertystore/appledouble_xattr.py	2013-02-12 22:16:23 UTC (rev 10706)
@@ -25,32 +25,32 @@
 # http://www.opensource.apple.com/source/Libc/Libc-391/darwin/copyfile.c
 
 # File header format: magic, version, unused, number of entries
-AS_HEADER_FORMAT=">LL16sh"
-AS_HEADER_LENGTH=26
+AS_HEADER_FORMAT = ">LL16sh"
+AS_HEADER_LENGTH = 26
 
 # The flag words for AppleDouble
-AS_MAGIC=0x00051607
-AS_VERSION=0x00020000
+AS_MAGIC = 0x00051607
+AS_VERSION = 0x00020000
 
 # Entry header format: id, offset, length
-AS_ENTRY_FORMAT=">lll"
-AS_ENTRY_LENGTH=12
+AS_ENTRY_FORMAT = ">lll"
+AS_ENTRY_LENGTH = 12
 
 # The id values
-AS_DATAFORK=1
-AS_RESOURCEFORK=2
-AS_REALNAME=3
-AS_COMMENT=4
-AS_ICONBW=5
-AS_ICONCOLOR=6
-AS_DATESINFO=8
-AS_FINDERINFO=9
-AS_MACFILEINFO=10
-AS_PRODOSFILEINFO=11
-AS_MSDOSFILEINFO=12
-AS_SHORTNAME=13
-AS_AFPFILEINFO=14
-AS_DIECTORYID=15
+AS_DATAFORK = 1
+AS_RESOURCEFORK = 2
+AS_REALNAME = 3
+AS_COMMENT = 4
+AS_ICONBW = 5
+AS_ICONCOLOR = 6
+AS_DATESINFO = 8
+AS_FINDERINFO = 9
+AS_MACFILEINFO = 10
+AS_PRODOSFILEINFO = 11
+AS_MSDOSFILEINFO = 12
+AS_SHORTNAME = 13
+AS_AFPFILEINFO = 14
+AS_DIECTORYID = 15
 
 FINDER_INFO_LENGTH = 32
 XATTR_OFFSET = FINDER_INFO_LENGTH + 2
@@ -93,7 +93,7 @@
         raise ValueError("AppleDouble file contains no forks")
 
     # Get each entry
-    headers = [fileobj.read(AS_ENTRY_LENGTH) for _ignore in xrange(nentry)]
+    headers = [fileobj.read(AS_ENTRY_LENGTH) for _ignore_count in xrange(nentry)]
     for hdr in headers:
         try:
             restype, offset, length = struct.unpack(AS_ENTRY_FORMAT, hdr)
@@ -109,9 +109,9 @@
             # Get the xattr header
             fileobj.seek(offset + XATTR_OFFSET)
             data = fileobj.read(length - XATTR_OFFSET)
-            if len(data) != length-XATTR_OFFSET:
+            if len(data) != length - XATTR_OFFSET:
                 raise ValueError("Short read: expected %d bytes got %d" %
-                                 (length-XATTR_OFFSET, len(data)))
+                                 (length - XATTR_OFFSET, len(data)))
             magic, _ignore_tag, total_size, data_start, data_length, \
             _ignore_reserved1, _ignore_reserved2, _ignore_reserved3, \
             flags, num_attrs = struct.unpack(XATTR_HEADER,
@@ -138,7 +138,7 @@
                 xattr_name = data[
                     XATTR_ENTRY_LENGTH:
                     XATTR_ENTRY_LENGTH + xattr_name_len
-                    -1 # strip NULL terminator
+                    - 1 # strip NULL terminator
                 ]
                 fileobj.seek(xattr_offset)
                 xattr_value = fileobj.read(xattr_length)
@@ -184,9 +184,6 @@
     @property
     def attrs(self):
         try:
-            return attrsFromFile(self.path.sibling("._"+self.path.basename()).open())
+            return attrsFromFile(self.path.sibling("._" + self.path.basename()).open())
         except IOError:
             return {}
-
-
-

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2013-02-12 21:44:50 UTC (rev 10705)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_attachments.py	2013-02-12 22:16:23 UTC (rev 10706)
@@ -218,7 +218,7 @@
         self.assertEquals(contentType, MimeType("text", "x-fixture"))
         self.assertEquals(attachment.md5(), '50a9f27aeed9247a0833f30a631f1858')
         self.assertEquals(
-            [attachment.name() for attachment in (yield obj.attachments())],
+            [_attachment.name() for _attachment in (yield obj.attachments())],
             ['new.attachment']
         )
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130212/67e3d11a/attachment-0001.html>


More information about the calendarserver-changes mailing list