Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils-sfg
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils-sfg
Commits
dc59e7cc
Commit
dc59e7cc
authored
1 year ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
added configurator exection; untested
parent
475d99b5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencilssfg/configuration.py
+22
-2
22 additions, 2 deletions
pystencilssfg/configuration.py
with
22 additions
and
2 deletions
pystencilssfg/configuration.py
+
22
−
2
View file @
dc59e7cc
from
__future__
import
annotations
from
typing
import
List
,
Sequence
from
typing
import
List
,
Sequence
,
Any
from
enum
import
Enum
,
auto
from
dataclasses
import
dataclass
,
replace
,
asdict
,
InitVar
from
argparse
import
ArgumentParser
from
os
import
path
import
importlib
from
jinja2.filters
import
do_indent
...
...
@@ -60,6 +63,9 @@ class SfgConfiguration:
output_directory
:
str
=
None
"""
Directory to which the generated files should be written.
"""
project_info
:
Any
=
None
"""
Object for managing project-specific information. To be set by the configurator script.
"""
def
__post_init__
(
self
,
cfg_src
:
SfgConfigSource
=
None
):
if
self
.
header_only
:
raise
SfgConfigException
(
cfg_src
,
"
Header-only code generation is not implemented yet.
"
)
...
...
@@ -88,7 +94,21 @@ DEFAULT_CONFIG = SfgConfiguration(
def
run_configurator
(
configurator_script
:
str
):
raise
NotImplementedError
()
if
not
path
.
exists
(
configurator_script
):
raise
SfgConfigException
(
SfgConfigSource
.
PROJECT
,
f
"
Configurator script not found:
{
configurator_script
}
is not a file.
"
)
cfg_spec
=
importlib
.
util
.
spec_from_file_location
(
configurator_script
)
configurator
=
importlib
.
util
.
module_from_spec
(
cfg_spec
)
if
not
hasattr
(
project_config
,
"
sfg_config
"
):
raise
SfgConfigException
(
SfgConfigSource
.
PROJECT
,
"
Project configurator does not define function `sfg_config`.
"
)
project_config
=
configurator
.
sfg_config
()
if
not
isinstance
(
project_config
,
SfgConfiguration
):
raise
SfgConfigException
(
SfgConfigSource
.
PROJECT
,
"
sfg_config did not return a SfgConfiguration object.
"
)
return
project_config
def
add_config_args_to_parser
(
parser
:
ArgumentParser
):
...
...
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