-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84a4ebe
commit 21dd3ae
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ requires-python = '>=3.10, <4' | |
dependencies = [ | ||
'fastapi', | ||
'Jinja2', | ||
'rdflib', | ||
] | ||
|
||
[project.urls] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uvicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
export $(grep -v '^#' .env | xargs) | ||
|
||
uvicorn fip2dmp_importer:app --reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class _MappingExecutor: | ||
|
||
def __init__(self): | ||
self.result = [] | ||
self.variables = {} | ||
|
||
def reset(self): | ||
self.result = [] | ||
self.variables = {} | ||
|
||
def result_add(self, action: str, **kwargs): | ||
self.result.append({ | ||
'type': action, | ||
**kwargs, | ||
}) | ||
|
||
def result_debug(self, message: str): | ||
self.result_add(action='debug', message=message) | ||
|
||
def result_add_item(self, path: str, var_name: str): | ||
self.result_add(action='addItem', path=path.split('.'), var=var_name) | ||
|
||
def result_set_reply(self, path: str, value: str): | ||
self.result_add(action='setReply', path=path.split('.'), value=value) | ||
|
||
def result_set_integration_reply(self, path: str, value: str, item_id): | ||
self.result_add(action='setIntegrationReply', path=path.split('.'), value=value, itemId=item_id) | ||
|
||
def get_result_dict(self): | ||
return { | ||
'actions': self.result, | ||
} | ||
|
||
|
||
def prepare_import_mapping(contents: str, content_type: str) -> dict: | ||
executor = _MappingExecutor() | ||
|
||
# TODO: process contents in custom functions, etc. | ||
|
||
return executor.get_result_dict() |