Skip to content

Commit 80cc146

Browse files
committed
init dtl support
1 parent 035c60f commit 80cc146

File tree

9 files changed

+581
-66
lines changed

9 files changed

+581
-66
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
33

44
[project]
55
name = "iris_pex_embedded_python"
6-
version = "3.1.6"
6+
version = "3.2.0"
77
description = "Iris Interoperability based on Embedded Python"
88
readme = "README.md"
99
authors = [
@@ -30,7 +30,8 @@ dependencies = [
3030
"dacite >=1.6.0",
3131
"xmltodict>=0.12.0",
3232
"iris-embedded-python-wrapper>=0.0.6",
33-
"setuptools >= 40.8.0"
33+
"setuptools >= 40.8.0",
34+
"dc-schema >= 0.0.8"
3435
]
3536

3637
license = { file = "LICENSE" }

requirements-dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ requests
66
dataclasses-json
77
wheel
88
twine
9-
iris-embedded-python-wrapper
9+
iris-embedded-python-wrapper
10+
dc-schema

src/iop/_utils.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import xmltodict
77
import pkg_resources
88
import importlib
9+
import json
10+
from dc_schema import get_schema
911

1012
class _Utils():
1113
@staticmethod
@@ -33,6 +35,33 @@ def setup(path:str = None):
3335
if path:
3436
_Utils.raise_on_error(iris.cls('%SYSTEM.OBJ').LoadDir(path,'cubk',"*.cls",1))
3537

38+
@staticmethod
39+
def register_message_schema(cls):
40+
"""
41+
It takes a class and registers the schema
42+
43+
:param cls: The class to register
44+
"""
45+
schema = get_schema(cls)
46+
schema_name = cls.__module__ + '.' + cls.__name__
47+
schema_str = json.dumps(schema)
48+
categories = schema_name
49+
_Utils.register_schema(schema_name,schema_str,categories)
50+
51+
@staticmethod
52+
def register_schema(schema_name:str, schema_str:str,categories:str):
53+
"""
54+
It takes a schema name, a schema string, and a category string, and registers the schema
55+
56+
:param schema_name: The name of the schema
57+
:type schema_name: str
58+
:param schema_str: The schema as a string
59+
:type schema_str: str
60+
:param categories: The categories of the schema
61+
:type categories: str
62+
"""
63+
_Utils.raise_on_error(iris.cls('IOP.Message.JSONSchema').Import(schema_str,categories,schema_name))
64+
3665
@staticmethod
3766
def register_component(module:str,classname:str,path:str,overwrite:int=1,iris_classname:str='Python'):
3867
"""
@@ -128,7 +157,7 @@ def _register_file(filename:str,path:str,overwrite:int=1,iris_package_name:str='
128157
extend = klass.bases[0].id
129158
else:
130159
extend = klass.bases[0].attr
131-
if extend in ('BusinessOperation','BusinessProcess','BusinessService','DuplexService','DuplexProcess','DuplexOperation','InboundAdapter','OutboundAdapter'):
160+
if extend in ('BusinessOperation','BusinessProcess','BusinessService','DuplexService','DuplexProcess','DuplexOperation','InboundAdapter','OutboundAdapter'):
132161
module = _Utils.filename_to_module(filename)
133162
iris_class_name = f"{iris_package_name}.{module}.{klass.name}"
134163
# strip "_" for iris class name
@@ -188,6 +217,8 @@ def migrate(filename=None):
188217
list of dictionaries:
189218
* key: the name of the production
190219
* value: a dictionary containing the settings for the production
220+
* SCHEMAS
221+
List of classes
191222
"""
192223
path = None
193224
# try to load the settings file
@@ -216,6 +247,12 @@ def migrate(filename=None):
216247
_Utils.set_productions_settings(settings.PRODUCTIONS,path)
217248
except AttributeError:
218249
print("No productions to register")
250+
try:
251+
# set the schemas
252+
for cls in settings.SCHEMAS:
253+
_Utils.register_message_schema(cls)
254+
except AttributeError:
255+
print("No schemas to register")
219256
try:
220257
sys.path.remove(path)
221258
except ValueError:

0 commit comments

Comments
 (0)