Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: c59bba8fb259db0fec2bbb77ad8ba51ea7341b56 # frozen: v0.15.20
rev: 38bfb07c0c64c304f47eb52090f8288150c77730 # frozen: v0.17.1
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -20,7 +20,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 1a4bb160cab6417b3045e1b37b6b72449243e658 # frozen: 0.37.4
rev: 4f85d46a92dc17713078e5de73f8a13190edf6fc # frozen: 0.38.2
hooks:
- id: check-github-workflows

Expand All @@ -35,7 +35,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/mirrors-mypy
rev: d2823d321df3af8f878f7ee3414dc94d037145b9 # frozen: v2.1.0
rev: 2834ec6639549dd6796205c8f011dedcd587288b # frozen: v2.4.0
hooks:
- id: mypy
additional_dependencies: [types-docutils, types-polib>=1.2.0.20250114, types-requests]
Expand All @@ -47,13 +47,13 @@ repos:
args: [".", "--per-rule-ignores", "DEP002=python-docs-theme", "--package-module-name-map", "gitpython=git,sphinx-lint=sphinxlint"]

- repo: https://github.com/djlint/djLint
rev: 9112cb64851c95a7802358af285d21ad8b7f6437 # frozen: v1.36.4
rev: 1399b56bfc493191c39ff1a525a8ab9c11201cd3 # frozen: v1.46.6
hooks:
- id: djlint-reformat-jinja
- id: djlint-jinja

- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: e3eebf65325ccc992422292cb7a4baee967cf815 # frozen: v1.26.1
rev: fa412071e4f5d44d44f9e365f4676f9df92456a2 # frozen: v1.30.1
hooks:
- id: zizmor

Expand Down
15 changes: 8 additions & 7 deletions generate.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
from __future__ import annotations

import json
import concurrent.futures
import itertools
import json
import logging
import subprocess
from collections.abc import Iterator
from dataclasses import dataclass, asdict
from datetime import datetime, timezone
from dataclasses import asdict, dataclass
from datetime import UTC, datetime
from pathlib import Path

from git import Repo
from jinja2 import Environment, FileSystemLoader
from urllib3 import PoolManager

import translated_names
import contribute
import translated_names
from completion import branches_from_peps, get_completion, release_cycle_from_peps
from repositories import Language, get_languages_and_repos

generation_time = datetime.now(timezone.utc)
logger = logging.getLogger('pydocs-translation-dashboard')
generation_time = datetime.now(UTC)


def get_completion_progress() -> Iterator[LanguageProjectData]:
Expand Down Expand Up @@ -111,7 +112,7 @@ def completion_score(self) -> float:

if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
logging.info(f'starting at {generation_time}')
logger.info('starting at %s', generation_time)
Path('build').mkdir(parents=True, exist_ok=True)

completion_progress = list(get_completion_progress())
Expand All @@ -123,7 +124,7 @@ def completion_score(self) -> float:
python_version=python_version,
release_cycle_status=release_cycle_from_peps()[python_version]['status'],
generation_time=generation_time,
duration=(datetime.now(timezone.utc) - generation_time).seconds,
duration=(datetime.now(UTC) - generation_time).seconds,
)

Path('build/style.css').write_bytes(Path('src/style.css').read_bytes())
Expand Down
9 changes: 5 additions & 4 deletions generate_build_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import itertools
import logging
from collections.abc import Iterator, Sequence
from datetime import datetime, timezone
from datetime import UTC, datetime
from json import loads
from pathlib import Path
from sys import argv
Expand All @@ -17,7 +17,8 @@
from generate import LanguageProjectData
from repositories import Language

generation_time = datetime.now(timezone.utc)
logger = logging.getLogger('pydocs-translation-dashboard')
generation_time = datetime.now(UTC)


def get_projects_build_details(
Expand Down Expand Up @@ -54,7 +55,7 @@ def get_language_repo_and_completion(

if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
logging.info(f'starting at {generation_time}')
logger.info('starting at %s', generation_time)
env = Environment(loader=FileSystemLoader('templates'))
if (index_path := Path('build/index.json')).exists():
index_json = loads(Path('build/index.json').read_text())
Expand All @@ -70,7 +71,7 @@ def get_language_repo_and_completion(
completion_progress, get_projects_build_details(completion_progress)
),
generation_time=generation_time,
duration=(datetime.now(timezone.utc) - generation_time).seconds,
duration=(datetime.now(UTC) - generation_time).seconds,
)

Path('build/build-details.html').write_text(output)
2 changes: 1 addition & 1 deletion repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path

from docutils import core
from docutils.nodes import table, row
from docutils.nodes import row, table


def get_languages_and_repos(
Expand Down
4 changes: 1 addition & 3 deletions sphinx_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
def store_and_count_failures(clones_dir: str, repo: str, language_code: str) -> int:
failed_checks = list(chain.from_iterable(yield_failures(clones_dir, repo)))
prefix = f'{Path(clones_dir, "rebased_translations", repo)}/'
log = '\n'.join(
map(lambda check: check.removeprefix(prefix), map(str, failed_checks))
)
log = '\n'.join(check.removeprefix(prefix) for check in map(str, failed_checks))
filepath = Path(f'build/warnings-lint-{language_code}.txt')
filepath.write_text(log)
return len(failed_checks)
Expand Down
8 changes: 8 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ ul.links-row li:not(:first-child)::before {
height: 20px;
}

.progress-bar.main-bar {
background: linear-gradient(
to left,
#94cf96 var(--progress-change, 0%),
#4caf50 var(--progress-change, 0%)
);
}

.outer-label {
display: none;
padding-left: .5em;
Expand Down
7 changes: 4 additions & 3 deletions templates/progress_bar.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
- change: numeric change value (same units as width) or falsy
#}
<div class="progress {{ extra_container_class }}">
{% set relative_change_percent = change * 100 / width if change and width else 0 %}
{# djlint:off H021 #}
<div class="progress-bar main-bar"
style="width: {{ width }}%;
{%- if change and width -%} {# compute the relative change percentage safely #} {%- set rel = (change * 100 / width) -%} background: linear-gradient(to left, #94cf96 {{ rel }}%, #4caf50 {{ rel }}%);
{%- else -%} background-color: #4caf50;
{%- endif -%}">
--progress-change: {{ relative_change_percent }}%">
{# djlint:on #}
{{ kind }}: {{ '{:.2f}%'.format(width) }}
{% if change >= 0.01 %}
({{ '{:+.2f}%'.format(change) }})
Expand Down
4 changes: 2 additions & 2 deletions tests/support.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import contextlib
import sys

# -------------------------------- Imports ----------------------------------- #

Expand All @@ -11,7 +11,7 @@ def import_scripts(dir='..'):
yield cm


class DirsOnSysPath(object):
class DirsOnSysPath:
def __init__(self, *paths):
self.original_value = sys.path[:]
self.original_object = sys.path
Expand Down
5 changes: 3 additions & 2 deletions tests/test_contribute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import urllib3

import support
import urllib3

with support.import_scripts():
import contribute
Expand Down Expand Up @@ -42,7 +43,7 @@ def test_links_are_valid(self):
if isinstance(e.reason, urllib3.exceptions.ReadTimeoutError):
self.skipTest(f'{link}: read timeout, skipping slow server')
self.fail(f'{link}: {e}')
except Exception as e:
except urllib3.exceptions.HTTPError as e:
self.fail(f'{link}: {e}')


Expand Down
2 changes: 1 addition & 1 deletion tests/test_index.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest
from dataclasses import replace
from datetime import datetime
import support

import support
from jinja2 import Environment, FileSystemLoader

with support.import_scripts():
Expand Down
10 changes: 5 additions & 5 deletions tests/test_repositories.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest
import support
import tempfile
import shutil

import tempfile
import unittest
from pathlib import Path

import support
from git import Repo

with support.import_scripts():
Expand Down Expand Up @@ -31,7 +31,7 @@ def test_get_languages_and_repos(self):
result = list(repositories.get_languages_and_repos(self.test_repo_path))

for entry in result:
info, repo = entry
info, _repo = entry
self.assertIsInstance(info, Language)

self.assertIn(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_translated_names.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import support

import support
from urllib3 import PoolManager

with support.import_scripts():
Expand Down
Loading