From 347731929824b32b4b58239ffd3ee84ae775b9f8 Mon Sep 17 00:00:00 2001 From: blag Date: Tue, 10 Jun 2025 22:44:06 -0600 Subject: [PATCH] Use os.walk instead of Path.walk until we support only Python 3.12+ --- dbtemplates/management/commands/sync_templates.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 047fedb..1cad812 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from dbtemplates.models import Template @@ -89,13 +90,15 @@ class Command(BaseCommand): templatedirs = [Path(d) for d in tpl_dirs if Path(d).is_dir()] for templatedir in templatedirs: - for dirpath, subdirs, filenames in templatedir.walk(follow_symlinks=True): + # TODO: Replace os.walk(templatedir) with templatedir.walk(follow_symlinks=True) + # once we only support Python 3.12+ + for dirpath, subdirs, filenames in os.walk(templatedir): for f in [ f for f in filenames if f.endswith(extension) and not f.startswith(".") ]: - path = dirpath / f + path = Path(dirpath) / f name = path.relative_to(templatedir) try: t = Template.on_site.get(name__exact=name)