Added logic to handle not external base classes
This commit is contained in:
parent
aa56fa473b
commit
318a8362ca
11
src/py_to_uxf/appsettings.json
Normal file
11
src/py_to_uxf/appsettings.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"Parser": {
|
||||||
|
"IgnoreClassNames": [
|
||||||
|
"ABC",
|
||||||
|
"Enum"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"UMLCreator": {
|
||||||
|
"MaxPixelX": 1500
|
||||||
|
}
|
||||||
|
}
|
@ -28,6 +28,10 @@ class Startup(StartupABC):
|
|||||||
|
|
||||||
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
||||||
environment.set_runtime_directory(os.path.dirname(__file__))
|
environment.set_runtime_directory(os.path.dirname(__file__))
|
||||||
|
if os.path.isfile('py_to_uxf/appsettings.json'):
|
||||||
|
configuration.add_json_file('py_to_uxf/appsettings.json', optional=False, output=False)
|
||||||
|
else:
|
||||||
|
configuration.add_json_file('appsettings.json', optional=False, output=False)
|
||||||
|
|
||||||
configuration.add_console_argument(ConsoleArgument('-', 'p', [], ' ', False, [
|
configuration.add_console_argument(ConsoleArgument('-', 'p', [], ' ', False, [
|
||||||
ConsoleArgument('-', 'o', [], ' ', is_value_token_optional=False)
|
ConsoleArgument('-', 'o', [], ' ', is_value_token_optional=False)
|
||||||
|
25
src/py_to_uxf_core/configuration/__init__.py
Normal file
25
src/py_to_uxf_core/configuration/__init__.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
py_to_uxf
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:copyright: (c)
|
||||||
|
:license:
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'py_to_uxf_core.configuration'
|
||||||
|
__author__ = ''
|
||||||
|
__license__ = ''
|
||||||
|
__copyright__ = 'Copyright (c) '
|
||||||
|
__version__ = '0.0.0'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major='0', minor='0', micro='0')
|
23
src/py_to_uxf_core/configuration/parser_settings.py
Normal file
23
src/py_to_uxf_core/configuration/parser_settings.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
|
from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC
|
||||||
|
from cpl_core.console import Console
|
||||||
|
|
||||||
|
|
||||||
|
class ParserSettings(ConfigurationModelABC):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
ConfigurationModelABC.__init__(self)
|
||||||
|
|
||||||
|
self._ignore_class_names = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ignore_class_names(self) -> list[str]:
|
||||||
|
return self._ignore_class_names
|
||||||
|
|
||||||
|
def from_dict(self, settings: dict):
|
||||||
|
try:
|
||||||
|
self._ignore_class_names = settings['IgnoreClassNames']
|
||||||
|
except Exception as e:
|
||||||
|
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {self.__name__} settings')
|
||||||
|
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
@ -1,17 +1,20 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
from cpl_core.console import Console
|
from cpl_core.console import Console
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
from py_to_uxf_core.abc.implementation_scanner_abc import ImplementationScannerABC
|
from py_to_uxf_core.abc.implementation_scanner_abc import ImplementationScannerABC
|
||||||
|
from py_to_uxf_core.configuration.parser_settings import ParserSettings
|
||||||
from py_to_uxf_core.model.class_implementation import ClassImplementation
|
from py_to_uxf_core.model.class_implementation import ClassImplementation
|
||||||
from py_to_uxf_core.model.python_class import PythonClass
|
from py_to_uxf_core.model.python_class import PythonClass
|
||||||
|
|
||||||
|
|
||||||
class ImplementationScannerService(ImplementationScannerABC):
|
class ImplementationScannerService(ImplementationScannerABC):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, configuration: ConfigurationABC):
|
||||||
pass
|
ImplementationScannerABC.__init__(self)
|
||||||
|
self._parser_settings: ParserSettings = configuration.get_configuration(ParserSettings)
|
||||||
|
|
||||||
def scan_line_for_implementation(self, line: str, classes: List[PythonClass]) -> Optional[ClassImplementation]:
|
def scan_line_for_implementation(self, line: str, classes: List[PythonClass]) -> Optional[ClassImplementation]:
|
||||||
line = line.replace(' ', '')
|
line = line.replace(' ', '')
|
||||||
@ -24,9 +27,13 @@ class ImplementationScannerService(ImplementationScannerABC):
|
|||||||
|
|
||||||
base_name = line.split('(')[1].split(')')[0]
|
base_name = line.split('(')[1].split(')')[0]
|
||||||
base: Optional[PythonClass] = classes.where(lambda c: c.name == base_name).first_or_default()
|
base: Optional[PythonClass] = classes.where(lambda c: c.name == base_name).first_or_default()
|
||||||
if base is None:
|
if base_name in self._parser_settings.ignore_class_names:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if base is None:
|
||||||
|
new_base = PythonClass(base_name)
|
||||||
|
classes.append(new_base)
|
||||||
|
return ClassImplementation(new_base, sub)
|
||||||
|
|
||||||
return ClassImplementation(base, sub)
|
return ClassImplementation(base, sub)
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from cpl_core.console import Console
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
from py_to_uxf_core.abc.umlet_creator_abc import UmletCreatorABC
|
from py_to_uxf_core.abc.umlet_creator_abc import UmletCreatorABC
|
||||||
|
Loading…
Reference in New Issue
Block a user