Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
automated-problem-generation-lib
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUNI-KYPO-CRP
backend-python
automated-problem-generation-lib
Commits
f220495e
Commit
f220495e
authored
3 years ago
by
Juraj Paluba
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop'
parents
3255ec69
fadab68b
No related branches found
No related tags found
1 merge request
!12
Merge develop to master
Checking pipeline status
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
generator/var_parser.py
+22
-16
22 additions, 16 deletions
generator/var_parser.py
setup.cfg
+1
-1
1 addition, 1 deletion
setup.cfg
with
23 additions
and
17 deletions
generator/var_parser.py
+
22
−
16
View file @
f220495e
from
typing
import
List
import
yaml
from
generator.var_object
import
Variable
def
get_variables
(
variables_raw
:
dict
)
->
List
[
Variable
]:
var_objects
=
[]
for
variable_name
,
variable_options
in
variables_raw
.
items
():
v_type
=
variable_options
[
"
type
"
]
v_min
=
variable_options
.
get
(
"
min
"
)
v_max
=
variable_options
.
get
(
"
max
"
)
v_length
=
variable_options
.
get
(
"
length
"
)
v_prohibited
=
variable_options
.
get
(
"
prohibited
"
)
if
v_prohibited
is
None
:
v_prohibited
=
[]
var_objects
.
append
(
Variable
(
variable_name
,
v_type
,
v_min
,
v_max
,
v_prohibited
,
v_length
))
return
var_objects
def
parser_var_file
(
var_file
):
"""
Main function to parsen source data stored in file.
...
...
@@ -19,20 +36,9 @@ def parser_var_file(var_file):
"""
try
:
var_list
=
yaml
.
load
(
var_file
,
Loader
=
yaml
.
FullLoader
)
var_objects
=
[]
for
var
in
var_list
.
keys
():
v_name
=
var
v_type
=
var_list
[
var
][
"
type
"
]
v_min
=
var_list
[
var
].
get
(
"
min
"
)
v_max
=
var_list
[
var
].
get
(
"
max
"
)
v_length
=
var_list
[
var
].
get
(
"
length
"
)
v_prohibited
=
var_list
[
var
].
get
(
"
prohibited
"
)
if
v_prohibited
is
None
:
v_prohibited
=
[]
var_objects
.
append
(
Variable
(
v_name
,
v_type
,
v_min
,
v_max
,
v_prohibited
,
v_length
))
except
Exception
as
e
:
print
(
"
Error occure
"
)
variables_raw
=
yaml
.
load
(
var_file
,
Loader
=
yaml
.
FullLoader
)
return
get_variables
(
variables_raw
)
except
Exception
as
exc
:
# TODO: Remove this horrendous exception handling!
print
(
f
"
Something went wrong:
{
exc
}
"
)
return
None
return
var_objects
This diff is collapsed.
Click to expand it.
setup.cfg
+
1
−
1
View file @
f220495e
[metadata]
version
=
v0.1.
0rc1
version
=
v0.1.
2
\ 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