Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Niegsch
erp5
Commits
b8ef41df
Commit
b8ef41df
authored
Sep 06, 2013
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up the code to use OFS.XMLExportImport library to read XML instead if use a custom parser.
parent
ccec16d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
52 deletions
+16
-52
product/ERP5/tests/utils.py
product/ERP5/tests/utils.py
+16
-52
No files found.
product/ERP5/tests/utils.py
View file @
b8ef41df
...
@@ -30,6 +30,9 @@ import tarfile
...
@@ -30,6 +30,9 @@ import tarfile
import
xml.parsers.expat
import
xml.parsers.expat
import
xml.dom.minidom
import
xml.dom.minidom
from
urllib
import
url2pathname
from
urllib
import
url2pathname
from
ZODB.DemoStorage
import
DemoStorage
from
ZODB
import
DB
from
OFS.XMLExportImport
import
importXML
if
int
(
os
.
environ
.
get
(
'erp5_report_new_simulation_failures'
)
or
0
):
if
int
(
os
.
environ
.
get
(
'erp5_report_new_simulation_failures'
)
or
0
):
newSimulationExpectedFailure
=
lambda
test
:
test
newSimulationExpectedFailure
=
lambda
test
:
test
...
@@ -98,64 +101,25 @@ class BusinessTemplateInfoBase:
...
@@ -98,64 +101,25 @@ class BusinessTemplateInfoBase:
self
.
allowed_content_types
[
portal_type
].
append
(
item
.
childNodes
[
0
].
data
)
self
.
allowed_content_types
[
portal_type
].
append
(
item
.
childNodes
[
0
].
data
)
def
setUpActions
(
self
):
def
setUpActions
(
self
):
class
Handler
:
cur_key
=
None
def
parse
(
file_path
):
old_tag
=
None
db
=
DB
(
DemoStorage
())
cur_tag
=
None
_connection
=
db
.
open
()
key_val
=
None
action_information
=
importXML
(
_connection
,
file_path
)
value_val
=
None
action_information
.
__repr__
()
for
key
,
value
in
action_information
.
__dict__
.
iteritems
():
def
__init__
(
self
):
if
value
not
in
(
None
,
""
)
and
key
in
(
'action'
,
'condition'
)
:
self
.
data
=
{}
setattr
(
action_information
,
key
,
value
.
text
)
actions
=
action_information
.
__dict__
.
copy
()
def
start
(
self
,
name
,
attrs
):
db
.
close
()
if
not
name
in
(
'item'
,
'key'
,
'value'
,
'string'
,
'int'
,
'float'
):
return
actions
return
self
.
old_tag
=
self
.
cur_tag
self
.
cur_tag
=
name
if
name
==
'key'
:
self
.
cur_key
=
name
def
end
(
self
,
name
):
self
.
cur_tag
=
None
if
name
==
'item'
:
self
.
data
[
self
.
key_val
]
=
self
.
value_val
self
.
cur_key
=
None
self
.
key_val
=
None
self
.
value_val
=
None
def
char
(
self
,
data
):
if
self
.
cur_tag
in
(
'string'
,
'int'
,
'float'
):
f
=
getattr
(
self
,
'to%s'
%
self
.
cur_tag
)
if
self
.
old_tag
==
'key'
:
self
.
key_val
=
f
(
data
)
elif
self
.
old_tag
==
'value'
:
self
.
value_val
=
f
(
data
)
def
tostring
(
self
,
value
):
return
str
(
value
)
def
toint
(
self
,
value
):
return
int
(
value
)
def
tofloat
(
self
,
value
):
return
float
(
value
)
def
parse
(
source
):
handler
=
Handler
()
p
=
xml
.
parsers
.
expat
.
ParserCreate
()
p
.
StartElementHandler
=
handler
.
start
p
.
EndElementHandler
=
handler
.
end
p
.
CharacterDataHandler
=
handler
.
char
p
.
Parse
(
source
)
return
handler
.
data
name
=
'%s/ActionTemplateItem/portal_types/'
%
self
.
getPrefix
()
name
=
'%s/ActionTemplateItem/portal_types/'
%
self
.
getPrefix
()
for
i
in
self
.
findFileInfosByName
(
startswith
=
name
,
endswith
=
'.xml'
):
for
i
in
self
.
findFileInfosByName
(
startswith
=
name
,
endswith
=
'.xml'
):
portal_type
=
url2pathname
(
self
.
getFileInfoName
(
i
).
split
(
'/'
)[
-
2
])
portal_type
=
url2pathname
(
self
.
getFileInfoName
(
i
).
split
(
'/'
)[
-
2
])
if
not
portal_type
in
self
.
actions
:
if
not
portal_type
in
self
.
actions
:
self
.
actions
[
portal_type
]
=
[]
self
.
actions
[
portal_type
]
=
[]
data
=
parse
(
self
.
readFileInfo
(
i
)
)
data
=
parse
(
i
)
self
.
actions
[
portal_type
].
append
(
data
)
self
.
actions
[
portal_type
].
append
(
data
)
...
...
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