Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fml40-reference-implementation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KWH40
fml40-reference-implementation
Commits
be3d879e
Commit
be3d879e
authored
4 years ago
by
C. Albrecht
Browse files
Options
Downloads
Patches
Plain Diff
NEW: added script thing_to_ditto_thing.py
parent
39e32122
Branches
gitkeep
No related tags found
1 merge request
!4
Dev chen
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/thing_to_ditto_thing.py
+34
-0
34 additions, 0 deletions
scripts/thing_to_ditto_thing.py
with
34 additions
and
0 deletions
scripts/thing_to_ditto_thing.py
0 → 100644
+
34
−
0
View file @
be3d879e
import
json
def
add_feature
(
features
,
feature_id
,
feature_name
):
short_id
=
feature_id
[
14
:]
properties
=
{
feature_name
:
""
}
features
[
short_id
]
=
{
"
properties
"
:
properties
}
def
transform
(
obj
,
features
):
for
key
in
obj
:
value
=
obj
[
key
]
if
isinstance
(
value
,
dict
):
transform
(
value
,
features
)
elif
isinstance
(
value
,
list
):
for
ele
in
value
:
if
isinstance
(
ele
,
dict
):
transform
(
ele
,
features
)
elif
isinstance
(
value
,
str
):
if
value
.
startswith
(
"
ditto-feature:
"
):
add_feature
(
features
,
value
,
key
)
def
main
():
filename
=
""
with
open
(
filename
,
"
r
"
)
as
in_file
:
thing
=
json
.
load
(
in_file
)
features
=
thing
.
get
(
"
features
"
,
None
)
if
not
features
:
features
=
{}
thing
[
"
features
"
]
=
features
transform
(
thing
,
features
)
print
(
json
.
dumps
(
thing
,
indent
=
2
))
main
()
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