Hugoifier
fix(logging): configure logging once in cli.py, remove basicConfig from all utility modules Closes #7
Commit
017d14d737a2a2c18a2d1d0ebeb87075fedcf545510c28cf52b8ded6b402db6b
Parent
d26598ffa0ad3ec…
8 files changed
-2
-3
-3
-3
-2
-3
+1
-3
-2
-2
| --- src/utils/analyze.py | ||
| +++ src/utils/analyze.py | ||
| @@ -6,12 +6,10 @@ | ||
| 6 | 6 | import os |
| 7 | 7 | |
| 8 | 8 | from config import call_ai |
| 9 | 9 | from utils.theme_finder import find_hugo_theme, find_raw_html_files |
| 10 | 10 | |
| 11 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 12 | - | |
| 13 | 11 | SYSTEM = "You are an expert Hugo theme developer analyzing themes for conversion." |
| 14 | 12 | |
| 15 | 13 | |
| 16 | 14 | def analyze(path: str) -> str: |
| 17 | 15 | logging.info(f"Analyzing {path} ...") |
| 18 | 16 |
| --- src/utils/analyze.py | |
| +++ src/utils/analyze.py | |
| @@ -6,12 +6,10 @@ | |
| 6 | import os |
| 7 | |
| 8 | from config import call_ai |
| 9 | from utils.theme_finder import find_hugo_theme, find_raw_html_files |
| 10 | |
| 11 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 12 | |
| 13 | SYSTEM = "You are an expert Hugo theme developer analyzing themes for conversion." |
| 14 | |
| 15 | |
| 16 | def analyze(path: str) -> str: |
| 17 | logging.info(f"Analyzing {path} ...") |
| 18 |
| --- src/utils/analyze.py | |
| +++ src/utils/analyze.py | |
| @@ -6,12 +6,10 @@ | |
| 6 | import os |
| 7 | |
| 8 | from config import call_ai |
| 9 | from utils.theme_finder import find_hugo_theme, find_raw_html_files |
| 10 | |
| 11 | SYSTEM = "You are an expert Hugo theme developer analyzing themes for conversion." |
| 12 | |
| 13 | |
| 14 | def analyze(path: str) -> str: |
| 15 | logging.info(f"Analyzing {path} ...") |
| 16 |
| --- src/utils/cloudflare.py | ||
| +++ src/utils/cloudflare.py | ||
| @@ -3,13 +3,10 @@ | ||
| 3 | 3 | It uses Cloudflare's API to automate these tasks. |
| 4 | 4 | """ |
| 5 | 5 | |
| 6 | 6 | import logging |
| 7 | 7 | |
| 8 | -# Configure logging | |
| 9 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 10 | - | |
| 11 | 8 | # Function to configure and deploy to Cloudflare |
| 12 | 9 | def configure_cloudflare(path, zone): |
| 13 | 10 | logging.info(f"Starting Cloudflare configuration for {path} in zone {zone}...") |
| 14 | 11 | try: |
| 15 | 12 | # Placeholder logic for Cloudflare configuration |
| 16 | 13 |
| --- src/utils/cloudflare.py | |
| +++ src/utils/cloudflare.py | |
| @@ -3,13 +3,10 @@ | |
| 3 | It uses Cloudflare's API to automate these tasks. |
| 4 | """ |
| 5 | |
| 6 | import logging |
| 7 | |
| 8 | # Configure logging |
| 9 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 10 | |
| 11 | # Function to configure and deploy to Cloudflare |
| 12 | def configure_cloudflare(path, zone): |
| 13 | logging.info(f"Starting Cloudflare configuration for {path} in zone {zone}...") |
| 14 | try: |
| 15 | # Placeholder logic for Cloudflare configuration |
| 16 |
| --- src/utils/cloudflare.py | |
| +++ src/utils/cloudflare.py | |
| @@ -3,13 +3,10 @@ | |
| 3 | It uses Cloudflare's API to automate these tasks. |
| 4 | """ |
| 5 | |
| 6 | import logging |
| 7 | |
| 8 | # Function to configure and deploy to Cloudflare |
| 9 | def configure_cloudflare(path, zone): |
| 10 | logging.info(f"Starting Cloudflare configuration for {path} in zone {zone}...") |
| 11 | try: |
| 12 | # Placeholder logic for Cloudflare configuration |
| 13 |
| --- src/utils/complete.py | ||
| +++ src/utils/complete.py | ||
| @@ -12,13 +12,10 @@ | ||
| 12 | 12 | |
| 13 | 13 | from utils.theme_finder import find_hugo_theme, find_raw_html_files |
| 14 | 14 | from utils.hugoify import hugoify_html |
| 15 | 15 | from utils.decapify import decapify |
| 16 | 16 | from utils.theme_patcher import patch_theme, patch_config |
| 17 | - | |
| 18 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 19 | - | |
| 20 | 17 | |
| 21 | 18 | def complete( |
| 22 | 19 | input_path: str, |
| 23 | 20 | output_dir: str = None, |
| 24 | 21 | cms_name: str = None, |
| 25 | 22 |
| --- src/utils/complete.py | |
| +++ src/utils/complete.py | |
| @@ -12,13 +12,10 @@ | |
| 12 | |
| 13 | from utils.theme_finder import find_hugo_theme, find_raw_html_files |
| 14 | from utils.hugoify import hugoify_html |
| 15 | from utils.decapify import decapify |
| 16 | from utils.theme_patcher import patch_theme, patch_config |
| 17 | |
| 18 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 19 | |
| 20 | |
| 21 | def complete( |
| 22 | input_path: str, |
| 23 | output_dir: str = None, |
| 24 | cms_name: str = None, |
| 25 |
| --- src/utils/complete.py | |
| +++ src/utils/complete.py | |
| @@ -12,13 +12,10 @@ | |
| 12 | |
| 13 | from utils.theme_finder import find_hugo_theme, find_raw_html_files |
| 14 | from utils.hugoify import hugoify_html |
| 15 | from utils.decapify import decapify |
| 16 | from utils.theme_patcher import patch_theme, patch_config |
| 17 | |
| 18 | def complete( |
| 19 | input_path: str, |
| 20 | output_dir: str = None, |
| 21 | cms_name: str = None, |
| 22 |
-3
| --- src/utils/deploy.py | ||
| +++ src/utils/deploy.py | ||
| @@ -4,13 +4,10 @@ | ||
| 4 | 4 | """ |
| 5 | 5 | |
| 6 | 6 | import logging |
| 7 | 7 | import os |
| 8 | 8 | |
| 9 | -# Configure logging | |
| 10 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 11 | - | |
| 12 | 9 | # Function to handle deployment tasks |
| 13 | 10 | def deploy(path, zone): |
| 14 | 11 | logging.info(f"Starting deployment for {path} to zone {zone}...") |
| 15 | 12 | try: |
| 16 | 13 | # Check prerequisites |
| 17 | 14 |
| --- src/utils/deploy.py | |
| +++ src/utils/deploy.py | |
| @@ -4,13 +4,10 @@ | |
| 4 | """ |
| 5 | |
| 6 | import logging |
| 7 | import os |
| 8 | |
| 9 | # Configure logging |
| 10 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 11 | |
| 12 | # Function to handle deployment tasks |
| 13 | def deploy(path, zone): |
| 14 | logging.info(f"Starting deployment for {path} to zone {zone}...") |
| 15 | try: |
| 16 | # Check prerequisites |
| 17 |
| --- src/utils/deploy.py | |
| +++ src/utils/deploy.py | |
| @@ -4,13 +4,10 @@ | |
| 4 | """ |
| 5 | |
| 6 | import logging |
| 7 | import os |
| 8 | |
| 9 | # Function to handle deployment tasks |
| 10 | def deploy(path, zone): |
| 11 | logging.info(f"Starting deployment for {path} to zone {zone}...") |
| 12 | try: |
| 13 | # Check prerequisites |
| 14 |
-2
| --- src/utils/hugoify.py | ||
| +++ src/utils/hugoify.py | ||
| @@ -10,12 +10,10 @@ | ||
| 10 | 10 | import json |
| 11 | 11 | import re |
| 12 | 12 | |
| 13 | 13 | from config import call_ai |
| 14 | 14 | |
| 15 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 16 | - | |
| 17 | 15 | SYSTEM = """You are an expert Hugo theme developer. Convert HTML templates to valid Hugo Go template files. |
| 18 | 16 | Output only valid Hugo template syntax — no explanations, no markdown fences.""" |
| 19 | 17 | |
| 20 | 18 | |
| 21 | 19 | def hugoify_html(html_path: str) -> dict: |
| 22 | 20 |
| --- src/utils/hugoify.py | |
| +++ src/utils/hugoify.py | |
| @@ -10,12 +10,10 @@ | |
| 10 | import json |
| 11 | import re |
| 12 | |
| 13 | from config import call_ai |
| 14 | |
| 15 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 16 | |
| 17 | SYSTEM = """You are an expert Hugo theme developer. Convert HTML templates to valid Hugo Go template files. |
| 18 | Output only valid Hugo template syntax — no explanations, no markdown fences.""" |
| 19 | |
| 20 | |
| 21 | def hugoify_html(html_path: str) -> dict: |
| 22 |
| --- src/utils/hugoify.py | |
| +++ src/utils/hugoify.py | |
| @@ -10,12 +10,10 @@ | |
| 10 | import json |
| 11 | import re |
| 12 | |
| 13 | from config import call_ai |
| 14 | |
| 15 | SYSTEM = """You are an expert Hugo theme developer. Convert HTML templates to valid Hugo Go template files. |
| 16 | Output only valid Hugo template syntax — no explanations, no markdown fences.""" |
| 17 | |
| 18 | |
| 19 | def hugoify_html(html_path: str) -> dict: |
| 20 |
-3
| --- src/utils/parser.py | ||
| +++ src/utils/parser.py | ||
| @@ -3,13 +3,10 @@ | ||
| 3 | 3 | It checks for syntax errors and validates the structure of the content. |
| 4 | 4 | """ |
| 5 | 5 | |
| 6 | 6 | import logging |
| 7 | 7 | |
| 8 | -# Configure logging | |
| 9 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 10 | - | |
| 11 | 8 | # Function to perform parsing, linting, and validation |
| 12 | 9 | def parse(path): |
| 13 | 10 | logging.info(f"Starting parsing and linting for {path}...") |
| 14 | 11 | try: |
| 15 | 12 | # Parse input |
| 16 | 13 |
| --- src/utils/parser.py | |
| +++ src/utils/parser.py | |
| @@ -3,13 +3,10 @@ | |
| 3 | It checks for syntax errors and validates the structure of the content. |
| 4 | """ |
| 5 | |
| 6 | import logging |
| 7 | |
| 8 | # Configure logging |
| 9 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 10 | |
| 11 | # Function to perform parsing, linting, and validation |
| 12 | def parse(path): |
| 13 | logging.info(f"Starting parsing and linting for {path}...") |
| 14 | try: |
| 15 | # Parse input |
| 16 |
| --- src/utils/parser.py | |
| +++ src/utils/parser.py | |
| @@ -3,13 +3,10 @@ | |
| 3 | It checks for syntax errors and validates the structure of the content. |
| 4 | """ |
| 5 | |
| 6 | import logging |
| 7 | |
| 8 | # Function to perform parsing, linting, and validation |
| 9 | def parse(path): |
| 10 | logging.info(f"Starting parsing and linting for {path}...") |
| 11 | try: |
| 12 | # Parse input |
| 13 |
+1
-3
| --- src/utils/theme_patcher.py | ||
| +++ src/utils/theme_patcher.py | ||
| @@ -2,15 +2,13 @@ | ||
| 2 | 2 | Patches common Hugo deprecations in theme layout files so they work with Hugo >= v0.128. |
| 3 | 3 | |
| 4 | 4 | Call patch_theme(theme_dir) after copying theme files to the output directory. |
| 5 | 5 | """ |
| 6 | 6 | |
| 7 | +import logging | |
| 7 | 8 | import os |
| 8 | 9 | import re |
| 9 | -import logging | |
| 10 | - | |
| 11 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 12 | 10 | |
| 13 | 11 | # Map of (pattern, replacement) for deprecated Hugo template variables/functions |
| 14 | 12 | TEMPLATE_PATCHES = [ |
| 15 | 13 | # .Site.DisqusShortname → .Site.Config.Services.Disqus.Shortname |
| 16 | 14 | (r'\.Site\.DisqusShortname', '.Site.Config.Services.Disqus.Shortname'), |
| 17 | 15 |
| --- src/utils/theme_patcher.py | |
| +++ src/utils/theme_patcher.py | |
| @@ -2,15 +2,13 @@ | |
| 2 | Patches common Hugo deprecations in theme layout files so they work with Hugo >= v0.128. |
| 3 | |
| 4 | Call patch_theme(theme_dir) after copying theme files to the output directory. |
| 5 | """ |
| 6 | |
| 7 | import os |
| 8 | import re |
| 9 | import logging |
| 10 | |
| 11 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 12 | |
| 13 | # Map of (pattern, replacement) for deprecated Hugo template variables/functions |
| 14 | TEMPLATE_PATCHES = [ |
| 15 | # .Site.DisqusShortname → .Site.Config.Services.Disqus.Shortname |
| 16 | (r'\.Site\.DisqusShortname', '.Site.Config.Services.Disqus.Shortname'), |
| 17 |
| --- src/utils/theme_patcher.py | |
| +++ src/utils/theme_patcher.py | |
| @@ -2,15 +2,13 @@ | |
| 2 | Patches common Hugo deprecations in theme layout files so they work with Hugo >= v0.128. |
| 3 | |
| 4 | Call patch_theme(theme_dir) after copying theme files to the output directory. |
| 5 | """ |
| 6 | |
| 7 | import logging |
| 8 | import os |
| 9 | import re |
| 10 | |
| 11 | # Map of (pattern, replacement) for deprecated Hugo template variables/functions |
| 12 | TEMPLATE_PATCHES = [ |
| 13 | # .Site.DisqusShortname → .Site.Config.Services.Disqus.Shortname |
| 14 | (r'\.Site\.DisqusShortname', '.Site.Config.Services.Disqus.Shortname'), |
| 15 |
| --- src/utils/translate.py | ||
| +++ src/utils/translate.py | ||
| @@ -3,12 +3,10 @@ | ||
| 3 | 3 | """ |
| 4 | 4 | |
| 5 | 5 | import logging |
| 6 | 6 | from config import call_ai |
| 7 | 7 | |
| 8 | -logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | |
| 9 | - | |
| 10 | 8 | |
| 11 | 9 | def translate(path: str, target_language: str = "Spanish") -> str: |
| 12 | 10 | logging.info(f"Translating content in {path} ...") |
| 13 | 11 | try: |
| 14 | 12 | with open(path, 'r', errors='replace') as f: |
| 15 | 13 |
| --- src/utils/translate.py | |
| +++ src/utils/translate.py | |
| @@ -3,12 +3,10 @@ | |
| 3 | """ |
| 4 | |
| 5 | import logging |
| 6 | from config import call_ai |
| 7 | |
| 8 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
| 9 | |
| 10 | |
| 11 | def translate(path: str, target_language: str = "Spanish") -> str: |
| 12 | logging.info(f"Translating content in {path} ...") |
| 13 | try: |
| 14 | with open(path, 'r', errors='replace') as f: |
| 15 |
| --- src/utils/translate.py | |
| +++ src/utils/translate.py | |
| @@ -3,12 +3,10 @@ | |
| 3 | """ |
| 4 | |
| 5 | import logging |
| 6 | from config import call_ai |
| 7 | |
| 8 | |
| 9 | def translate(path: str, target_language: str = "Spanish") -> str: |
| 10 | logging.info(f"Translating content in {path} ...") |
| 11 | try: |
| 12 | with open(path, 'r', errors='replace') as f: |
| 13 |