Skip to content

Commit

Permalink
#2300: scripts: remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs authored and cwschilly committed Sep 20, 2024
1 parent 9ead6d4 commit 01af2d1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions scripts/JSON_data_files_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,6 @@ def __cli(self):
self.__file_suffix = args.file_suffix
self.__validate_comm_links = args.validate_comm_links

@staticmethod
def __check_if_file_exists(file_path: str) -> bool:
""" Check for existence of a given file. Returns True when file exists. """
return os.path.isfile(file_path)

@staticmethod
def __check_if_dir_exists(dir_path: str) -> bool:
""" Check for existence of a given directory. Returns True when file exists. """
return os.path.isdir(dir_path)

@staticmethod
def __get_files_for_validation(dir_path: str, file_prefix: str, file_suffix: str) -> list:
""" Get a sorted list of files from directory. """
Expand Down Expand Up @@ -424,14 +414,14 @@ def __validate_comm_links(data):

def main(self):
if self.__file_path is not None:
if self.__check_if_file_exists(file_path=self.__file_path):
if os.path.isfile(self.__file_path):
self.__validate_file(file_path=self.__file_path,
validate_comm_links=self.__validate_comm_links)
else:
sys.excepthook = exc_handler
raise FileNotFoundError(f"File: {self.__file_path} NOT found")
elif self.__dir_path is not None:
if self.__check_if_dir_exists(dir_path=self.__dir_path):
if os.path.isdir(self.__dir_path):
list_of_files_for_validation = self.__get_files_for_validation(dir_path=self.__dir_path,
file_prefix=self.__file_prefix,
file_suffix=self.__file_suffix)
Expand Down

0 comments on commit 01af2d1

Please sign in to comment.