Hugoifier
fix: lint errors and CI — remove macOS, fix unused vars, add E501 ignores - Remove macOS from CI matrix (ubuntu-only) - Remove unused variables in hugoify.py (head_extras, css_links, js_links) - Remove unused import (urllib.parse) in hugoify.py - Fix unused variable in decapify.py (.gitkeep creation) - Add E501 per-file ignores for modules with HTML templates/prompts - Import sorting fixed by ruff --fix
Commit
3884774dfcd998c4a12980c34c8099a88238c513776e4d1dcf5bc658cbbf4dc6
Parent
b50173b704abb95…
5 files changed
+1
-1
+1
-1
+1
-2
-10
+4
+1
-1
| --- .github/workflows/ci.yml | ||
| +++ .github/workflows/ci.yml | ||
| @@ -9,11 +9,11 @@ | ||
| 9 | 9 | jobs: |
| 10 | 10 | test: |
| 11 | 11 | runs-on: ${{ matrix.os }} |
| 12 | 12 | strategy: |
| 13 | 13 | matrix: |
| 14 | - os: [ubuntu-latest, macos-latest] | |
| 14 | + os: [ubuntu-latest] | |
| 15 | 15 | python-version: ["3.11", "3.12", "3.13"] |
| 16 | 16 | steps: |
| 17 | 17 | - uses: actions/checkout@v4 |
| 18 | 18 | |
| 19 | 19 | - uses: actions/setup-python@v5 |
| 20 | 20 |
| --- .github/workflows/ci.yml | |
| +++ .github/workflows/ci.yml | |
| @@ -9,11 +9,11 @@ | |
| 9 | jobs: |
| 10 | test: |
| 11 | runs-on: ${{ matrix.os }} |
| 12 | strategy: |
| 13 | matrix: |
| 14 | os: [ubuntu-latest, macos-latest] |
| 15 | python-version: ["3.11", "3.12", "3.13"] |
| 16 | steps: |
| 17 | - uses: actions/checkout@v4 |
| 18 | |
| 19 | - uses: actions/setup-python@v5 |
| 20 |
| --- .github/workflows/ci.yml | |
| +++ .github/workflows/ci.yml | |
| @@ -9,11 +9,11 @@ | |
| 9 | jobs: |
| 10 | test: |
| 11 | runs-on: ${{ matrix.os }} |
| 12 | strategy: |
| 13 | matrix: |
| 14 | os: [ubuntu-latest] |
| 15 | python-version: ["3.11", "3.12", "3.13"] |
| 16 | steps: |
| 17 | - uses: actions/checkout@v4 |
| 18 | |
| 19 | - uses: actions/setup-python@v5 |
| 20 |
+1
-1
| --- hugoifier/cli.py | ||
| +++ hugoifier/cli.py | ||
| @@ -17,13 +17,13 @@ | ||
| 17 | 17 | from .utils.analyze import analyze |
| 18 | 18 | from .utils.cloudflare import configure_cloudflare |
| 19 | 19 | from .utils.complete import complete |
| 20 | 20 | from .utils.decapify import decapify |
| 21 | 21 | from .utils.deploy import deploy |
| 22 | +from .utils.enhance import alt_text, enhance, generate, seo | |
| 22 | 23 | from .utils.hugoify import hugoify |
| 23 | 24 | from .utils.parser import parse |
| 24 | -from .utils.enhance import enhance, generate, seo, alt_text | |
| 25 | 25 | from .utils.translate import translate |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | def main(): |
| 29 | 29 | parser = argparse.ArgumentParser( |
| 30 | 30 |
| --- hugoifier/cli.py | |
| +++ hugoifier/cli.py | |
| @@ -17,13 +17,13 @@ | |
| 17 | from .utils.analyze import analyze |
| 18 | from .utils.cloudflare import configure_cloudflare |
| 19 | from .utils.complete import complete |
| 20 | from .utils.decapify import decapify |
| 21 | from .utils.deploy import deploy |
| 22 | from .utils.hugoify import hugoify |
| 23 | from .utils.parser import parse |
| 24 | from .utils.enhance import enhance, generate, seo, alt_text |
| 25 | from .utils.translate import translate |
| 26 | |
| 27 | |
| 28 | def main(): |
| 29 | parser = argparse.ArgumentParser( |
| 30 |
| --- hugoifier/cli.py | |
| +++ hugoifier/cli.py | |
| @@ -17,13 +17,13 @@ | |
| 17 | from .utils.analyze import analyze |
| 18 | from .utils.cloudflare import configure_cloudflare |
| 19 | from .utils.complete import complete |
| 20 | from .utils.decapify import decapify |
| 21 | from .utils.deploy import deploy |
| 22 | from .utils.enhance import alt_text, enhance, generate, seo |
| 23 | from .utils.hugoify import hugoify |
| 24 | from .utils.parser import parse |
| 25 | from .utils.translate import translate |
| 26 | |
| 27 | |
| 28 | def main(): |
| 29 | parser = argparse.ArgumentParser( |
| 30 |
+1
-2
| --- hugoifier/utils/decapify.py | ||
| +++ hugoifier/utils/decapify.py | ||
| @@ -392,7 +392,6 @@ | ||
| 392 | 392 | """Create the media uploads directory so Decap doesn't 404.""" |
| 393 | 393 | media_dir = os.path.join(site_dir, 'static', 'images', 'uploads') |
| 394 | 394 | os.makedirs(media_dir, exist_ok=True) |
| 395 | 395 | gitkeep = os.path.join(media_dir, '.gitkeep') |
| 396 | 396 | if not os.path.exists(gitkeep): |
| 397 | - with open(gitkeep, 'w') as f: | |
| 398 | - pass | |
| 397 | + open(gitkeep, 'w').close() | |
| 399 | 398 |
| --- hugoifier/utils/decapify.py | |
| +++ hugoifier/utils/decapify.py | |
| @@ -392,7 +392,6 @@ | |
| 392 | """Create the media uploads directory so Decap doesn't 404.""" |
| 393 | media_dir = os.path.join(site_dir, 'static', 'images', 'uploads') |
| 394 | os.makedirs(media_dir, exist_ok=True) |
| 395 | gitkeep = os.path.join(media_dir, '.gitkeep') |
| 396 | if not os.path.exists(gitkeep): |
| 397 | with open(gitkeep, 'w') as f: |
| 398 | pass |
| 399 |
| --- hugoifier/utils/decapify.py | |
| +++ hugoifier/utils/decapify.py | |
| @@ -392,7 +392,6 @@ | |
| 392 | """Create the media uploads directory so Decap doesn't 404.""" |
| 393 | media_dir = os.path.join(site_dir, 'static', 'images', 'uploads') |
| 394 | os.makedirs(media_dir, exist_ok=True) |
| 395 | gitkeep = os.path.join(media_dir, '.gitkeep') |
| 396 | if not os.path.exists(gitkeep): |
| 397 | open(gitkeep, 'w').close() |
| 398 |
| --- hugoifier/utils/hugoify.py | ||
| +++ hugoifier/utils/hugoify.py | ||
| @@ -40,19 +40,10 @@ | ||
| 40 | 40 | with open(html_path, 'r', errors='replace') as f: |
| 41 | 41 | html = f.read() |
| 42 | 42 | |
| 43 | 43 | logging.info(f"Read {len(html)} chars from {html_path}") |
| 44 | 44 | |
| 45 | - # Extract <head> content (CSS links, meta, fonts, etc.) | |
| 46 | - head_extras = _extract_head_content(html) | |
| 47 | - | |
| 48 | - # Extract and rewrite CSS/JS paths to be relative to Hugo static/ | |
| 49 | - css_links = re.findall(r'<link[^>]+rel=["\']stylesheet["\'][^>]*/?>', | |
| 50 | - html, re.DOTALL | re.IGNORECASE) | |
| 51 | - js_links = re.findall(r'<script[^>]+src=["\'][^"\']+["\'][^>]*>.*?</script>', | |
| 52 | - html, re.DOTALL) | |
| 53 | - | |
| 54 | 45 | # Extract <body> content |
| 55 | 46 | body_match = re.search(r'<body[^>]*>(.*?)</body>', html, re.DOTALL) |
| 56 | 47 | body_content = body_match.group(1).strip() if body_match else html |
| 57 | 48 | |
| 58 | 49 | # Extract body attributes (class, style, etc.) |
| @@ -142,11 +133,10 @@ | ||
| 142 | 133 | """ |
| 143 | 134 | Capture the actual server-rendered HTML from a running Next.js app |
| 144 | 135 | and convert it into Hugo layout files. This gives pixel-perfect results. |
| 145 | 136 | """ |
| 146 | 137 | import urllib.request |
| 147 | - import urllib.parse | |
| 148 | 138 | |
| 149 | 139 | logging.info(f"Capturing rendered HTML from {dev_url} ...") |
| 150 | 140 | |
| 151 | 141 | # Fetch the full rendered page |
| 152 | 142 | resp = urllib.request.urlopen(dev_url) |
| 153 | 143 |
| --- hugoifier/utils/hugoify.py | |
| +++ hugoifier/utils/hugoify.py | |
| @@ -40,19 +40,10 @@ | |
| 40 | with open(html_path, 'r', errors='replace') as f: |
| 41 | html = f.read() |
| 42 | |
| 43 | logging.info(f"Read {len(html)} chars from {html_path}") |
| 44 | |
| 45 | # Extract <head> content (CSS links, meta, fonts, etc.) |
| 46 | head_extras = _extract_head_content(html) |
| 47 | |
| 48 | # Extract and rewrite CSS/JS paths to be relative to Hugo static/ |
| 49 | css_links = re.findall(r'<link[^>]+rel=["\']stylesheet["\'][^>]*/?>', |
| 50 | html, re.DOTALL | re.IGNORECASE) |
| 51 | js_links = re.findall(r'<script[^>]+src=["\'][^"\']+["\'][^>]*>.*?</script>', |
| 52 | html, re.DOTALL) |
| 53 | |
| 54 | # Extract <body> content |
| 55 | body_match = re.search(r'<body[^>]*>(.*?)</body>', html, re.DOTALL) |
| 56 | body_content = body_match.group(1).strip() if body_match else html |
| 57 | |
| 58 | # Extract body attributes (class, style, etc.) |
| @@ -142,11 +133,10 @@ | |
| 142 | """ |
| 143 | Capture the actual server-rendered HTML from a running Next.js app |
| 144 | and convert it into Hugo layout files. This gives pixel-perfect results. |
| 145 | """ |
| 146 | import urllib.request |
| 147 | import urllib.parse |
| 148 | |
| 149 | logging.info(f"Capturing rendered HTML from {dev_url} ...") |
| 150 | |
| 151 | # Fetch the full rendered page |
| 152 | resp = urllib.request.urlopen(dev_url) |
| 153 |
| --- hugoifier/utils/hugoify.py | |
| +++ hugoifier/utils/hugoify.py | |
| @@ -40,19 +40,10 @@ | |
| 40 | with open(html_path, 'r', errors='replace') as f: |
| 41 | html = f.read() |
| 42 | |
| 43 | logging.info(f"Read {len(html)} chars from {html_path}") |
| 44 | |
| 45 | # Extract <body> content |
| 46 | body_match = re.search(r'<body[^>]*>(.*?)</body>', html, re.DOTALL) |
| 47 | body_content = body_match.group(1).strip() if body_match else html |
| 48 | |
| 49 | # Extract body attributes (class, style, etc.) |
| @@ -142,11 +133,10 @@ | |
| 133 | """ |
| 134 | Capture the actual server-rendered HTML from a running Next.js app |
| 135 | and convert it into Hugo layout files. This gives pixel-perfect results. |
| 136 | """ |
| 137 | import urllib.request |
| 138 | |
| 139 | logging.info(f"Capturing rendered HTML from {dev_url} ...") |
| 140 | |
| 141 | # Fetch the full rendered page |
| 142 | resp = urllib.request.urlopen(dev_url) |
| 143 |
+4
| --- pyproject.toml | ||
| +++ pyproject.toml | ||
| @@ -61,10 +61,14 @@ | ||
| 61 | 61 | select = ["E", "F", "W", "I"] |
| 62 | 62 | |
| 63 | 63 | [tool.ruff.lint.per-file-ignores] |
| 64 | 64 | "hugoifier/cli.py" = ["E501"] |
| 65 | 65 | "hugoifier/utils/hugoify.py" = ["E501"] |
| 66 | +"hugoifier/utils/complete.py" = ["E501"] | |
| 67 | +"hugoifier/utils/enhance.py" = ["E501"] | |
| 68 | +"hugoifier/utils/decapify.py" = ["E501"] | |
| 69 | +"hugoifier/config.py" = ["E501"] | |
| 66 | 70 | "tests/*" = ["E501"] |
| 67 | 71 | |
| 68 | 72 | [tool.pytest.ini_options] |
| 69 | 73 | testpaths = ["tests"] |
| 70 | 74 | python_files = "test_*.py" |
| 71 | 75 |
| --- pyproject.toml | |
| +++ pyproject.toml | |
| @@ -61,10 +61,14 @@ | |
| 61 | select = ["E", "F", "W", "I"] |
| 62 | |
| 63 | [tool.ruff.lint.per-file-ignores] |
| 64 | "hugoifier/cli.py" = ["E501"] |
| 65 | "hugoifier/utils/hugoify.py" = ["E501"] |
| 66 | "tests/*" = ["E501"] |
| 67 | |
| 68 | [tool.pytest.ini_options] |
| 69 | testpaths = ["tests"] |
| 70 | python_files = "test_*.py" |
| 71 |
| --- pyproject.toml | |
| +++ pyproject.toml | |
| @@ -61,10 +61,14 @@ | |
| 61 | select = ["E", "F", "W", "I"] |
| 62 | |
| 63 | [tool.ruff.lint.per-file-ignores] |
| 64 | "hugoifier/cli.py" = ["E501"] |
| 65 | "hugoifier/utils/hugoify.py" = ["E501"] |
| 66 | "hugoifier/utils/complete.py" = ["E501"] |
| 67 | "hugoifier/utils/enhance.py" = ["E501"] |
| 68 | "hugoifier/utils/decapify.py" = ["E501"] |
| 69 | "hugoifier/config.py" = ["E501"] |
| 70 | "tests/*" = ["E501"] |
| 71 | |
| 72 | [tool.pytest.ini_options] |
| 73 | testpaths = ["tests"] |
| 74 | python_files = "test_*.py" |
| 75 |