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):
self._attributes.append(attribute)
def __str__(self):
return f'{self._name}'
def __repr__(self):
return f'{self._name}'

View File

@ -33,21 +33,27 @@ class ImplementationScannerService(ImplementationScannerABC):
line = line.replace('\t', '')
if line.startswith('class ') and '(' in line and ')' in line:
sub_name = line.split('class ')[1].split('(')[0]
sub: Optional[PythonClass] = classes.where(lambda c: c.name == sub_name).first_or_default()
if sub is None:
return None
subclasses = classes.where(lambda c: c.name == sub_name)
implementations = List(ClassImplementation)
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(' ', '')
base_name = line.split('(')[1].split(')')[0]
if ',' in base_name:
implementations = List(ClassImplementation)
for name in base_name.split(','):
if '=' in name:
continue
line = line.replace(' ', '')
base_name = line.split('(')[1].split(')')[0]
if ',' in base_name:
for name in base_name.split(','):
if '=' in name:
continue
implementation = self._get_implementation(name, sub, classes)
if implementation is not None:
implementations.append(implementation)
return implementations
return self._get_implementation(base_name, sub, classes)
implementation = self._get_implementation(name, sub, classes)
if implementation is not None:
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 None