Added support for multiple subclasses

This commit is contained in:
Sven Heidemann 2022-01-18 19:15:48 +01:00
parent 1eb7aa37d3
commit f41e31371f
2 changed files with 27 additions and 15 deletions

View File

@ -28,3 +28,9 @@ class PythonClass:
def add_attribute(self, attribute: PythonClassAttribute): def add_attribute(self, attribute: PythonClassAttribute):
self._attributes.append(attribute) self._attributes.append(attribute)
def __str__(self):
return f'{self._name}'
def __repr__(self):
return f'{self._name}'

View File

@ -33,14 +33,16 @@ class ImplementationScannerService(ImplementationScannerABC):
line = line.replace('\t', '') line = line.replace('\t', '')
if line.startswith('class ') and '(' in line and ')' in line: if line.startswith('class ') and '(' in line and ')' in line:
sub_name = line.split('class ')[1].split('(')[0] sub_name = line.split('class ')[1].split('(')[0]
sub: Optional[PythonClass] = classes.where(lambda c: c.name == sub_name).first_or_default() subclasses = classes.where(lambda c: c.name == sub_name)
if sub is None: implementations = List(ClassImplementation)
return None for sub in subclasses:
# sub: Optional[PythonClass] = classes.where(lambda c: c.name == sub_name).first_or_default()
# if sub is None:
# return None
line = line.replace(' ', '') line = line.replace(' ', '')
base_name = line.split('(')[1].split(')')[0] base_name = line.split('(')[1].split(')')[0]
if ',' in base_name: if ',' in base_name:
implementations = List(ClassImplementation)
for name in base_name.split(','): for name in base_name.split(','):
if '=' in name: if '=' in name:
continue continue
@ -48,6 +50,10 @@ class ImplementationScannerService(ImplementationScannerABC):
implementation = self._get_implementation(name, sub, classes) implementation = self._get_implementation(name, sub, classes)
if implementation is not None: if implementation is not None:
implementations.append(implementation) implementations.append(implementation)
# return implementations
# return self._get_implementation(base_name, sub, classes)
implementation = self._get_implementation(base_name, sub, classes)
if implementation is not None:
implementations.append(implementation)
return implementations return implementations
return self._get_implementation(base_name, sub, classes)
return None return None