Hugoifier

fix(logging): configure logging once in cli.py, remove basicConfig from all utility modules Closes #7

lmata 2026-03-12 21:52 trunk
Commit 017d14d737a2a2c18a2d1d0ebeb87075fedcf545510c28cf52b8ded6b402db6b
--- src/utils/analyze.py
+++ src/utils/analyze.py
@@ -6,12 +6,10 @@
66
import os
77
88
from config import call_ai
99
from utils.theme_finder import find_hugo_theme, find_raw_html_files
1010
11
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
12
-
1311
SYSTEM = "You are an expert Hugo theme developer analyzing themes for conversion."
1412
1513
1614
def analyze(path: str) -> str:
1715
logging.info(f"Analyzing {path} ...")
1816
--- 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 @@
33
It uses Cloudflare's API to automate these tasks.
44
"""
55
66
import logging
77
8
-# Configure logging
9
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
10
-
118
# Function to configure and deploy to Cloudflare
129
def configure_cloudflare(path, zone):
1310
logging.info(f"Starting Cloudflare configuration for {path} in zone {zone}...")
1411
try:
1512
# Placeholder logic for Cloudflare configuration
1613
--- 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 @@
1212
1313
from utils.theme_finder import find_hugo_theme, find_raw_html_files
1414
from utils.hugoify import hugoify_html
1515
from utils.decapify import decapify
1616
from utils.theme_patcher import patch_theme, patch_config
17
-
18
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
19
-
2017
2118
def complete(
2219
input_path: str,
2320
output_dir: str = None,
2421
cms_name: str = None,
2522
--- 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
--- src/utils/deploy.py
+++ src/utils/deploy.py
@@ -4,13 +4,10 @@
44
"""
55
66
import logging
77
import os
88
9
-# Configure logging
10
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
11
-
129
# Function to handle deployment tasks
1310
def deploy(path, zone):
1411
logging.info(f"Starting deployment for {path} to zone {zone}...")
1512
try:
1613
# Check prerequisites
1714
--- 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
--- src/utils/hugoify.py
+++ src/utils/hugoify.py
@@ -10,12 +10,10 @@
1010
import json
1111
import re
1212
1313
from config import call_ai
1414
15
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
16
-
1715
SYSTEM = """You are an expert Hugo theme developer. Convert HTML templates to valid Hugo Go template files.
1816
Output only valid Hugo template syntax — no explanations, no markdown fences."""
1917
2018
2119
def hugoify_html(html_path: str) -> dict:
2220
--- 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
--- src/utils/parser.py
+++ src/utils/parser.py
@@ -3,13 +3,10 @@
33
It checks for syntax errors and validates the structure of the content.
44
"""
55
66
import logging
77
8
-# Configure logging
9
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
10
-
118
# Function to perform parsing, linting, and validation
129
def parse(path):
1310
logging.info(f"Starting parsing and linting for {path}...")
1411
try:
1512
# Parse input
1613
--- 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
--- src/utils/theme_patcher.py
+++ src/utils/theme_patcher.py
@@ -2,15 +2,13 @@
22
Patches common Hugo deprecations in theme layout files so they work with Hugo >= v0.128.
33
44
Call patch_theme(theme_dir) after copying theme files to the output directory.
55
"""
66
7
+import logging
78
import os
89
import re
9
-import logging
10
-
11
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
1210
1311
# Map of (pattern, replacement) for deprecated Hugo template variables/functions
1412
TEMPLATE_PATCHES = [
1513
# .Site.DisqusShortname → .Site.Config.Services.Disqus.Shortname
1614
(r'\.Site\.DisqusShortname', '.Site.Config.Services.Disqus.Shortname'),
1715
--- 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 @@
33
"""
44
55
import logging
66
from config import call_ai
77
8
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
9
-
108
119
def translate(path: str, target_language: str = "Spanish") -> str:
1210
logging.info(f"Translating content in {path} ...")
1311
try:
1412
with open(path, 'r', errors='replace') as f:
1513
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button