Log message for revision 122282: replace map+lambda with list comprehensions
Changed: U Zope/trunk/src/App/CacheManager.py U Zope/trunk/src/OFS/Cache.py U Zope/trunk/src/OFS/CopySupport.py U Zope/trunk/src/OFS/ObjectManager.py U Zope/trunk/src/OFS/PropertyManager.py U Zope/trunk/src/OFS/PropertySheets.py U Zope/trunk/src/Products/Five/browser/__init__.py U Zope/trunk/src/ZPublisher/BaseRequest.py U Zope/trunk/src/ZPublisher/HTTPRequest.py U Zope/trunk/src/webdav/Resource.py -=- Modified: Zope/trunk/src/App/CacheManager.py =================================================================== --- Zope/trunk/src/App/CacheManager.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/App/CacheManager.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -97,8 +97,7 @@ if REQUEST is not None: # format as text REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain') - return '\n'.join(map(lambda (name, count): '%6d %s' % - (count, name), detail)) + return '\n'.join('%6d %s'%(count, name) for count, name in detail) else: # raw return detail @@ -110,8 +109,7 @@ detail = self._getDB().cacheExtremeDetail() if REQUEST is not None: # sort the list. - lst = map(lambda dict: ((dict['conn_no'], dict['oid']), dict), - detail) + lst = [((dict['conn_no'], dict['oid']), dict) for dict in detail] # format as text. res = [ '# Table shows connection number, oid, refcount, state, ' Modified: Zope/trunk/src/OFS/Cache.py =================================================================== --- Zope/trunk/src/OFS/Cache.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/OFS/Cache.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -438,7 +438,7 @@ ids = getVerifiedManagerIds(container) id = self.getId() if id in ids: - manager_ids = filter(lambda s, id=id: s != id, ids) + manager_ids = [s for s in ids if s != id] if manager_ids: setattr(container, ZCM_MANAGERS, manager_ids) elif getattr(aq_base(self), ZCM_MANAGERS, None) is not None: Modified: Zope/trunk/src/OFS/CopySupport.py =================================================================== --- Zope/trunk/src/OFS/CopySupport.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/OFS/CopySupport.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -92,7 +92,7 @@ return self._getOb(REQUEST['ids'][0]) def manage_CopyContainerAllItems(self, REQUEST): - return map(lambda i, s=self: s._getOb(i), tuple(REQUEST['ids'])) + return [self._getOb(i) for i in REQUEST['ids']] security.declareProtected(delete_objects, 'manage_cutObjects') def manage_cutObjects(self, ids=None, REQUEST=None): Modified: Zope/trunk/src/OFS/ObjectManager.py =================================================================== --- Zope/trunk/src/OFS/ObjectManager.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/OFS/ObjectManager.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -428,7 +428,7 @@ def objectMap(self): # Return a tuple of mappings containing subobject meta-data - return tuple(map(lambda dict: dict.copy(), self._objects)) + return tuple(d.copy() for d in self._objects) def objectIds_d(self, t=None): if hasattr(self, '_reserved_names'): n=self._reserved_names @@ -689,7 +689,7 @@ globbing = REQUEST.environ.get('GLOBBING','') if globbing : - files = filter(lambda x,g=globbing: fnmatch.fnmatch(x[0],g), files) + files = [x for x in files if fnmatch.fnmatch(x[0],globbing)] files.sort() Modified: Zope/trunk/src/OFS/PropertyManager.py =================================================================== --- Zope/trunk/src/OFS/PropertyManager.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/OFS/PropertyManager.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -210,27 +210,26 @@ if not self.hasProperty(id): raise ValueError, 'The property %s does not exist' % escape(id) self._delPropValue(id) - self._properties=tuple(filter(lambda i, n=id: i['id'] != n, - self._properties)) + self._properties=tuple(i for i in self._properties if i['id'] != id) security.declareProtected(access_contents_information, 'propertyIds') def propertyIds(self): """Return a list of property ids. """ - return map(lambda i: i['id'], self._properties) + return [i['id'] for i in self._properties] security.declareProtected(access_contents_information, 'propertyValues') def propertyValues(self): """Return a list of actual property objects. """ - return map(lambda i,s=self: getattr(s,i['id']), self._properties) + return [getattr(self, i['id']) for i in self._properties] security.declareProtected(access_contents_information, 'propertyItems') def propertyItems(self): """Return a list of (id,property) tuples. """ - return map(lambda i,s=self: (i['id'],getattr(s,i['id'])), - self._properties) + return [(i['id'], getattr(self, i['id'])) for i in self._properties] + def _propertyMap(self): """Return a tuple of mappings, giving meta-data for properties. """ @@ -242,7 +241,7 @@ Return copies of the real definitions for security. """ - return tuple(map(lambda dict: dict.copy(), self._propertyMap())) + return tuple(dict.copy() for dict in self._propertyMap()) security.declareProtected(access_contents_information, 'propertyLabel') def propertyLabel(self, id): Modified: Zope/trunk/src/OFS/PropertySheets.py =================================================================== --- Zope/trunk/src/OFS/PropertySheets.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/OFS/PropertySheets.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -258,25 +258,22 @@ raise BadRequest, '%s cannot be deleted.' % escape(id) delattr(vself, id) pself=self.p_self() - pself._properties=tuple(filter(lambda i, n=id: i['id'] != n, - pself._properties)) + pself._properties=tuple(i for i in pself._properties if i['id'] != id) security.declareProtected(access_contents_information, 'propertyIds') def propertyIds(self): # Return a list of property ids. - return map(lambda i: i['id'], self._propertyMap()) + return [i['id'] for i in self._propertyMap()] security.declareProtected(access_contents_information, 'propertyValues') def propertyValues(self): # Return a list of property values. - return map(lambda i, s=self: s.getProperty(i['id']), - self._propertyMap()) + return [self.getProperty(i['id']) for i in self._propertyMap()] security.declareProtected(access_contents_information, 'propertyItems') def propertyItems(self): # Return a list of (id, property) tuples. - return map(lambda i, s=self: (i['id'], s.getProperty(i['id'])), - self._propertyMap()) + return [(i['id'], self.getProperty(i['id'])) for i in self._propertyMap()] security.declareProtected(access_contents_information, 'propertyInfo') def propertyInfo(self, id): @@ -292,7 +289,7 @@ security.declareProtected(access_contents_information, 'propertyMap') def propertyMap(self): # Returns a secure copy of the property definitions. - return tuple(map(lambda dict: dict.copy(), self._propertyMap())) + return tuple(dict.copy() for dict in self._propertyMap()) def _propdict(self): dict={} @@ -327,8 +324,7 @@ attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: # It's a xml property. Don't escape value. - attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) - attrs=''.join(attrs) + attrs=''.join(' %s="%s"' % n for n in attrs.items()) else: # It's a non-xml property. Escape value. attrs='' @@ -381,8 +377,7 @@ attrs=item.get('meta', {}).get('__xml_attrs__', None) if attrs is not None: # It's a xml property. Don't escape value. - attrs=map(lambda n: ' %s="%s"' % n, attrs.items()) - attrs=''.join(attrs) + attrs=''.join(' %s="%s"' % n for n in attrs.items()) else: # It's a non-xml property. Escape value. attrs='' @@ -539,7 +534,7 @@ return self.pm def propertyMap(self): - return map(lambda dict: dict.copy(), self._propertyMap()) + return [dict.copy() for dict in self._propertyMap()] def dav__creationdate(self): return iso8601_date(43200.0) @@ -648,7 +643,7 @@ security.declareProtected(access_contents_information, 'values') def values(self): propsets=self.__propsets__() - return map(lambda n, s=self: n.__of__(s), propsets) + return [n.__of__(self) for n in propsets] security.declareProtected(access_contents_information, 'items') def items(self): Modified: Zope/trunk/src/Products/Five/browser/__init__.py =================================================================== --- Zope/trunk/src/Products/Five/browser/__init__.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/Products/Five/browser/__init__.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -25,7 +25,8 @@ # Use an explicit __init__ to work around problems with magically inserted # super classes when using BrowserView as a base for viewlets. def __init__(self, context, request): - zope.publisher.browser.BrowserView.__init__(self, context, request) + self.context = context + self.request = request # Classes which are still based on Acquisition and access # self.context in a method need to call aq_inner on it, or get a Modified: Zope/trunk/src/ZPublisher/BaseRequest.py =================================================================== --- Zope/trunk/src/ZPublisher/BaseRequest.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/ZPublisher/BaseRequest.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -312,7 +312,7 @@ def __str__(self): L1 = self.items() L1.sort() - return '\n'.join(map(lambda item: "%s:\t%s" % item, L1)) + return '\n'.join("%s:\t%s" % item for item in L1) __repr__=__str__ Modified: Zope/trunk/src/ZPublisher/HTTPRequest.py =================================================================== --- Zope/trunk/src/ZPublisher/HTTPRequest.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/ZPublisher/HTTPRequest.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -1731,14 +1731,14 @@ def __str__(self): L1 = self.__dict__.items() L1.sort() - return ", ".join(map(lambda item: "%s: %s" % item, L1)) + return ", ".join("%s: %s" % item for item in L1) def __repr__(self): #return repr( self.__dict__ ) L1 = self.__dict__.items() L1.sort() return '{%s}' % ', '.join( - map(lambda item: "'%s': %s" % (item[0], repr(item[1])), L1)) + "'%s': %s" % (item[0], repr(item[1])) for item in L1) def __cmp__(self, other): return (cmp(type(self), type(other)) or Modified: Zope/trunk/src/webdav/Resource.py =================================================================== --- Zope/trunk/src/webdav/Resource.py 2011-07-18 18:44:15 UTC (rev 122281) +++ Zope/trunk/src/webdav/Resource.py 2011-07-18 18:59:50 UTC (rev 122282) @@ -149,7 +149,6 @@ # the final part of the URL (ie '/a/b/foo.html' becomes '/a/b/') if col: url = url[:url.rfind('/')+1] - havetag = lambda x, self=self: self.wl_hasLock(x) found = 0; resourcetagged = 0 taglist = IfParser(ifhdr) for tag in taglist: @@ -157,7 +156,7 @@ if not tag.resource: # There's no resource (url) with this tag tag_list = map(tokenFinder, tag.list) - wehave = filter(havetag, tag_list) + wehave = [tag for tag in tag_list if self.wl_hasLock(tag)] if not wehave: continue if tag.NOTTED: continue @@ -168,7 +167,7 @@ elif urlbase(tag.resource) == url: resourcetagged = 1 tag_list = map(tokenFinder, tag.list) - wehave = filter(havetag, tag_list) + wehave = [tag for tag in tag_list if self.wl_hasLock(tag)] if not wehave: continue if tag.NOTTED: continue _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins