Skip to content

Commit

Permalink
Clean up Code Climate Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mab879 committed Jun 12, 2024
1 parent 79c21ad commit 37500b9
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions tests/validate_automatus_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,33 @@ def _test_filename_valid(test_file: str) -> bool:
return True


def _has_invalid_param(root: str, test_file: str) -> bool:
full_path = os.path.join(root, test_file)
with open(full_path, "r") as f:
for line in f:
if not line.startswith("#"):
break
line = line.removeprefix('#')
line = line.strip()
parts = line.split('=')
if len(parts) != 2:
continue
param_name = parts[0].strip()
if param_name not in VALID_FIELDS:
print(f"Invalid field '{param_name}' in {test_file}", file=sys.stderr)
return False
return True


def main() -> int:
args = _parse_args()
test_files = get_files(args.root)
return_value = 0
for test_file in test_files:
if not _test_filename_valid(test_file) != 0:
if not _test_filename_valid(test_file):
return_value = 1
if not _has_invalid_param(args.root, test_file):
return_value = 1
full_path = os.path.join(args.root, test_file)
with open(full_path, "r") as f:
for line in f:
if not line.startswith("#"):
break
line = line.removeprefix('#')
line = line.strip()
parts = line.split('=')
if len(parts) != 2:
continue
if parts[0].strip() not in VALID_FIELDS:
print(f"Invalid field '{parts[0].strip()}' in {test_file}", file=sys.stderr)
return_value = 1

return return_value


Expand Down

0 comments on commit 37500b9

Please sign in to comment.