Fixed attribute parsing
This commit is contained in:
parent
9a4de29af8
commit
f7edc44154
@ -26,6 +26,9 @@ class AttributeScannerService(AttributeScannerABC):
|
|||||||
if name.startswith('self.'):
|
if name.startswith('self.'):
|
||||||
name = name.split('self.')[1]
|
name = name.split('self.')[1]
|
||||||
|
|
||||||
|
if '.' in name:
|
||||||
|
return None
|
||||||
|
|
||||||
access_modifier = AccessModifierEnum.public
|
access_modifier = AccessModifierEnum.public
|
||||||
type_str = 'any'
|
type_str = 'any'
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ class ClassScannerService(ClassScannerABC):
|
|||||||
ClassScannerABC.__init__(self)
|
ClassScannerABC.__init__(self)
|
||||||
|
|
||||||
def scan_line_for_classes(self, line: str) -> Optional[PythonClass]:
|
def scan_line_for_classes(self, line: str) -> Optional[PythonClass]:
|
||||||
|
line = line.replace(' ', '')
|
||||||
|
line = line.replace('\t', '')
|
||||||
if line.startswith('class'):
|
if line.startswith('class'):
|
||||||
name = line.split('class ')[1]
|
name = line.split('class ')[1]
|
||||||
if '(' in name:
|
if '(' in name:
|
||||||
|
@ -22,6 +22,7 @@ class FunctionScannerService(FunctionScannerABC):
|
|||||||
# async def _xy(x: int, y: int) -> int:
|
# async def _xy(x: int, y: int) -> int:
|
||||||
# async def __xy(x: int, y: int) -> int:
|
# async def __xy(x: int, y: int) -> int:
|
||||||
if line.startswith('def') or line.startswith('async def'):
|
if line.startswith('def') or line.startswith('async def'):
|
||||||
|
line = line.replace('\t', '')
|
||||||
# name
|
# name
|
||||||
name = line.split('def ')[1]
|
name = line.split('def ')[1]
|
||||||
name = name.split('(')[0]
|
name = name.split('(')[0]
|
||||||
|
@ -32,9 +32,11 @@ class PythonParserService(PythonParserABC):
|
|||||||
classes = List(PythonClass)
|
classes = List(PythonClass)
|
||||||
for file in files:
|
for file in files:
|
||||||
is_comment = False
|
is_comment = False
|
||||||
|
is_function = False
|
||||||
with open(file, 'r') as file_content:
|
with open(file, 'r') as file_content:
|
||||||
cls: Optional[PythonClass] = None
|
cls: Optional[PythonClass] = None
|
||||||
for line in file_content.readlines():
|
for line in file_content.readlines():
|
||||||
|
line_with_tabs = line
|
||||||
line = line.replace(' ', '')
|
line = line.replace(' ', '')
|
||||||
line = line.replace('\t', '')
|
line = line.replace('\t', '')
|
||||||
# replace line break at the end of line
|
# replace line break at the end of line
|
||||||
@ -42,6 +44,8 @@ class PythonParserService(PythonParserABC):
|
|||||||
line = line.replace('\n', '')
|
line = line.replace('\n', '')
|
||||||
|
|
||||||
if line == '\n' or line == '':
|
if line == '\n' or line == '':
|
||||||
|
if is_function:
|
||||||
|
is_function = False
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# one line comments
|
# one line comments
|
||||||
@ -70,6 +74,10 @@ class PythonParserService(PythonParserABC):
|
|||||||
func = self._function_scanner.scan_line_for_function(line)
|
func = self._function_scanner.scan_line_for_function(line)
|
||||||
if func is not None:
|
if func is not None:
|
||||||
cls.add_function(func)
|
cls.add_function(func)
|
||||||
|
is_function = True if func.name != '__init__' else False
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(line_with_tabs.split(' ')) > 3 or is_function:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
attribute = self._attribute_scanner.scan_line_for_attribute(line)
|
attribute = self._attribute_scanner.scan_line_for_attribute(line)
|
||||||
|
Loading…
Reference in New Issue
Block a user