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
cubes
seda
Commits
70e13297f997
Commit
22eb8045
authored
Sep 23, 2016
by
Sylvain Thénault
Browse files
[py3k] unicode -> text_type, basestring -> string_types
parent
7896a09a5f08
Changes
9
Hide whitespace changes
Inline
Side-by-side
entities/html_generation.py
View file @
70e13297
...
...
@@ -15,6 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda adapter classes for generation of a profile generation as HTML"""
from
six
import
string_types
from
cubicweb
import
_
from
cubes.seda.entities.profile_generation
import
SEDA2ExportAdapter
,
content_types
...
...
@@ -190,7 +192,7 @@ class SEDA2HTMLExport(SEDA2ExportAdapter):
self
.
element
(
'span'
,
div
,
text
=
occ
.
target
.
local_name
,
attributes
=
{
'class'
:
'label'
})
self
.
element
(
'span'
,
div
,
text
=
card
,
attributes
=
{
'class'
:
'card'
})
fixed_value
=
self
.
serialize
(
target_value
)
if
isinstance
(
fixed_value
,
base
string
):
if
isinstance
(
fixed_value
,
string
_types
):
self
.
element
(
'span'
,
div
,
text
=
fixed_value
,
attributes
=
{
'class'
:
'value'
})
else
:
span
=
self
.
element
(
'span'
,
div
,
attributes
=
{
'class'
:
'value'
})
...
...
@@ -243,7 +245,7 @@ class SEDA2HTMLExport(SEDA2ExportAdapter):
value_div
=
self
.
element
(
'div'
,
div
)
self
.
element
(
'span'
,
value_div
,
text
=
self
.
_cw
.
_
(
'fixed value'
),
attributes
=
{
'class'
:
'label'
})
if
isinstance
(
fixed_value
,
base
string
):
if
isinstance
(
fixed_value
,
string
_types
):
self
.
element
(
'span'
,
value_div
,
text
=
fixed_value
,
attributes
=
{
'class'
:
'value'
})
else
:
span
=
self
.
element
(
'span'
,
value_div
,
attributes
=
{
'class'
:
'value'
})
...
...
@@ -289,5 +291,5 @@ class SEDA2HTMLExport(SEDA2ExportAdapter):
else
:
if
isinstance
(
value
,
bool
):
value
=
'true'
if
value
else
'false'
assert
isinstance
(
value
,
base
string
),
repr
(
value
)
assert
isinstance
(
value
,
string
_types
),
repr
(
value
)
return
value
entities/profile_generation.py
View file @
70e13297
...
...
@@ -17,6 +17,8 @@
from
collections
import
defaultdict
from
six
import
text_type
,
string_types
from
lxml
import
etree
from
pyxst.xml_struct
import
graph_nodes
...
...
@@ -84,8 +86,8 @@ def serialize(value):
return
None
# intermediary entity
if
isinstance
(
value
,
bool
):
return
'true'
if
value
else
'false'
assert
isinstance
(
value
,
base
string
),
repr
(
value
)
return
unicod
e
(
value
)
assert
isinstance
(
value
,
string
_types
),
repr
(
value
)
return
text_typ
e
(
value
)
def
element_minmax_cardinality
(
occ
,
card_entity
):
...
...
test/test_entities.py
View file @
70e13297
...
...
@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-saem_ref unit tests for entities.container"""
from
six
import
text_type
from
cubicweb.devtools.testlib
import
CubicWebTC
from
cubes.seda.entities
import
seda_profile_container_def
,
simplified_profile
,
full_seda2_profile
...
...
@@ -92,7 +94,7 @@ class PredicatesTC(CubicWebTC):
self
.
assertEqual
(
simplified_profile_pred
(
None
,
req
,
entity
=
being_created
),
0
)
self
.
assertEqual
(
full_seda2_profile_pred
(
None
,
req
,
entity
=
being_created
),
1
)
del
req
.
form
[
'__linkto'
]
req
.
form
[
'arg'
]
=
[
unicod
e
(
transfer
.
eid
)]
req
.
form
[
'arg'
]
=
[
text_typ
e
(
transfer
.
eid
)]
self
.
assertEqual
(
simplified_profile_pred
(
None
,
req
,
entity
=
being_created
),
0
)
self
.
assertEqual
(
full_seda2_profile_pred
(
None
,
req
,
entity
=
being_created
),
1
)
transfer
.
cw_set
(
simplified_profile
=
True
)
...
...
test/test_views.py
View file @
70e13297
...
...
@@ -17,6 +17,8 @@
import
unittest
from
six
import
text_type
from
cubicweb.devtools.testlib
import
CubicWebTC
from
cubicweb.web
import
INTERNAL_FIELD_VALUE
...
...
@@ -55,9 +57,9 @@ class ManagementRulesTC(CubicWebTC):
cnx
.
commit
()
self
.
assertEqual
(
_rule_ref_vocabulary
(
rule_base
,
transfer
),
[(
access_concept
.
label
(),
unicod
e
(
access_concept
.
eid
))])
[(
access_concept
.
label
(),
text_typ
e
(
access_concept
.
eid
))])
self
.
assertEqual
(
_rule_ref_vocabulary
(
rule_alt
,
transfer
),
[(
access_concept
.
label
(),
unicod
e
(
access_concept
.
eid
))])
[(
access_concept
.
label
(),
text_typ
e
(
access_concept
.
eid
))])
class
PermissionsTC
(
CubicWebTC
):
...
...
@@ -108,7 +110,7 @@ class RelationWidgetTC(CubicWebTC):
with
self
.
admin_access
.
web_request
()
as
req
:
compressed
=
req
.
entity_from_eid
(
compressed
.
eid
)
req
.
form
=
{
'relation'
:
'seda_algorithm:Concept:subject'
,
'container'
:
unicod
e
(
transfer
.
eid
)}
'container'
:
text_typ
e
(
transfer
.
eid
)}
view
=
self
.
vreg
[
'views'
].
select
(
'search_related_entities'
,
req
,
rset
=
compressed
.
as_rset
())
self
.
failIf
(
view
.
linkable_rset
())
...
...
@@ -122,7 +124,7 @@ class RelationWidgetTC(CubicWebTC):
with
self
.
admin_access
.
web_request
()
as
req
:
compressed
=
req
.
entity_from_eid
(
compressed
.
eid
)
req
.
form
=
{
'relation'
:
'seda_algorithm:Concept:subject'
,
'container'
:
unicod
e
(
transfer
.
eid
)}
'container'
:
text_typ
e
(
transfer
.
eid
)}
view
=
self
.
vreg
[
'views'
].
select
(
'search_related_entities'
,
req
,
rset
=
compressed
.
as_rset
())
self
.
assertEqual
(
len
(
view
.
linkable_rset
()),
1
)
...
...
views/archiveunit.py
View file @
70e13297
...
...
@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda views for ArchiveUnit"""
from
six
import
text_type
from
logilab.common.registry
import
objectify_predicate
,
yes
from
cubicweb
import
tags
,
_
...
...
@@ -413,7 +415,7 @@ class SimplifiedArchiveUnitDataObjectReferencesTab(ArchiveUnitDataObjectReferenc
def
display_add_button
(
self
,
entity
):
rtype_roles
=
[(
rtype
,
role
)
for
rtype
,
role
,
_
in
self
.
rtype_role_targets
]
params
=
self
.
url_params
(
entity
)
params
[
'referenced_by'
]
=
unicod
e
(
entity
.
eid
)
params
[
'referenced_by'
]
=
text_typ
e
(
entity
.
eid
)
transfer
=
entity
.
container
[
0
]
button
=
add_subobjects_button
(
transfer
,
rtype_roles
,
params
)
if
button
:
...
...
views/dataobject.py
View file @
70e13297
...
...
@@ -17,6 +17,8 @@
import
json
from
six
import
text_type
from
logilab.mtconverter
import
xml_escape
from
cubicweb
import
tags
,
view
,
_
...
...
@@ -76,7 +78,7 @@ class ContainedRelationFacetWidget(rwdg.RelationFacetWidget):
_
,
container
=
parent_and_container
(
entity
)
# and put it as an extra url param
if
container
is
not
None
:
url_params
[
'container'
]
=
unicod
e
(
container
.
eid
)
url_params
[
'container'
]
=
text_typ
e
(
container
.
eid
)
return
super
(
ContainedRelationFacetWidget
,
self
).
trigger_search_url
(
entity
,
url_params
)
...
...
views/mgmt_rules.py
View file @
70e13297
...
...
@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda views for management rules"""
from
six
import
text_type
from
logilab.mtconverter
import
xml_escape
from
cubicweb.predicates
import
is_instance
...
...
@@ -50,7 +52,7 @@ def _rule_ref_vocabulary(parent, container):
'CACLV seda_{0}_rule_code_list_version_to CS'
.
format
(
rule_type
))
rset
=
req
.
execute
(
rql
,
{
'at'
:
container
.
eid
})
if
rset
:
return
[(
concept
.
label
(),
unicod
e
(
concept
.
eid
))
return
[(
concept
.
label
(),
text_typ
e
(
concept
.
eid
))
for
concept
in
rset
.
entities
()]
else
:
scheme_relation
=
'seda_{0}_rule_code_list_version_from_object'
.
format
(
rule_type
)
...
...
views/widgets.py
View file @
70e13297
...
...
@@ -15,6 +15,8 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""cubicweb-seda custom fields/widgets"""
from
six
import
text_type
from
logilab.common.decorators
import
monkeypatch
from
cubicweb
import
tags
,
utils
...
...
@@ -138,7 +140,7 @@ class ConceptAutoCompleteWidget(fw.TextInput):
eid
=
u
''
else
:
value
=
concept
.
label
()
eid
=
unicod
e
(
concept
.
eid
)
eid
=
text_typ
e
(
concept
.
eid
)
# we need an hidden input to handle the value while the text input display the label
inputs
=
[
tags
.
input
(
name
=
field
.
input_name
(
form
,
'Label'
),
id
=
slave_id
+
'Label'
,
...
...
@@ -206,7 +208,7 @@ class SEDAMetaField(ff.StringField):
else
:
hidden
=
' hidden'
icon
=
'icon-list-add'
wdgs
.
append
(
tags
.
a
(
u
''
,
onclick
=
unicod
e
(
js
.
seda
.
toggleFormMetaVisibility
(
divid
)),
wdgs
.
append
(
tags
.
a
(
u
''
,
onclick
=
text_typ
e
(
js
.
seda
.
toggleFormMetaVisibility
(
divid
)),
href
=
'javascript:$.noop()'
,
title
=
form
.
_cw
.
_
(
'show/hide meta fields'
),
# take care, related js relies on the icon class position
klass
=
icon
+
' metaFieldSwitch'
))
...
...
xsd2uicfg.py
View file @
70e13297
...
...
@@ -19,6 +19,8 @@ XSD parsing is done using generateDS, which has been copied into the `gends` dir
used bits).
"""
from
six
import
text_type
from
cubicweb
import
neg_role
from
xsd
import
XSDM_MAPPING
...
...
@@ -193,9 +195,9 @@ class UICFGGenerator(CodeGenerator):
yield
mapping
.
etype
,
attributes
class
Code
(
unicod
e
):
"""Special
unicode
subclass whose repr() doesn't add quotes, for insertion of python code in a
data
structure
class
Code
(
text_typ
e
):
"""Special
string
subclass whose repr() doesn't add quotes, for insertion of python code in a
data
structure
"""
def
__repr__
(
self
):
return
str
(
self
)
...
...
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