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
838d4da7a664
Commit
ccb5ce2c
authored
Jul 07, 2021
by
Laurent Peuch
Browse files
style: hg format-source with black again
parent
c5ad4e650499
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
.hg-format-source
View file @
838d4da7
This diff is collapsed.
Click to expand it.
cubicweb/cwvreg.py
View file @
838d4da7
...
...
@@ -292,9 +292,7 @@ class CtxComponentsRegistry(CWRegistry):
try
:
cached
=
cache
.
__components_cache
except
AttributeError
:
ctxcomps
=
super
().
poss_visible_objects
(
*
args
,
**
kwargs
)
ctxcomps
=
super
().
poss_visible_objects
(
*
args
,
**
kwargs
)
if
cache
is
None
:
components
=
[]
for
component
in
ctxcomps
:
...
...
cubicweb/dataimport/test/unittest_importer.py
View file @
838d4da7
...
...
@@ -73,9 +73,7 @@ class ExtEntitiesImporterTC(CubicWebTC):
def
test_bytes_attribute
(
self
):
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
importer
=
self
.
importer
(
cnx
)
personne
=
ExtEntity
(
"Personne"
,
1
,
{
"photo"
:
{
b
"poilu"
},
"nom"
:
{
"alf"
}}
)
personne
=
ExtEntity
(
"Personne"
,
1
,
{
"photo"
:
{
b
"poilu"
},
"nom"
:
{
"alf"
}})
importer
.
import_entities
([
personne
])
cnx
.
commit
()
entity
=
cnx
.
find
(
"Personne"
).
one
()
...
...
@@ -105,9 +103,7 @@ class ExtEntitiesImporterTC(CubicWebTC):
"""Check import of ext entities with inlined relation"""
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
importer
=
self
.
importer
(
cnx
)
richelieu
=
ExtEntity
(
"Personne"
,
3
,
{
"nom"
:
{
"Richelieu"
},
"enfant"
:
{
4
}}
)
richelieu
=
ExtEntity
(
"Personne"
,
3
,
{
"nom"
:
{
"Richelieu"
},
"enfant"
:
{
4
}})
athos
=
ExtEntity
(
"Personne"
,
4
,
{
"nom"
:
{
"Athos"
}})
importer
.
import_entities
([
athos
,
richelieu
])
cnx
.
commit
()
...
...
@@ -119,9 +115,7 @@ class ExtEntitiesImporterTC(CubicWebTC):
"""Check import of ext entities with non inlined relation"""
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
importer
=
self
.
importer
(
cnx
)
richelieu
=
ExtEntity
(
"Personne"
,
5
,
{
"nom"
:
{
"Richelieu"
},
"connait"
:
{
6
}}
)
richelieu
=
ExtEntity
(
"Personne"
,
5
,
{
"nom"
:
{
"Richelieu"
},
"connait"
:
{
6
}})
athos
=
ExtEntity
(
"Personne"
,
6
,
{
"nom"
:
{
"Athos"
}})
importer
.
import_entities
([
athos
,
richelieu
])
cnx
.
commit
()
...
...
@@ -136,9 +130,7 @@ class ExtEntitiesImporterTC(CubicWebTC):
"""Check import of ext entity with missing inlined relation"""
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
importer
=
self
.
importer
(
cnx
)
richelieu
=
ExtEntity
(
"Personne"
,
7
,
{
"nom"
:
{
"Richelieu"
},
"enfant"
:
{
8
}}
)
richelieu
=
ExtEntity
(
"Personne"
,
7
,
{
"nom"
:
{
"Richelieu"
},
"enfant"
:
{
8
}})
self
.
assertRaises
(
Exception
,
importer
.
import_entities
,
[
richelieu
])
cnx
.
commit
()
rset
=
cnx
.
execute
(
'Any X WHERE X is Personne, X nom "Richelieu"'
)
...
...
@@ -162,9 +154,7 @@ class ExtEntitiesImporterTC(CubicWebTC):
"""Check import of ext entity in both order"""
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
importer
=
self
.
importer
(
cnx
)
richelieu
=
ExtEntity
(
"Personne"
,
3
,
{
"nom"
:
{
"Richelieu"
},
"enfant"
:
{
4
}}
)
richelieu
=
ExtEntity
(
"Personne"
,
3
,
{
"nom"
:
{
"Richelieu"
},
"enfant"
:
{
4
}})
athos
=
ExtEntity
(
"Personne"
,
4
,
{
"nom"
:
{
"Athos"
}})
importer
.
import_entities
([
richelieu
,
athos
])
cnx
.
commit
()
...
...
@@ -239,9 +229,7 @@ def extentities_from_csv(fpath):
"""Yield ExtEntity read from `fpath` CSV file."""
with
open
(
fpath
,
"rb"
)
as
f
:
for
uri
,
name
,
knows
in
ucsvreader
(
f
,
skipfirst
=
True
,
skip_empty
=
False
):
yield
ExtEntity
(
"Personne"
,
uri
,
{
"nom"
:
{
name
},
"connait"
:
{
knows
}}
)
yield
ExtEntity
(
"Personne"
,
uri
,
{
"nom"
:
{
name
},
"connait"
:
{
knows
}})
class
DataimportFunctionalTC
(
CubicWebTC
):
...
...
cubicweb/devtools/fake.py
View file @
838d4da7
...
...
@@ -83,9 +83,7 @@ class FakeRequest(ConnectionCubicWebRequestBase):
def
set_cookie
(
self
,
name
,
value
,
maxage
=
300
,
expires
=
None
,
secure
=
False
,
httponly
=
False
):
super
().
set_cookie
(
name
,
value
,
maxage
,
expires
,
secure
,
httponly
)
super
().
set_cookie
(
name
,
value
,
maxage
,
expires
,
secure
,
httponly
)
cookie
=
self
.
get_response_header
(
"Set-Cookie"
)
self
.
_headers_in
.
setHeader
(
"Cookie"
,
cookie
)
...
...
cubicweb/devtools/qunit.py
View file @
838d4da7
...
...
@@ -234,7 +234,9 @@ class QUnitResultController(Controller):
self
.
__class__
.
_current_module_name
=
self
.
_cw
.
form
.
get
(
"name"
,
""
)
def
handle_test_done
(
self
):
name
=
"{} // {}"
.
format
(
self
.
_current_module_name
,
self
.
_cw
.
form
.
get
(
"name"
,
""
))
name
=
"{} // {}"
.
format
(
self
.
_current_module_name
,
self
.
_cw
.
form
.
get
(
"name"
,
""
)
)
failures
=
int
(
self
.
_cw
.
form
.
get
(
"failures"
,
0
))
total
=
int
(
self
.
_cw
.
form
.
get
(
"total"
,
0
))
...
...
cubicweb/devtools/test/unittest_dbfill.py
View file @
838d4da7
...
...
@@ -44,9 +44,7 @@ class ValueGeneratorTC(TestCase):
def
_choice_func
(
self
,
etype
,
attrname
):
try
:
return
getattr
(
self
,
f
"_available_
{
etype
}
_
{
attrname
}
"
)(
etype
,
attrname
)
return
getattr
(
self
,
f
"_available_
{
etype
}
_
{
attrname
}
"
)(
etype
,
attrname
)
except
AttributeError
:
return
None
...
...
cubicweb/entities/test/unittest_base.py
View file @
838d4da7
...
...
@@ -59,9 +59,7 @@ class MetadataTC(BaseEntityTC):
# XXX move to yams
self
.
assertEqual
(
self
.
schema
[
"CWUser"
].
meta_attributes
(),
{})
self
.
assertEqual
(
{
str
(
k
):
v
for
k
,
v
in
self
.
schema
[
"State"
].
meta_attributes
().
items
()
},
{
str
(
k
):
v
for
k
,
v
in
self
.
schema
[
"State"
].
meta_attributes
().
items
()},
{
"description_format"
:
(
"format"
,
"description"
)},
)
...
...
@@ -173,14 +171,14 @@ class CWUserTC(BaseEntityTC):
self
.
assertEqual
(
e
.
cw_adapt_to
(
"IEmailable"
).
allowed_massmail_keys
(),
{
"surname"
,
"firstname"
,
"login"
,
"last_login_time"
,
"creation_date"
,
"modification_date"
,
"cwuri"
,
"eid"
,
"surname"
,
"firstname"
,
"login"
,
"last_login_time"
,
"creation_date"
,
"modification_date"
,
"cwuri"
,
"eid"
,
},
)
...
...
cubicweb/hooks/integrity.py
View file @
838d4da7
...
...
@@ -349,9 +349,7 @@ class DeleteCompositeOrphanHook(hook.Hook):
rtype
=
rdef
.
rtype
.
type
target
=
getattr
(
rdef
,
neg_role
(
role
))
expr
=
(
"C %s X"
%
rtype
)
if
role
==
"subject"
else
(
"X %s C"
%
rtype
)
self
.
_cw
.
execute
(
f
"DELETE
{
target
}
X WHERE C eid %(c)s,
{
expr
}
"
,
{
"c"
:
eid
}
)
self
.
_cw
.
execute
(
f
"DELETE
{
target
}
X WHERE C eid %(c)s,
{
expr
}
"
,
{
"c"
:
eid
})
def
registration_callback
(
vreg
):
...
...
cubicweb/hooks/notification.py
View file @
838d4da7
...
...
@@ -134,9 +134,7 @@ class RelationChangeHook(NotificationHook):
email defined by the view
"""
rset
=
self
.
_cw
.
eid_rset
(
self
.
eidfrom
)
view
=
self
.
select_view
(
f
"notif_
{
self
.
event
}
_
{
self
.
rtype
}
"
,
rset
=
rset
,
row
=
0
)
view
=
self
.
select_view
(
f
"notif_
{
self
.
event
}
_
{
self
.
rtype
}
"
,
rset
=
rset
,
row
=
0
)
if
view
is
None
:
return
notify_on_commit
(
self
.
_cw
,
view
)
...
...
cubicweb/hooks/test/unittest_synccomputed.py
View file @
838d4da7
...
...
@@ -78,11 +78,11 @@ class FormulaDependenciesMatrixTC(TestCase):
self
.
assertEqual
(
values
,
{
(
"Any 2014 - D WHERE X birth_year D"
,
tuple
((
"birth_year"
,))),
(
"Any SUM(SA) GROUPBY X WHERE P works_for X, P salary SA"
,
tuple
((
"salary"
,)),
),
(
"Any 2014 - D WHERE X birth_year D"
,
tuple
((
"birth_year"
,))),
(
"Any SUM(SA) GROUPBY X WHERE P works_for X, P salary SA"
,
tuple
((
"salary"
,)),
),
},
)
...
...
cubicweb/hooks/test/unittest_syncschema.py
View file @
838d4da7
...
...
@@ -229,9 +229,7 @@ class SchemaModificationHooksTC(CubicWebTC):
def
test_perms_synchronization_1
(
self
):
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
schema
=
self
.
repo
.
schema
self
.
assertEqual
(
schema
[
"CWUser"
].
get_groups
(
"read"
),
{
"managers"
,
"users"
}
)
self
.
assertEqual
(
schema
[
"CWUser"
].
get_groups
(
"read"
),
{
"managers"
,
"users"
})
self
.
assertTrue
(
cnx
.
execute
(
'Any X, Y WHERE X is CWEType, X name "CWUser", '
...
...
@@ -245,8 +243,8 @@ class SchemaModificationHooksTC(CubicWebTC):
self
.
assertEqual
(
schema
[
"CWUser"
].
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"managers"
,
"users"
,
},
)
cnx
.
commit
()
...
...
@@ -259,24 +257,20 @@ class SchemaModificationHooksTC(CubicWebTC):
self
.
assertEqual
(
schema
[
"CWUser"
].
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"managers"
,
"users"
,
},
)
def
test_perms_synchronization_2
(
self
):
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
schema
=
self
.
repo
.
schema
[
"in_group"
].
rdefs
[(
"CWUser"
,
"CWGroup"
)]
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"guests"
}
)
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"guests"
})
cnx
.
execute
(
"DELETE X read_permission Y WHERE X relation_type RT, "
'RT name "in_group", Y name "guests"'
)
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"guests"
}
)
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"guests"
})
cnx
.
commit
()
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
})
cnx
.
execute
(
...
...
@@ -285,9 +279,7 @@ class SchemaModificationHooksTC(CubicWebTC):
)
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
})
cnx
.
commit
()
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"guests"
}
)
self
.
assertEqual
(
schema
.
get_groups
(
"read"
),
{
"managers"
,
"users"
,
"guests"
})
def
test_nonregr_user_edit_itself
(
self
):
with
self
.
admin_access
.
repo_cnx
()
as
cnx
:
...
...
cubicweb/migration.py
View file @
838d4da7
...
...
@@ -204,8 +204,7 @@ class MigrationHelper:
msg
=
"Execute command: {}({}) ?"
.
format
(
meth
.
__name__
[
4
:],
", "
.
join
(
[
repr
(
arg
)
for
arg
in
args
]
+
[
f
"
{
n
}
=
{
v
!
r
}
"
for
n
,
v
in
kwargs
.
items
()]
[
repr
(
arg
)
for
arg
in
args
]
+
[
f
"
{
n
}
=
{
v
!
r
}
"
for
n
,
v
in
kwargs
.
items
()]
),
)
if
"ask_confirm"
in
kwargs
:
...
...
cubicweb/pyramid/debug_source_code.py
View file @
838d4da7
...
...
@@ -57,12 +57,14 @@ def _generate_link_to_source(file_path, start=None, end=None, tag_body="[source]
)
)
else
:
return
'<a href="../{}?file={}&line={}#line-{}" target="_blank">{}</a>'
.
format
(
DEBUG_DISPLAY_SOURCE_CODE_PATH
,
file_path
,
start
,
line_anchor
,
tag_body
,
return
(
'<a href="../{}?file={}&line={}#line-{}" target="_blank">{}</a>'
.
format
(
DEBUG_DISPLAY_SOURCE_CODE_PATH
,
file_path
,
start
,
line_anchor
,
tag_body
,
)
)
return
'<a href="../{}?file={}" target="_blank">{}</a>'
.
format
(
...
...
cubicweb/server/checkintegrity.py
View file @
838d4da7
...
...
@@ -289,7 +289,9 @@ def check_entities(schema, cnx, eids, fix=1):
if
not
eid
in
eids
or
not
eids
[
eid
]:
sys
.
stderr
.
write
(
msg
%
(
eid
,
eschema
.
type
))
if
fix
:
cnx
.
system_sql
(
"DELETE FROM {} WHERE {}={};"
.
format
(
table
,
column
,
eid
))
cnx
.
system_sql
(
"DELETE FROM {} WHERE {}={};"
.
format
(
table
,
column
,
eid
)
)
notify_fixed
(
fix
)
...
...
@@ -354,7 +356,9 @@ def check_relations(schema, cnx, eids, fix=1):
if
not
has_eid
(
cnx
,
cursor
,
eid
,
eids
):
bad_related_msg
(
rschema
,
"subject"
,
eid
,
fix
)
if
fix
:
sql
=
"DELETE FROM {}_relation WHERE eid_from={};"
.
format
(
rschema
,
eid
)
sql
=
"DELETE FROM {}_relation WHERE eid_from={};"
.
format
(
rschema
,
eid
)
cnx
.
system_sql
(
sql
)
cursor
=
cnx
.
system_sql
(
"SELECT eid_to FROM %s_relation;"
%
rschema
)
for
row
in
cursor
.
fetchall
():
...
...
@@ -362,7 +366,9 @@ def check_relations(schema, cnx, eids, fix=1):
if
not
has_eid
(
cnx
,
cursor
,
eid
,
eids
):
bad_related_msg
(
rschema
,
"object"
,
eid
,
fix
)
if
fix
:
sql
=
"DELETE FROM {}_relation WHERE eid_to={};"
.
format
(
rschema
,
eid
)
sql
=
"DELETE FROM {}_relation WHERE eid_to={};"
.
format
(
rschema
,
eid
)
cnx
.
system_sql
(
sql
)
...
...
cubicweb/server/rqlannotation.py
View file @
838d4da7
...
...
@@ -383,10 +383,7 @@ class IsAmbData:
def
_debug_print
(
self
):
print
(
"varsols"
,
{
x
:
sorted
(
str
(
v
)
for
v
in
values
)
for
x
,
values
in
self
.
varsols
.
items
()
},
{
x
:
sorted
(
str
(
v
)
for
v
in
values
)
for
x
,
values
in
self
.
varsols
.
items
()},
)
print
(
"ambiguous vars"
,
sorted
(
self
.
ambiguousvars
))
...
...
cubicweb/server/serverconfig.py
View file @
838d4da7
...
...
@@ -104,10 +104,12 @@ class ServerConfiguration(CubicWebConfiguration):
name
=
"repository"
cubicweb_appobject_path
=
CubicWebConfiguration
.
cubicweb_appobject_path
|
{
"sobjects"
,
"hooks"
"sobjects"
,
"hooks"
,
}
cube_appobject_path
=
CubicWebConfiguration
.
cube_appobject_path
|
{
"sobjects"
,
"hooks"
"sobjects"
,
"hooks"
,
}
options
=
lgconfig
.
merge_options
(
...
...
cubicweb/server/sources/native.py
View file @
838d4da7
...
...
@@ -1420,10 +1420,12 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
obj
,
)
else
:
sql
=
"SELECT 1 FROM {}_relation WHERE eid_from={} and eid_to={}"
.
format
(
rtype
,
subj
,
obj
,
sql
=
(
"SELECT 1 FROM {}_relation WHERE eid_from={} and eid_to={}"
.
format
(
rtype
,
subj
,
obj
,
)
)
cu
=
self
.
doexec
(
cnx
,
sql
)
if
cu
.
fetchone
()
is
None
:
...
...
cubicweb/server/sources/rql2sql.py
View file @
838d4da7
...
...
@@ -1171,9 +1171,7 @@ class SQLGenerator:
termsql
=
termconst
and
termconst
.
accept
(
self
)
or
termvar
.
accept
(
self
)
yield
f
"
{
rid
}
.
{
relfield
}
=
{
termsql
}
"
elif
termvar
.
_q_invariant
:
extrajoin
=
self
.
_extra_join_sql
(
relation
,
f
"
{
rid
}
.
{
relfield
}
"
,
termvar
)
extrajoin
=
self
.
_extra_join_sql
(
relation
,
f
"
{
rid
}
.
{
relfield
}
"
,
termvar
)
if
extrajoin
is
not
None
:
yield
extrajoin
...
...
@@ -1463,7 +1461,8 @@ class SQLGenerator:
ealias
=
lhsvar
.
_q_sqltable
=
"_"
+
lhsvar
.
name
jointo
=
lhsvar
.
_q_sql
=
"%s.cw_eid"
%
ealias
self
.
_state
.
add_table
(
"cw_{} AS {}"
.
format
(
self
.
_state
.
solution
[
lhs
.
name
],
ealias
),
ealias
"cw_{} AS {}"
.
format
(
self
.
_state
.
solution
[
lhs
.
name
],
ealias
),
ealias
,
)
else
:
subquery
=
" UNION "
.
join
(
...
...
cubicweb/server/test/unittest_querier.py
View file @
838d4da7
...
...
@@ -1763,14 +1763,10 @@ Any P1,B,E WHERE P1 identity P2 WITH
"WHERE P1 eid %s, P2 eid %s, U eid %s"
%
(
peid1
,
peid2
,
ueid
)
)
self
.
assertTrue
(
cnx
.
execute
(
f
"Any X WHERE X eid
{
peid1
}
, X owned_by U, U eid
{
ueid
}
"
)
cnx
.
execute
(
f
"Any X WHERE X eid
{
peid1
}
, X owned_by U, U eid
{
ueid
}
"
)
)
self
.
assertTrue
(
cnx
.
execute
(
f
"Any X WHERE X eid
{
peid2
}
, X owned_by U, U eid
{
ueid
}
"
)
cnx
.
execute
(
f
"Any X WHERE X eid
{
peid2
}
, X owned_by U, U eid
{
ueid
}
"
)
)
def
test_update_math_expr
(
self
):
...
...
cubicweb/server/test/unittest_repository.py
View file @
838d4da7
...
...
@@ -189,20 +189,20 @@ class RepositoryTC(CubicWebTC):
schema
=
self
.
repo
.
schema
# check order of attributes is respected
notin
=
{
"eid"
,
"is"
,
"is_instance_of"
,
"identity"
,
"creation_date"
,
"modification_date"
,
"cwuri"
,
"owned_by"
,
"created_by"
,
"cw_source"
,
"update_permission"
,
"read_permission"
,
"add_permission"
,
"in_basket"
,
"eid"
,
"is"
,
"is_instance_of"
,
"identity"
,
"creation_date"
,
"modification_date"
,
"cwuri"
,
"owned_by"
,
"created_by"
,
"cw_source"
,
"update_permission"
,
"read_permission"
,
"add_permission"
,
"in_basket"
,
}
self
.
assertListEqual
(
[
...
...
Prev
1
2
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