Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CCS
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marko Mecina
CCS
Commits
9f329268
Commit
9f329268
authored
3 years ago
by
Marko Mecina
Browse files
Options
Downloads
Patches
Plain Diff
add converter from specification CSV to JSON
parent
90912d4a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tst/spec_to_json.py
+81
-0
81 additions, 0 deletions
Tst/spec_to_json.py
Tst/tst_template_empty.json
+38
-0
38 additions, 0 deletions
Tst/tst_template_empty.json
with
119 additions
and
0 deletions
Tst/spec_to_json.py
0 → 100755
+
81
−
0
View file @
9f329268
#!/usr/bin/env python
import
json
import
sys
sys
.
path
.
append
(
'
../Ccs
'
)
import
ccs_function_lib
as
cfl
def
run
(
specfile
,
gen_cmd
):
tmp
=
json
.
load
(
open
(
'
tst_template_empty.json
'
,
'
r
'
))
jspec
=
tmp
.
copy
()
specs
=
open
(
specfile
,
'
r
'
).
read
().
split
(
'
\n
'
)
name
,
descr
,
*
_
=
specs
[
1
].
split
(
'
|
'
)
jspec
[
'
_name
'
]
=
name
jspec
[
'
_description
'
]
=
descr
jspec
[
'
_version
'
]
=
''
steps
=
jspec
[
'
sequences
'
][
0
][
'
steps
'
]
step_temp
=
steps
[
0
].
copy
()
steps
=
[]
for
step
in
specs
[
4
:]:
if
step
.
count
(
'
|
'
)
!=
3
:
continue
n
,
descr
,
ver
,
_
=
step
.
split
(
'
|
'
)
if
not
n
.
lower
().
startswith
((
'
step
'
,
'
comment
'
)):
continue
if
n
.
lower
()
==
'
comment
'
:
step
=
steps
[
-
1
]
step
[
'
_step_comment
'
]
=
descr
continue
step_temp
[
'
_step_number
'
]
=
n
.
replace
(
'
Step
'
,
''
)
+
'
.0
'
step_temp
[
'
_primary_counter
'
]
=
int
(
n
.
replace
(
'
Step
'
,
''
))
step_temp
[
'
_description
'
]
=
descr
step_temp
[
'
_verification_description
'
]
=
ver
if
gen_cmd
and
(
'
TC(
'
in
descr
):
try
:
i
=
descr
.
index
(
'
TC(
'
)
+
3
j
=
descr
.
index
(
'
)
'
,
i
)
st
,
sst
=
map
(
int
,
descr
[
i
:
j
].
split
(
'
,
'
))
cmd
=
cfl
.
get_tc_descr_from_stsst
(
st
,
sst
)
if
len
(
cmd
)
>
1
:
for
c
in
cmd
:
if
c
in
descr
:
_cmd
=
c
break
_cmd
=
cmd
[
0
]
else
:
_cmd
=
cmd
[
0
]
cmdtxt
=
cfl
.
make_tc_template
(
_cmd
,
add_parcfg
=
True
)
except
Exception
as
err
:
print
(
err
)
else
:
cmdtxt
=
''
step_temp
[
'
_command_code
'
]
=
cmdtxt
steps
.
append
(
step_temp
.
copy
())
jspec
[
'
sequences
'
][
0
][
'
steps
'
]
=
steps
json
.
dump
(
jspec
,
open
(
specfile
+
'
.json
'
,
'
w
'
),
indent
=
4
)
if
__name__
==
"
__main__
"
:
if
'
--nocmd
'
in
sys
.
argv
:
gen_cmd
=
False
sys
.
argv
.
remove
(
'
--nocmd
'
)
else
:
gen_cmd
=
True
specfile
=
sys
.
argv
[
1
]
run
(
specfile
,
gen_cmd
)
This diff is collapsed.
Click to expand it.
Tst/tst_template_empty.json
0 → 100644
+
38
−
0
View file @
9f329268
{
"_comment"
:
""
,
"_description"
:
""
,
"_name"
:
""
,
"_postcon_code"
:
""
,
"_postcon_descr"
:
""
,
"_postcon_name"
:
""
,
"_precon_code"
:
""
,
"_precon_descr"
:
""
,
"_precon_name"
:
""
,
"_primary_counter_locked"
:
false
,
"_version"
:
""
,
"sequences"
:
[
{
"_description"
:
""
,
"_name"
:
""
,
"_primary_counter_locked"
:
false
,
"_sequence"
:
0
,
"_version"
:
""
,
"steps"
:
[
{
"_command_code"
:
""
,
"_description"
:
""
,
"_is_active"
:
true
,
"_primary_counter"
:
1
,
"_secondary_counter"
:
0
,
"_start_sequence"
:
null
,
"_step_comment"
:
""
,
"_step_number"
:
"1.0"
,
"_stop_sequence"
:
null
,
"_verification_code"
:
""
,
"_verification_description"
:
""
,
"_verified_item"
:
[]
}
]
}
]
}
\ No newline at end of file
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