Skip to content

Commit

Permalink
chore: use iterdir() instead of glob("*")
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Sep 25, 2023
1 parent c31af83 commit 989d62d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data_registry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, *args, **kwargs):

# collect all years from annual dump files names
flags_dir = "data_registry/static/img/flags"
files = [f.name for f in Path(flags_dir).glob("*") if f.is_file()]
files = [f.name for f in Path(flags_dir).iterdir() if f.is_file()]
files.sort()
self.fields["country_flag"].choices += tuple((n, n) for n in files)

Expand Down
2 changes: 1 addition & 1 deletion exporter/management/commands/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def callback(state, channel, method, properties, input_message):
try:
export.directory.mkdir(parents=True)
except FileExistsError:
for f in export.directory.glob("*"):
for f in export.directory.iterdir():
if f.is_file():
f.unlink()

Expand Down
2 changes: 1 addition & 1 deletion exporter/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def files(self) -> dict:
"""
files = self.default_files()

for path in self.directory.glob("*"):
for path in self.directory.iterdir():
suffix = path.name.split(".", 2)[1] # works for .xlsx .jsonl.gz .csv.tar.gz
if suffix not in files:
continue
Expand Down

0 comments on commit 989d62d

Please sign in to comment.