several bugfixes and improvements
This commit is contained in:
@ -1,37 +1,37 @@
|
||||
"""
|
||||
@file file_list_parser.py
|
||||
@brief Generic File Parser class
|
||||
@details
|
||||
"""Generic File Parser class
|
||||
Used by parse header files. Implemented as class in case header parser becomes more complex
|
||||
@author R. Mueller
|
||||
@date 22.11.2019
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
from typing import Union
|
||||
|
||||
from fsfwgen.core import get_console_logger
|
||||
|
||||
LOGGER = get_console_logger()
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class FileListParser:
|
||||
"""
|
||||
Generic header parser which takes a directory name or directory name list
|
||||
"""Generic header parser which takes a directory name or directory name list
|
||||
and parses all included header files recursively.
|
||||
TODO: Filter functionality for each directory to filter out files or folders
|
||||
"""
|
||||
def __init__(self, directory_list_or_name: Union[str, list]):
|
||||
self.directory_list = []
|
||||
if isinstance(directory_list_or_name, str):
|
||||
self.directory_list = [directory_list_or_name]
|
||||
self.directory_list.append(directory_list_or_name)
|
||||
elif isinstance(directory_list_or_name, list):
|
||||
self.directory_list = directory_list_or_name
|
||||
self.directory_list.extend(directory_list_or_name)
|
||||
else:
|
||||
print("Header Parser: Passed directory list is not a header name or list of "
|
||||
"header names")
|
||||
LOGGER.warning(
|
||||
"Header Parser: Passed directory list is not a header name or list of header names"
|
||||
)
|
||||
self.header_files = []
|
||||
|
||||
def parse_header_files(self, search_recursively: bool = False,
|
||||
printout_string: str = "Parsing header files: ",
|
||||
print_current_dir: bool = False):
|
||||
"""
|
||||
This function is called to get a list of header files
|
||||
"""This function is called to get a list of header files
|
||||
:param search_recursively:
|
||||
:param printout_string:
|
||||
:param print_current_dir:
|
||||
|
@ -17,6 +17,12 @@ from abc import abstractmethod
|
||||
from typing import Dict, List
|
||||
|
||||
|
||||
class VerbosityLevels(enum.Enum):
|
||||
REDUCED = 0,
|
||||
REGULAR = 1,
|
||||
DEBUG = 2
|
||||
|
||||
|
||||
class FileParserModes(enum.Enum):
|
||||
REGULAR = enum.auto(),
|
||||
MOVING_WINDOW = enum.auto()
|
||||
@ -72,6 +78,9 @@ class FileParser:
|
||||
def set_verbosity(self, verbose_level: int):
|
||||
self._verbose_level = verbose_level
|
||||
|
||||
def get_verbosity(self):
|
||||
return self._verbose_level
|
||||
|
||||
def enable_moving_window_debugging(self, file_name: str):
|
||||
self.__debug_moving_window = True
|
||||
self.__debug_moving_window_filename = file_name
|
||||
@ -201,6 +210,8 @@ class FileParser:
|
||||
def _build_multi_line_string_generic(
|
||||
self, first_line: str, moving_window: List[str]
|
||||
) -> str:
|
||||
"""This function transforms a multi line match into a one line match by searching for the
|
||||
semicolon at the string end"""
|
||||
all_lines = first_line.rstrip()
|
||||
end_found = False
|
||||
current_idx = self._moving_window_center_idx
|
||||
|
Reference in New Issue
Block a user