Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
cea3fed4
Commit
cea3fed4
authored
Jul 18, 2011
by
Nikolay Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace map/lambda with list comprehension
parent
19ba01dc
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
29 additions
and
37 deletions
+29
-37
src/App/ApplicationManager.py
src/App/ApplicationManager.py
+1
-1
src/App/CacheManager.py
src/App/CacheManager.py
+2
-4
src/OFS/Cache.py
src/OFS/Cache.py
+1
-1
src/OFS/CopySupport.py
src/OFS/CopySupport.py
+1
-1
src/OFS/ObjectManager.py
src/OFS/ObjectManager.py
+2
-2
src/OFS/PropertyManager.py
src/OFS/PropertyManager.py
+6
-7
src/OFS/PropertySheets.py
src/OFS/PropertySheets.py
+9
-14
src/Products/Five/browser/__init__.py
src/Products/Five/browser/__init__.py
+2
-1
src/ZPublisher/BaseRequest.py
src/ZPublisher/BaseRequest.py
+1
-1
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+2
-2
src/webdav/Resource.py
src/webdav/Resource.py
+2
-3
No files found.
src/App/ApplicationManager.py
View file @
cea3fed4
...
@@ -464,7 +464,7 @@ class ApplicationManager(Folder,CacheManager):
...
@@ -464,7 +464,7 @@ class ApplicationManager(Folder,CacheManager):
introduced in 2.4.
introduced in 2.4.
"""
"""
meta_types
=
map
(
lambda
x
:
x
.
get
(
'meta_type'
,
None
),
self
.
_objects
)
meta_types
=
[
x
.
get
(
'meta_type'
,
None
)
for
x
in
self
.
_objects
]
if
not
self
.
DavLocks
.
meta_type
in
meta_types
:
if
not
self
.
DavLocks
.
meta_type
in
meta_types
:
...
...
src/App/CacheManager.py
View file @
cea3fed4
...
@@ -102,8 +102,7 @@ class CacheManager:
...
@@ -102,8 +102,7 @@ class CacheManager:
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
# format as text
# format as text
REQUEST
.
RESPONSE
.
setHeader
(
'Content-Type'
,
'text/plain'
)
REQUEST
.
RESPONSE
.
setHeader
(
'Content-Type'
,
'text/plain'
)
return
'
\
n
'
.
join
(
map
(
lambda
(
name
,
count
):
'%6d %s'
%
return
'
\
n
'
.
join
(
'%6d %s'
%
(
count
,
name
)
for
count
,
name
in
detail
)
(
count
,
name
),
detail
))
else
:
else
:
# raw
# raw
return
detail
return
detail
...
@@ -115,8 +114,7 @@ class CacheManager:
...
@@ -115,8 +114,7 @@ class CacheManager:
detail
=
self
.
_getDB
().
cacheExtremeDetail
()
detail
=
self
.
_getDB
().
cacheExtremeDetail
()
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
# sort the list.
# sort the list.
lst
=
map
(
lambda
dict
:
((
dict
[
'conn_no'
],
dict
[
'oid'
]),
dict
),
lst
=
[((
dict
[
'conn_no'
],
dict
[
'oid'
]),
dict
)
for
dict
in
detail
]
detail
)
# format as text.
# format as text.
res
=
[
res
=
[
'# Table shows connection number, oid, refcount, state, '
'# Table shows connection number, oid, refcount, state, '
...
...
src/OFS/Cache.py
View file @
cea3fed4
...
@@ -439,7 +439,7 @@ class CacheManager:
...
@@ -439,7 +439,7 @@ class CacheManager:
ids
=
getVerifiedManagerIds
(
container
)
ids
=
getVerifiedManagerIds
(
container
)
id
=
self
.
getId
()
id
=
self
.
getId
()
if
id
in
ids
:
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
:
if
manager_ids
:
setattr
(
container
,
ZCM_MANAGERS
,
manager_ids
)
setattr
(
container
,
ZCM_MANAGERS
,
manager_ids
)
elif
getattr
(
aq_base
(
self
),
ZCM_MANAGERS
,
None
)
is
not
None
:
elif
getattr
(
aq_base
(
self
),
ZCM_MANAGERS
,
None
)
is
not
None
:
...
...
src/OFS/CopySupport.py
View file @
cea3fed4
...
@@ -92,7 +92,7 @@ class CopyContainer(Base):
...
@@ -92,7 +92,7 @@ class CopyContainer(Base):
return
self
.
_getOb
(
REQUEST
[
'ids'
][
0
])
return
self
.
_getOb
(
REQUEST
[
'ids'
][
0
])
def
manage_CopyContainerAllItems
(
self
,
REQUEST
):
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'
)
security
.
declareProtected
(
delete_objects
,
'manage_cutObjects'
)
def
manage_cutObjects
(
self
,
ids
=
None
,
REQUEST
=
None
):
def
manage_cutObjects
(
self
,
ids
=
None
,
REQUEST
=
None
):
...
...
src/OFS/ObjectManager.py
View file @
cea3fed4
...
@@ -436,7 +436,7 @@ class ObjectManager(CopyContainer,
...
@@ -436,7 +436,7 @@ class ObjectManager(CopyContainer,
def
objectMap
(
self
):
def
objectMap
(
self
):
# Return a tuple of mappings containing subobject meta-data
# 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
):
def
objectIds_d
(
self
,
t
=
None
):
if
hasattr
(
self
,
'_reserved_names'
):
n
=
self
.
_reserved_names
if
hasattr
(
self
,
'_reserved_names'
):
n
=
self
.
_reserved_names
...
@@ -700,7 +700,7 @@ class ObjectManager(CopyContainer,
...
@@ -700,7 +700,7 @@ class ObjectManager(CopyContainer,
globbing
=
REQUEST
.
environ
.
get
(
'GLOBBING'
,
''
)
globbing
=
REQUEST
.
environ
.
get
(
'GLOBBING'
,
''
)
if
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
()
files
.
sort
()
...
...
src/OFS/PropertyManager.py
View file @
cea3fed4
...
@@ -212,27 +212,26 @@ class PropertyManager(Base, ElementWithAttributes):
...
@@ -212,27 +212,26 @@ class PropertyManager(Base, ElementWithAttributes):
if
not
self
.
hasProperty
(
id
):
if
not
self
.
hasProperty
(
id
):
raise
ValueError
,
'The property %s does not exist'
%
escape
(
id
)
raise
ValueError
,
'The property %s does not exist'
%
escape
(
id
)
self
.
_delPropValue
(
id
)
self
.
_delPropValue
(
id
)
self
.
_properties
=
tuple
(
filter
(
lambda
i
,
n
=
id
:
i
[
'id'
]
!=
n
,
self
.
_properties
=
tuple
(
i
for
i
in
self
.
_properties
if
i
[
'id'
]
!=
id
)
self
.
_properties
))
security
.
declareProtected
(
access_contents_information
,
'propertyIds'
)
security
.
declareProtected
(
access_contents_information
,
'propertyIds'
)
def
propertyIds
(
self
):
def
propertyIds
(
self
):
"""Return a list of property ids.
"""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'
)
security
.
declareProtected
(
access_contents_information
,
'propertyValues'
)
def
propertyValues
(
self
):
def
propertyValues
(
self
):
"""Return a list of actual property objects.
"""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'
)
security
.
declareProtected
(
access_contents_information
,
'propertyItems'
)
def
propertyItems
(
self
):
def
propertyItems
(
self
):
"""Return a list of (id,property) tuples.
"""Return a list of (id,property) tuples.
"""
"""
return
map
(
lambda
i
,
s
=
self
:
(
i
[
'id'
],
getattr
(
s
,
i
[
'id'
])),
return
[(
i
[
'id'
],
getattr
(
self
,
i
[
'id'
]))
for
i
in
self
.
_properties
]
self
.
_properties
)
def
_propertyMap
(
self
):
def
_propertyMap
(
self
):
"""Return a tuple of mappings, giving meta-data for properties.
"""Return a tuple of mappings, giving meta-data for properties.
"""
"""
...
@@ -244,7 +243,7 @@ class PropertyManager(Base, ElementWithAttributes):
...
@@ -244,7 +243,7 @@ class PropertyManager(Base, ElementWithAttributes):
Return copies of the real definitions for security.
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'
)
security
.
declareProtected
(
access_contents_information
,
'propertyLabel'
)
def
propertyLabel
(
self
,
id
):
def
propertyLabel
(
self
,
id
):
...
...
src/OFS/PropertySheets.py
View file @
cea3fed4
...
@@ -260,25 +260,22 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -260,25 +260,22 @@ class PropertySheet(Traversable, Persistent, Implicit):
raise
BadRequest
,
'%s cannot be deleted.'
%
escape
(
id
)
raise
BadRequest
,
'%s cannot be deleted.'
%
escape
(
id
)
delattr
(
vself
,
id
)
delattr
(
vself
,
id
)
pself
=
self
.
p_self
()
pself
=
self
.
p_self
()
pself
.
_properties
=
tuple
(
filter
(
lambda
i
,
n
=
id
:
i
[
'id'
]
!=
n
,
pself
.
_properties
=
tuple
(
i
for
i
in
pself
.
_properties
if
i
[
'id'
]
!=
id
)
pself
.
_properties
))
security
.
declareProtected
(
access_contents_information
,
'propertyIds'
)
security
.
declareProtected
(
access_contents_information
,
'propertyIds'
)
def
propertyIds
(
self
):
def
propertyIds
(
self
):
# Return a list of property ids.
# 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'
)
security
.
declareProtected
(
access_contents_information
,
'propertyValues'
)
def
propertyValues
(
self
):
def
propertyValues
(
self
):
# Return a list of property values.
# Return a list of property values.
return
map
(
lambda
i
,
s
=
self
:
s
.
getProperty
(
i
[
'id'
]),
return
[
self
.
getProperty
(
i
[
'id'
])
for
i
in
self
.
_propertyMap
()]
self
.
_propertyMap
())
security
.
declareProtected
(
access_contents_information
,
'propertyItems'
)
security
.
declareProtected
(
access_contents_information
,
'propertyItems'
)
def
propertyItems
(
self
):
def
propertyItems
(
self
):
# Return a list of (id, property) tuples.
# Return a list of (id, property) tuples.
return
map
(
lambda
i
,
s
=
self
:
(
i
[
'id'
],
s
.
getProperty
(
i
[
'id'
])),
return
[(
i
[
'id'
],
self
.
getProperty
(
i
[
'id'
]))
for
i
in
self
.
_propertyMap
()]
self
.
_propertyMap
())
security
.
declareProtected
(
access_contents_information
,
'propertyInfo'
)
security
.
declareProtected
(
access_contents_information
,
'propertyInfo'
)
def
propertyInfo
(
self
,
id
):
def
propertyInfo
(
self
,
id
):
...
@@ -294,7 +291,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -294,7 +291,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
security
.
declareProtected
(
access_contents_information
,
'propertyMap'
)
security
.
declareProtected
(
access_contents_information
,
'propertyMap'
)
def
propertyMap
(
self
):
def
propertyMap
(
self
):
# Returns a secure copy of the property definitions.
# 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
):
def
_propdict
(
self
):
dict
=
{}
dict
=
{}
...
@@ -329,8 +326,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -329,8 +326,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
if
attrs
is
not
None
:
if
attrs
is
not
None
:
# It's a xml property. Don't escape value.
# It's a xml property. Don't escape value.
attrs
=
map
(
lambda
n
:
' %s="%s"'
%
n
,
attrs
.
items
())
attrs
=
''
.
join
(
' %s="%s"'
%
n
for
n
in
attrs
.
items
())
attrs
=
''
.
join
(
attrs
)
else
:
else
:
# It's a non-xml property. Escape value.
# It's a non-xml property. Escape value.
attrs
=
''
attrs
=
''
...
@@ -383,8 +379,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
...
@@ -383,8 +379,7 @@ class PropertySheet(Traversable, Persistent, Implicit):
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
attrs
=
item
.
get
(
'meta'
,
{}).
get
(
'__xml_attrs__'
,
None
)
if
attrs
is
not
None
:
if
attrs
is
not
None
:
# It's a xml property. Don't escape value.
# It's a xml property. Don't escape value.
attrs
=
map
(
lambda
n
:
' %s="%s"'
%
n
,
attrs
.
items
())
attrs
=
''
.
join
(
' %s="%s"'
%
n
for
n
in
attrs
.
items
())
attrs
=
''
.
join
(
attrs
)
else
:
else
:
# It's a non-xml property. Escape value.
# It's a non-xml property. Escape value.
attrs
=
''
attrs
=
''
...
@@ -541,7 +536,7 @@ class DAVProperties(Virtual, PropertySheet, View):
...
@@ -541,7 +536,7 @@ class DAVProperties(Virtual, PropertySheet, View):
return
self
.
pm
return
self
.
pm
def
propertyMap
(
self
):
def
propertyMap
(
self
):
return
map
(
lambda
dict
:
dict
.
copy
(),
self
.
_propertyMap
())
return
[
dict
.
copy
()
for
dict
in
self
.
_propertyMap
()]
def
dav__creationdate
(
self
):
def
dav__creationdate
(
self
):
return
iso8601_date
(
43200.0
)
return
iso8601_date
(
43200.0
)
...
@@ -650,7 +645,7 @@ class PropertySheets(Traversable, Implicit, Tabs):
...
@@ -650,7 +645,7 @@ class PropertySheets(Traversable, Implicit, Tabs):
security
.
declareProtected
(
access_contents_information
,
'values'
)
security
.
declareProtected
(
access_contents_information
,
'values'
)
def
values
(
self
):
def
values
(
self
):
propsets
=
self
.
__propsets__
()
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'
)
security
.
declareProtected
(
access_contents_information
,
'items'
)
def
items
(
self
):
def
items
(
self
):
...
...
src/Products/Five/browser/__init__.py
View file @
cea3fed4
...
@@ -25,7 +25,8 @@ class BrowserView(zope.publisher.browser.BrowserView, AcquisitionBBB):
...
@@ -25,7 +25,8 @@ class BrowserView(zope.publisher.browser.BrowserView, AcquisitionBBB):
# Use an explicit __init__ to work around problems with magically inserted
# Use an explicit __init__ to work around problems with magically inserted
# super classes when using BrowserView as a base for viewlets.
# super classes when using BrowserView as a base for viewlets.
def
__init__
(
self
,
context
,
request
):
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
# Classes which are still based on Acquisition and access
# self.context in a method need to call aq_inner on it, or get a
# self.context in a method need to call aq_inner on it, or get a
...
...
src/ZPublisher/BaseRequest.py
View file @
cea3fed4
...
@@ -312,7 +312,7 @@ class BaseRequest:
...
@@ -312,7 +312,7 @@ class BaseRequest:
def
__str__
(
self
):
def
__str__
(
self
):
L1
=
self
.
items
()
L1
=
self
.
items
()
L1
.
sort
()
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__
__repr__
=
__str__
...
...
src/ZPublisher/HTTPRequest.py
View file @
cea3fed4
...
@@ -1726,14 +1726,14 @@ class record:
...
@@ -1726,14 +1726,14 @@ class record:
def
__str__
(
self
):
def
__str__
(
self
):
L1
=
self
.
__dict__
.
items
()
L1
=
self
.
__dict__
.
items
()
L1
.
sort
()
L1
.
sort
()
return
", "
.
join
(
map
(
lambda
item
:
"%s: %s"
%
item
,
L1
)
)
return
", "
.
join
(
"%s: %s"
%
item
for
item
in
L1
)
def
__repr__
(
self
):
def
__repr__
(
self
):
#return repr( self.__dict__ )
#return repr( self.__dict__ )
L1
=
self
.
__dict__
.
items
()
L1
=
self
.
__dict__
.
items
()
L1
.
sort
()
L1
.
sort
()
return
'{%s}'
%
', '
.
join
(
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
):
def
__cmp__
(
self
,
other
):
return
(
cmp
(
type
(
self
),
type
(
other
))
or
return
(
cmp
(
type
(
self
),
type
(
other
))
or
...
...
src/webdav/Resource.py
View file @
cea3fed4
...
@@ -149,7 +149,6 @@ class Resource(Base, LockableItem):
...
@@ -149,7 +149,6 @@ class Resource(Base, LockableItem):
# the final part of the URL (ie '/a/b/foo.html' becomes '/a/b/')
# the final part of the URL (ie '/a/b/foo.html' becomes '/a/b/')
if
col
:
url
=
url
[:
url
.
rfind
(
'/'
)
+
1
]
if
col
:
url
=
url
[:
url
.
rfind
(
'/'
)
+
1
]
havetag
=
lambda
x
,
self
=
self
:
self
.
wl_hasLock
(
x
)
found
=
0
;
resourcetagged
=
0
found
=
0
;
resourcetagged
=
0
taglist
=
IfParser
(
ifhdr
)
taglist
=
IfParser
(
ifhdr
)
for
tag
in
taglist
:
for
tag
in
taglist
:
...
@@ -157,7 +156,7 @@ class Resource(Base, LockableItem):
...
@@ -157,7 +156,7 @@ class Resource(Base, LockableItem):
if
not
tag
.
resource
:
if
not
tag
.
resource
:
# There's no resource (url) with this tag
# There's no resource (url) with this tag
tag_list
=
map
(
tokenFinder
,
tag
.
list
)
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
not
wehave
:
continue
if
tag
.
NOTTED
:
continue
if
tag
.
NOTTED
:
continue
...
@@ -168,7 +167,7 @@ class Resource(Base, LockableItem):
...
@@ -168,7 +167,7 @@ class Resource(Base, LockableItem):
elif
urlbase
(
tag
.
resource
)
==
url
:
elif
urlbase
(
tag
.
resource
)
==
url
:
resourcetagged
=
1
resourcetagged
=
1
tag_list
=
map
(
tokenFinder
,
tag
.
list
)
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
not
wehave
:
continue
if
tag
.
NOTTED
:
continue
if
tag
.
NOTTED
:
continue
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment