Hugoifier
fix(theme_finder): warn when multiple Hugo theme candidates are found Closes #6
Commit
d26598ffa0ad3ec7c1b5a5b273264fa79b3e087032ceecf498f1ac0fb9495ddf
Parent
71088c1abd45737…
1 file changed
+6
| --- src/utils/theme_finder.py | ||
| +++ src/utils/theme_finder.py | ||
| @@ -1,10 +1,11 @@ | ||
| 1 | 1 | """ |
| 2 | 2 | Locates the actual Hugo theme and exampleSite within the messy zip-extracted structure. |
| 3 | 3 | Themes in themes/ are structured as: {name}/{name}/themes/{theme-name}/ |
| 4 | 4 | """ |
| 5 | 5 | |
| 6 | +import logging | |
| 6 | 7 | import os |
| 7 | 8 | import glob as glob_module |
| 8 | 9 | |
| 9 | 10 | |
| 10 | 11 | def find_hugo_theme(input_path): |
| @@ -32,10 +33,15 @@ | ||
| 32 | 33 | if not candidates: |
| 33 | 34 | return None |
| 34 | 35 | |
| 35 | 36 | # Pick the deepest match (most likely the actual theme dir) |
| 36 | 37 | theme_dir = max(candidates, key=lambda p: p.count(os.sep)) |
| 38 | + if len(candidates) > 1: | |
| 39 | + logging.warning( | |
| 40 | + f"Multiple Hugo theme candidates found; using {theme_dir!r}. " | |
| 41 | + f"Others: {[c for c in candidates if c != theme_dir]}" | |
| 42 | + ) | |
| 37 | 43 | |
| 38 | 44 | # Detect exampleSite |
| 39 | 45 | example_site = None |
| 40 | 46 | for candidate in [ |
| 41 | 47 | os.path.join(theme_dir, 'exampleSite'), |
| 42 | 48 |
| --- src/utils/theme_finder.py | |
| +++ src/utils/theme_finder.py | |
| @@ -1,10 +1,11 @@ | |
| 1 | """ |
| 2 | Locates the actual Hugo theme and exampleSite within the messy zip-extracted structure. |
| 3 | Themes in themes/ are structured as: {name}/{name}/themes/{theme-name}/ |
| 4 | """ |
| 5 | |
| 6 | import os |
| 7 | import glob as glob_module |
| 8 | |
| 9 | |
| 10 | def find_hugo_theme(input_path): |
| @@ -32,10 +33,15 @@ | |
| 32 | if not candidates: |
| 33 | return None |
| 34 | |
| 35 | # Pick the deepest match (most likely the actual theme dir) |
| 36 | theme_dir = max(candidates, key=lambda p: p.count(os.sep)) |
| 37 | |
| 38 | # Detect exampleSite |
| 39 | example_site = None |
| 40 | for candidate in [ |
| 41 | os.path.join(theme_dir, 'exampleSite'), |
| 42 |
| --- src/utils/theme_finder.py | |
| +++ src/utils/theme_finder.py | |
| @@ -1,10 +1,11 @@ | |
| 1 | """ |
| 2 | Locates the actual Hugo theme and exampleSite within the messy zip-extracted structure. |
| 3 | Themes in themes/ are structured as: {name}/{name}/themes/{theme-name}/ |
| 4 | """ |
| 5 | |
| 6 | import logging |
| 7 | import os |
| 8 | import glob as glob_module |
| 9 | |
| 10 | |
| 11 | def find_hugo_theme(input_path): |
| @@ -32,10 +33,15 @@ | |
| 33 | if not candidates: |
| 34 | return None |
| 35 | |
| 36 | # Pick the deepest match (most likely the actual theme dir) |
| 37 | theme_dir = max(candidates, key=lambda p: p.count(os.sep)) |
| 38 | if len(candidates) > 1: |
| 39 | logging.warning( |
| 40 | f"Multiple Hugo theme candidates found; using {theme_dir!r}. " |
| 41 | f"Others: {[c for c in candidates if c != theme_dir]}" |
| 42 | ) |
| 43 | |
| 44 | # Detect exampleSite |
| 45 | example_site = None |
| 46 | for candidate in [ |
| 47 | os.path.join(theme_dir, 'exampleSite'), |
| 48 |