Skip to content

Commit

Permalink
Change filenames to be OS specific paths
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Apr 25, 2024
1 parent eaf23ca commit 942db17
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/cfnlint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import sys
from pathlib import Path
from typing import Dict
from typing import Dict, List, Sequence

import jsonschema

Expand Down Expand Up @@ -692,23 +692,10 @@ def templates(self):
if isinstance(filenames, str):
filenames = [filenames]

# handle different shells and Config files
# some shells don't expand * and configparser won't expand wildcards
all_filenames = []
ignore_templates = self._ignore_templates()
for filename in filenames:
add_filenames = glob.glob(filename, recursive=True)
# only way to know of the glob failed is to test it
# then add the filename as requested
if not add_filenames:
if filename not in ignore_templates:
all_filenames.append(filename)
else:
for add_filename in add_filenames:
if add_filename not in ignore_templates:
all_filenames.append(add_filename)
all_filenames = self._glob_filenames(filenames)

return sorted(all_filenames)
return [i for i in all_filenames if i not in ignore_templates]

def _ignore_templates(self):
ignore_template_args = self._get_argument_value("ignore_templates", False, True)
Expand All @@ -721,9 +708,13 @@ def _ignore_templates(self):
if isinstance(filenames, str):
filenames = [filenames]

return self._glob_filenames(filenames)

def _glob_filenames(self, filenames: Sequence[str]) -> List[str]:
# handle different shells and Config files
# some shells don't expand * and configparser won't expand wildcards
all_filenames = []

for filename in filenames:
add_filenames = glob.glob(filename, recursive=True)
# only way to know of the glob failed is to test it
Expand All @@ -733,7 +724,7 @@ def _ignore_templates(self):
else:
all_filenames.extend(add_filenames)

return all_filenames
return sorted(list(map(str, map(Path, all_filenames))))

@property
def append_rules(self):
Expand Down

0 comments on commit 942db17

Please sign in to comment.