Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
10942ed172de
Commit
a8f4ba7a
authored
Sep 15, 2015
by
Rémi Cardona
Browse files
[py3k] dict.iteritems → dict.items
parent
e6eb0c7c2e98
Changes
78
Hide whitespace changes
Inline
Side-by-side
cwconfig.py
View file @
10942ed1
...
...
@@ -506,7 +506,7 @@ this option is set to yes",
deps
=
{}
else
:
deps
=
dict
(
(
x
[
len
(
'cubicweb-'
):],
v
)
for
x
,
v
in
gendeps
.
iter
items
()
for
x
,
v
in
gendeps
.
items
()
if
x
.
startswith
(
'cubicweb-'
))
for
depcube
in
deps
:
try
:
...
...
cwctl.py
View file @
10942ed1
...
...
@@ -773,7 +773,7 @@ given, appropriate sources for migration will be automatically selected \
vcconf
=
repo
.
get_versions
()
helper
=
self
.
config_helper
(
config
,
required
=
False
)
if
self
.
config
.
force_cube_version
:
for
cube
,
version
in
self
.
config
.
force_cube_version
.
iter
items
():
for
cube
,
version
in
self
.
config
.
force_cube_version
.
items
():
vcconf
[
cube
]
=
Version
(
version
)
toupgrade
=
[]
for
cube
in
config
.
cubes
():
...
...
@@ -1049,7 +1049,7 @@ class ConfigureInstanceCommand(InstanceCommand):
def
configure_instance
(
self
,
appid
):
if
self
.
config
.
param
is
not
None
:
appcfg
=
cwcfg
.
config_for
(
appid
)
for
key
,
value
in
self
.
config
.
param
.
iter
items
():
for
key
,
value
in
self
.
config
.
param
.
items
():
try
:
appcfg
.
global_set_option
(
key
,
value
)
except
KeyError
:
...
...
cwvreg.py
View file @
10942ed1
...
...
@@ -382,7 +382,7 @@ class CWRegistryStore(RegistryStore):
return
[
item
for
item
in
super
(
CWRegistryStore
,
self
).
items
()
if
not
item
[
0
]
in
(
'propertydefs'
,
'propertyvalues'
)]
def
iteritems
(
self
):
return
(
item
for
item
in
super
(
CWRegistryStore
,
self
).
iter
items
()
return
(
item
for
item
in
super
(
CWRegistryStore
,
self
).
items
()
if
not
item
[
0
]
in
(
'propertydefs'
,
'propertyvalues'
))
def
values
(
self
):
...
...
@@ -576,7 +576,7 @@ class CWRegistryStore(RegistryStore):
if
withsitewide
:
return
sorted
(
k
for
k
in
self
[
'propertydefs'
]
if
not
k
.
startswith
(
'sources.'
))
return
sorted
(
k
for
k
,
kd
in
self
[
'propertydefs'
].
iter
items
()
return
sorted
(
k
for
k
,
kd
in
self
[
'propertydefs'
].
items
()
if
not
kd
[
'sitewide'
]
and
not
k
.
startswith
(
'sources.'
))
def
register_property
(
self
,
key
,
type
,
help
,
default
=
None
,
vocabulary
=
None
,
...
...
dataimport/pgstore.py
View file @
10942ed1
...
...
@@ -348,7 +348,7 @@ class SQLGenSourceWrapper(object):
# In that case, simply update the insert dict and remove
# the need to make the
# UPDATE statement
for
statement
,
datalist
in
_inlined_relations_sql
.
iter
items
():
for
statement
,
datalist
in
_inlined_relations_sql
.
items
():
new_datalist
=
[]
# for a given inlined relation,
# browse each couple to be inserted
...
...
dataimport/stores.py
View file @
10942ed1
...
...
@@ -168,7 +168,7 @@ class NoHookRQLObjectStore(RQLObjectStore):
"""Given an entity type, attributes and inlined relations, returns the inserted entity's
eid.
"""
for
k
,
v
in
kwargs
.
iter
items
():
for
k
,
v
in
kwargs
.
items
():
kwargs
[
k
]
=
getattr
(
v
,
'eid'
,
v
)
entity
,
rels
=
self
.
metagen
.
base_etype_dicts
(
etype
)
# make a copy to keep cached entity pristine
...
...
@@ -183,7 +183,7 @@ class NoHookRQLObjectStore(RQLObjectStore):
kwargs
=
dict
()
if
inspect
.
getargspec
(
self
.
add_relation
).
keywords
:
kwargs
[
'subjtype'
]
=
entity
.
cw_etype
for
rtype
,
targeteids
in
rels
.
iter
items
():
for
rtype
,
targeteids
in
rels
.
items
():
# targeteids may be a single eid or a list of eids
inlined
=
self
.
rschema
(
rtype
).
inlined
try
:
...
...
devtools/__init__.py
View file @
10942ed1
...
...
@@ -465,7 +465,7 @@ class TestDataBaseHandler(object):
dbname
,
data
=
data
.
split
(
'-'
,
1
)
db_id
,
filetype
=
data
.
split
(
'.'
,
1
)
entries
.
setdefault
((
dbname
,
db_id
),
{})[
filetype
]
=
filepath
for
(
dbname
,
db_id
),
entry
in
entries
.
iter
items
():
for
(
dbname
,
db_id
),
entry
in
entries
.
items
():
# apply necessary transformation from the driver
value
=
self
.
process_cache_entry
(
directory
,
dbname
,
db_id
,
entry
)
assert
'config'
in
entry
...
...
devtools/devctl.py
View file @
10942ed1
...
...
@@ -733,7 +733,7 @@ class ExamineLogCommand(Command):
except
Exception
as
exc
:
sys
.
stderr
.
write
(
'Line %s: %s (%s)
\n
'
%
(
lineno
,
exc
,
line
))
stat
=
[]
for
rql
,
times
in
requests
.
iter
items
():
for
rql
,
times
in
requests
.
items
():
stat
.
append
(
(
sum
(
time
[
0
]
for
time
in
times
),
sum
(
time
[
1
]
for
time
in
times
),
len
(
times
),
rql
)
)
...
...
devtools/fake.py
View file @
10942ed1
...
...
@@ -112,7 +112,7 @@ class FakeRequest(ConnectionCubicWebRequestBase):
def
build_url_params
(
self
,
**
kwargs
):
# overriden to get predictable resultts
args
=
[]
for
param
,
values
in
sorted
(
kwargs
.
iter
items
()):
for
param
,
values
in
sorted
(
kwargs
.
items
()):
if
not
isinstance
(
values
,
(
list
,
tuple
)):
values
=
(
values
,)
for
value
in
values
:
...
...
devtools/htmlparser.py
View file @
10942ed1
...
...
@@ -209,7 +209,7 @@ class PageInfo(object):
def
matching_nodes
(
self
,
tag
,
**
attrs
):
for
elt
in
self
.
etree
.
iterfind
(
self
.
_iterstr
(
tag
)):
eltattrs
=
elt
.
attrib
for
attr
,
value
in
attrs
.
iter
items
():
for
attr
,
value
in
attrs
.
items
():
try
:
if
eltattrs
[
attr
]
!=
value
:
break
...
...
devtools/instrument.py
View file @
10942ed1
...
...
@@ -186,7 +186,7 @@ class PropagationAnalyzer(object):
def
add_colors_legend
(
self
,
graph
):
"""Add a legend of used colors to the graph."""
for
package
,
color
in
sorted
(
_COLORS
.
iter
items
()):
for
package
,
color
in
sorted
(
_COLORS
.
items
()):
graph
.
add_node
(
package
,
color
=
color
,
fontcolor
=
color
,
shape
=
'record'
)
...
...
devtools/repotest.py
View file @
10942ed1
...
...
@@ -307,8 +307,8 @@ def _build_variantes(self, newsolutions):
variantes
=
_orig_build_variantes
(
self
,
newsolutions
)
sortedvariantes
=
[]
for
variante
in
variantes
:
orderedkeys
=
sorted
((
k
[
1
],
k
[
2
],
v
)
for
k
,
v
in
variante
.
iter
items
())
variante
=
DumbOrderedDict
(
sorted
(
variante
.
iter
items
(),
orderedkeys
=
sorted
((
k
[
1
],
k
[
2
],
v
)
for
k
,
v
in
variante
.
items
())
variante
=
DumbOrderedDict
(
sorted
(
variante
.
items
(),
lambda
a
,
b
:
cmp
((
a
[
0
][
1
],
a
[
0
][
2
],
a
[
1
]),
(
b
[
0
][
1
],
b
[
0
][
2
],
b
[
1
]))))
sortedvariantes
.
append
(
(
orderedkeys
,
variante
)
)
...
...
@@ -319,7 +319,7 @@ _orig_check_permissions = ExecutionPlan._check_permissions
def
_check_permissions
(
*
args
,
**
kwargs
):
res
,
restricted
=
_orig_check_permissions
(
*
args
,
**
kwargs
)
res
=
DumbOrderedDict
(
sorted
(
res
.
iter
items
(),
lambda
a
,
b
:
cmp
(
a
[
1
],
b
[
1
])))
res
=
DumbOrderedDict
(
sorted
(
res
.
items
(),
lambda
a
,
b
:
cmp
(
a
[
1
],
b
[
1
])))
return
res
,
restricted
def
_dummy_check_permissions
(
self
,
rqlst
):
...
...
devtools/testlib.py
View file @
10942ed1
...
...
@@ -521,10 +521,10 @@ class CubicWebTC(TestCase):
similar to `orig_permissions.update(partial_perms)`.
"""
torestore
=
[]
for
erschema
,
etypeperms
in
chain
(
perm_overrides
,
perm_kwoverrides
.
iter
items
()):
for
erschema
,
etypeperms
in
chain
(
perm_overrides
,
perm_kwoverrides
.
items
()):
if
isinstance
(
erschema
,
string_types
):
erschema
=
self
.
schema
[
erschema
]
for
action
,
actionperms
in
etypeperms
.
iter
items
():
for
action
,
actionperms
in
etypeperms
.
items
():
origperms
=
erschema
.
permissions
[
action
]
erschema
.
set_action_permissions
(
action
,
actionperms
)
torestore
.
append
([
erschema
,
action
,
origperms
])
...
...
@@ -887,7 +887,7 @@ class CubicWebTC(TestCase):
}
# maps vid : validator name (override content_type_validators)
vid_validators
=
dict
((
vid
,
htmlparser
.
VALMAP
[
valkey
])
for
vid
,
valkey
in
VIEW_VALIDATORS
.
iter
items
())
for
vid
,
valkey
in
VIEW_VALIDATORS
.
items
())
def
view
(
self
,
vid
,
rset
=
None
,
req
=
None
,
template
=
'main-template'
,
...
...
@@ -1106,7 +1106,7 @@ def how_many_dict(schema, cnx, how_many, skip):
# new num for etype = max(current num, sum(num for possible target etypes))
#
# XXX we should first check there is no cycle then propagate changes
for
(
rschema
,
etype
),
targets
in
relmap
.
iter
items
():
for
(
rschema
,
etype
),
targets
in
relmap
.
items
():
relfactor
=
sum
(
howmanydict
[
e
]
for
e
in
targets
)
howmanydict
[
str
(
etype
)]
=
max
(
relfactor
,
howmanydict
[
etype
])
return
howmanydict
...
...
@@ -1314,7 +1314,7 @@ def not_selected(vreg, appobject):
# def print_untested_objects(testclass, skipregs=('hooks', 'etypes')):
# for regname, reg in testclass._env.vreg.
iter
items():
# for regname, reg in testclass._env.vreg.items():
# if regname in skipregs:
# continue
# for appobjects in reg.itervalues():
...
...
doc/tutorials/dataimport/diseasome_import.py
View file @
10942ed1
...
...
@@ -95,7 +95,7 @@ def diseasome_import(session, file_name, store):
# Perform a first commit, of the entities
store
.
flush
()
kwargs
=
{}
for
uri
,
relations
in
all_relations
.
iter
items
():
for
uri
,
relations
in
all_relations
.
items
():
from_eid
=
uri_to_eid
.
get
(
uri
)
# ``subjtype`` should be initialized if ``SQLGenObjectStore`` is used
# and there are inlined relations in the schema.
...
...
@@ -108,7 +108,7 @@ def diseasome_import(session, file_name, store):
kwargs
[
'subjtype'
]
=
uri_to_etype
.
get
(
uri
)
if
not
from_eid
:
continue
for
rtype
,
rels
in
relations
.
iter
items
():
for
rtype
,
rels
in
relations
.
items
():
if
rtype
in
(
'classes'
,
'possible_drugs'
,
'omim'
,
'omim_page'
,
'chromosomal_location'
,
'same_as'
,
'gene_id'
,
'hgnc_id'
,
'hgnc_page'
):
...
...
entities/adapters.py
View file @
10942ed1
...
...
@@ -162,7 +162,7 @@ class IFTIndexableAdapter(view.EntityAdapter):
return
words
def
merge_weight_dict
(
maindict
,
newdict
):
for
weight
,
words
in
newdict
.
iter
items
():
for
weight
,
words
in
newdict
.
items
():
maindict
.
setdefault
(
weight
,
[]).
extend
(
words
)
class
IDownloadableAdapter
(
view
.
EntityAdapter
):
...
...
entities/sources.py
View file @
10942ed1
...
...
@@ -42,7 +42,7 @@ class _CWSourceCfgMixIn(object):
cfg
.
update
(
config
)
options
=
SOURCE_TYPES
[
self
.
type
].
options
sconfig
=
SourceConfiguration
(
self
.
_cw
.
vreg
.
config
,
options
=
options
)
for
opt
,
val
in
cfg
.
iter
items
():
for
opt
,
val
in
cfg
.
items
():
try
:
sconfig
.
set_option
(
opt
,
val
)
except
OptionError
:
...
...
entities/test/unittest_base.py
View file @
10942ed1
...
...
@@ -60,7 +60,7 @@ class MetadataTC(BaseEntityTC):
# XXX move to yams
self
.
assertEqual
(
self
.
schema
[
'CWUser'
].
meta_attributes
(),
{})
self
.
assertEqual
(
dict
((
str
(
k
),
v
)
for
k
,
v
in
self
.
schema
[
'State'
].
meta_attributes
().
iter
items
()),
for
k
,
v
in
self
.
schema
[
'State'
].
meta_attributes
().
items
()),
{
'description_format'
:
(
'format'
,
'description'
)})
def
test_fti_rql_method
(
self
):
...
...
entity.py
View file @
10942ed1
...
...
@@ -108,7 +108,7 @@ def build_cstr_with_linkto_infos(cstr, args, searchedvar, evar,
"""
st
=
cstr
.
snippet_rqlst
.
copy
()
# replace relations in ST by eid infos from linkto where possible
for
(
info_rtype
,
info_role
),
eids
in
lt_infos
.
iter
items
():
for
(
info_rtype
,
info_role
),
eids
in
lt_infos
.
items
():
eid
=
eids
[
0
]
# NOTE: we currently assume a pruned lt_info with only 1 eid
for
rel
in
st
.
iget_nodes
(
RqlRelation
):
targetvar
=
rel_matches
(
rel
,
info_rtype
,
info_role
,
evar
.
name
)
...
...
@@ -135,7 +135,7 @@ def build_cstr_with_linkto_infos(cstr, args, searchedvar, evar,
def
pruned_lt_info
(
eschema
,
lt_infos
):
pruned
=
{}
for
(
lt_rtype
,
lt_role
),
eids
in
lt_infos
.
iter
items
():
for
(
lt_rtype
,
lt_role
),
eids
in
lt_infos
.
items
():
# we can only use lt_infos describing relation with a cardinality
# of value 1 towards the linked entity
if
not
len
(
eids
)
==
1
:
...
...
etwist/request.py
View file @
10942ed1
...
...
@@ -31,7 +31,7 @@ class CubicWebTwistedRequestAdapter(CubicWebRequestBase):
self
.
_twreq
=
req
super
(
CubicWebTwistedRequestAdapter
,
self
).
__init__
(
vreg
,
https
,
req
.
args
,
headers
=
req
.
received_headers
)
for
key
,
name_stream_list
in
req
.
files
.
iter
items
():
for
key
,
name_stream_list
in
req
.
files
.
items
():
for
name
,
stream
in
name_stream_list
:
if
name
is
not
None
:
name
=
unicode
(
name
,
self
.
encoding
)
...
...
ext/test/unittest_rest.py
View file @
10942ed1
...
...
@@ -221,7 +221,7 @@ class RestTC(CubicWebTC):
%(rql)s
"""
%
{
'rql'
:
rql
,
'colvids'
:
', '
.
join
([
"%d=%s"
%
(
k
,
v
)
for
k
,
v
in
colvids
.
iter
items
()])
for
k
,
v
in
colvids
.
items
()])
})
view
=
self
.
vreg
[
'views'
].
select
(
'table'
,
req
,
rset
=
req
.
execute
(
rql
))
view
.
cellvids
=
colvids
...
...
hooks/__init__.py
View file @
10942ed1
...
...
@@ -52,7 +52,7 @@ class UpdateFeedsStartupHook(hook.Hook):
def
update_feeds
(
repo
):
# take a list to avoid iterating on a dictionary whose size may
# change
for
uri
,
source
in
list
(
repo
.
sources_by_uri
.
iter
items
()):
for
uri
,
source
in
list
(
repo
.
sources_by_uri
.
items
()):
if
(
uri
==
'system'
or
not
repo
.
config
.
source_enabled
(
source
)
or
not
source
.
config
[
'synchronize'
]):
...
...
@@ -72,7 +72,7 @@ class DataImportsCleanupStartupHook(hook.Hook):
def
__call__
(
self
):
def
expire_dataimports
(
repo
=
self
.
repo
):
for
uri
,
source
in
repo
.
sources_by_uri
.
iter
items
():
for
uri
,
source
in
repo
.
sources_by_uri
.
items
():
if
(
uri
==
'system'
or
not
repo
.
config
.
source_enabled
(
source
)):
continue
...
...
Prev
1
2
3
4
Next
Write
Preview
Supports
Markdown
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