Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion hack/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
import yaml


def walk_yaml(directory, revision=None):
def walk_yaml(directory, revision=None, allowed_extensions=None):
if revision is None:
for root, _, files in os.walk(directory):
for filename in files:
if not filename.endswith('.yaml'):
if allowed_extensions:
_, ext = os.path.splitext(filename)
if ext not in allowed_extensions:
raise ValueError('invalid filename: {!r} (allowed extensions: {})'.format(os.path.join(root, filename), allowed_extensions))
continue
path = os.path.join(root, filename)
with open(path) as f:
Expand Down
2 changes: 1 addition & 1 deletion hack/validate-blocked-edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def validate_blocked_edges(directory):
for path, data in util.walk_yaml(directory=directory):
for path, data in util.walk_yaml(directory=directory, allowed_extensions=('.yaml',)):
try:
validate_blocked_edge(data=data)
except Exception as error:
Expand Down