Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
00dbd25b
Commit
00dbd25b
authored
3 years ago
by
Jean-Marie Place
Browse files
Options
Downloads
Patches
Plain Diff
enable xml/json result as file
parent
1741e75f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/scodoc/sco_formations.py
+1
-1
1 addition, 1 deletion
app/scodoc/sco_formations.py
app/scodoc/sco_utils.py
+7
-7
7 additions, 7 deletions
app/scodoc/sco_utils.py
with
8 additions
and
8 deletions
app/scodoc/sco_formations.py
+
1
−
1
View file @
00dbd25b
...
...
@@ -130,7 +130,7 @@ def formation_export(formation_id, export_ids=False, export_tags=True, format=No
if
mod
[
"
ects
"
]
is
None
:
del
mod
[
"
ects
"
]
return
scu
.
sendResult
(
F
,
name
=
"
formation
"
,
format
=
format
,
force_outer_xml_tag
=
False
)
return
scu
.
sendResult
(
F
,
name
=
"
formation
"
,
format
=
format
,
force_outer_xml_tag
=
False
,
attached
=
True
)
def
formation_import_xml
(
doc
:
str
,
import_tags
=
True
):
...
...
This diff is collapsed.
Click to expand it.
app/scodoc/sco_utils.py
+
7
−
7
View file @
00dbd25b
...
...
@@ -553,28 +553,28 @@ class ScoDocJSONEncoder(json.JSONEncoder):
return
json
.
JSONEncoder
.
default
(
self
,
o
)
def
sendJSON
(
data
):
def
sendJSON
(
data
,
attached
=
False
):
js
=
json
.
dumps
(
data
,
indent
=
1
,
cls
=
ScoDocJSONEncoder
)
return
send_file
(
js
,
filename
=
"
sco_data.json
"
,
mime
=
JSON_MIMETYPE
,
attached
=
False
)
return
send_file
(
js
,
filename
=
"
sco_data.json
"
,
mime
=
JSON_MIMETYPE
,
attached
=
attached
)
def
sendXML
(
data
,
tagname
=
None
,
force_outer_xml_tag
=
True
):
def
sendXML
(
data
,
tagname
=
None
,
force_outer_xml_tag
=
True
,
attached
=
False
):
if
type
(
data
)
!=
list
:
data
=
[
data
]
# always list-of-dicts
if
force_outer_xml_tag
:
data
=
[{
tagname
:
data
}]
tagname
+=
"
_list
"
doc
=
sco_xml
.
simple_dictlist2xml
(
data
,
tagname
=
tagname
)
return
send_file
(
doc
,
filename
=
"
sco_data.xml
"
,
mime
=
XML_MIMETYPE
,
attached
=
False
)
return
send_file
(
doc
,
filename
=
"
sco_data.xml
"
,
mime
=
XML_MIMETYPE
,
attached
=
attached
)
def
sendResult
(
data
,
name
=
None
,
format
=
None
,
force_outer_xml_tag
=
True
):
def
sendResult
(
data
,
name
=
None
,
format
=
None
,
force_outer_xml_tag
=
True
,
attached
=
False
):
if
(
format
is
None
)
or
(
format
==
"
html
"
):
return
data
elif
format
==
"
xml
"
:
# name is outer tagname
return
sendXML
(
data
,
tagname
=
name
,
force_outer_xml_tag
=
force_outer_xml_tag
)
return
sendXML
(
data
,
tagname
=
name
,
force_outer_xml_tag
=
force_outer_xml_tag
,
attached
=
attached
)
elif
format
==
"
json
"
:
return
sendJSON
(
data
)
return
sendJSON
(
data
,
attached
=
attached
)
else
:
raise
ValueError
(
"
invalid format: %s
"
%
format
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment