Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dtk-widgets
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
19
Issues
19
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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
dtk
dtk-widgets
Commits
55d73766
Commit
55d73766
authored
May 17, 2019
by
NICLAUSSE Nicolas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add script to convert old parameters json to new one (move type)
parent
fcadae62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
tst/resources/convert_parameters.py
tst/resources/convert_parameters.py
+44
-0
No files found.
tst/resources/convert_parameters.py
0 → 100755
View file @
55d73766
#!/usr/bin/env python3
import
json
import
argparse
def
parse_group
(
json_o
,
type_map
):
for
c
in
json_o
[
"contents"
]:
if
'group'
in
c
:
parse_group
(
c
[
'group'
],
type_map
)
else
:
uid
=
c
[
'parameter'
][
'uid'
]
newtype
=
c
[
'parameter'
][
'type'
]
del
c
[
'parameter'
][
'type'
]
type_map
[
uid
]
=
newtype
parser
=
argparse
.
ArgumentParser
(
description
=
'Process Convert dtk parameters file to new format (type in def).'
)
parser
.
add_argument
(
'def_file'
,
help
=
'definition file'
)
parser
.
add_argument
(
'menu_file'
,
help
=
'menu file'
)
args
=
parser
.
parse_args
()
def_data
=
open
(
args
.
def_file
)
menu_data
=
open
(
args
.
menu_file
)
def_json
=
json
.
load
(
def_data
)
menu_json
=
json
.
load
(
menu_data
)
type_map
=
{}
for
c
in
menu_json
[
"contents"
]:
parse_group
(
c
[
'group'
],
type_map
)
for
uid
in
def_json
[
"contents"
].
keys
():
if
uid
in
type_map
:
def_json
[
"contents"
][
uid
][
'type'
]
=
type_map
[
uid
]
else
:
print
(
uid
,
"not used !"
)
with
open
(
'new_menu.json'
,
'w'
)
as
outfile
:
print
(
"write new_menu.json"
)
json
.
dump
(
menu_json
,
outfile
,
indent
=
4
,)
with
open
(
'new_definition.json'
,
'w'
)
as
outfile
:
print
(
"write new_definition.json"
)
json
.
dump
(
def_json
,
outfile
,
indent
=
4
,)
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