diff --git a/plugin/main.py b/plugin/main.py index 07d5266..622e17b 100644 --- a/plugin/main.py +++ b/plugin/main.py @@ -8,7 +8,7 @@ from mkdocs.config import config_options from mkdocs.plugins import BasePlugin -import plugin.processor as processor +from plugin import processor from plugin.processor import process_html from plugin.utils import resolve_all_authors diff --git a/plugin/postprocess.py b/plugin/postprocess.py index cd22b6d..722a211 100644 --- a/plugin/postprocess.py +++ b/plugin/postprocess.py @@ -14,7 +14,7 @@ except ImportError: TQDM = None -import plugin.processor as processor +from plugin import processor from plugin.processor import process_html from plugin.utils import resolve_all_authors @@ -304,23 +304,23 @@ def postprocess_site( # Enable logging only for the synchronous path; pools run without per-task log_fn to remain pickle-safe. log_fn = (progress.write if verbose and progress else print if verbose else None) if worker_count == 1 else None - task_kwargs = dict( - site_dir=site_dir, - md_index=md_index, - git_data=git_data, - repo_url=repo_url, - site_url=site_url, - default_image=default_image, - add_desc=add_desc, - add_image=add_image, - add_keywords=add_keywords, - add_share_buttons=add_share_buttons, - add_authors=add_authors, - add_json_ld=add_json_ld, - add_css=add_css, - add_copy_llm=add_copy_llm, - verbose=verbose, - ) + task_kwargs = { + "site_dir": site_dir, + "md_index": md_index, + "git_data": git_data, + "repo_url": repo_url, + "site_url": site_url, + "default_image": default_image, + "add_desc": add_desc, + "add_image": add_image, + "add_keywords": add_keywords, + "add_share_buttons": add_share_buttons, + "add_authors": add_authors, + "add_json_ld": add_json_ld, + "add_css": add_css, + "add_copy_llm": add_copy_llm, + "verbose": verbose, + } if worker_count == 1: for html_file in html_files: diff --git a/plugin/processor.py b/plugin/processor.py index 676a257..5c34d3f 100644 --- a/plugin/processor.py +++ b/plugin/processor.py @@ -6,7 +6,7 @@ import json import re import subprocess -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from pathlib import Path from typing import Any from urllib.parse import quote @@ -15,7 +15,7 @@ from plugin.utils import calculate_time_difference, get_youtube_video_ids -today = datetime.now() +today = datetime.now(timezone.utc) DEFAULT_CREATION_DATE = (today - timedelta(days=365)).strftime("%Y-%m-%d %H:%M:%S +0000") DEFAULT_MODIFIED_DATE = (today - timedelta(days=40)).strftime("%Y-%m-%d %H:%M:%S +0000") diff --git a/plugin/utils.py b/plugin/utils.py index 49a9cfe..4367c12 100644 --- a/plugin/utils.py +++ b/plugin/utils.py @@ -147,20 +147,17 @@ def resolve_github_user( # Query the commit API when git history provides a commit for this email. This resolves authors whose commit email # is linked to a GitHub account but hidden from user search. - if repo_path := _github_repo_path(repo_url): - if commit_sha: - try: - response = requests.get( - f"https://api.github.com/repos/{repo_path}/commits/{commit_sha}", timeout=TIMEOUT - ) - if response.status_code == 200: - data = response.json() - author = data.get("author") or {} - if author.get("login") and author.get("avatar_url"): - cache[email] = {"username": author["login"], "avatar": author["avatar_url"]} - return cache[email] - except Exception: - pass + if (repo_path := _github_repo_path(repo_url)) and commit_sha: + try: + response = requests.get(f"https://api.github.com/repos/{repo_path}/commits/{commit_sha}", timeout=TIMEOUT) + if response.status_code == 200: + data = response.json() + author = data.get("author") or {} + if author.get("login") and author.get("avatar_url"): + cache[email] = {"username": author["login"], "avatar": author["avatar_url"]} + return cache[email] + except Exception: + pass # Query GitHub REST API if verbose: @@ -238,7 +235,7 @@ def resolve_all_authors( # Build authors list for each file entry github_repo_url = repo_url or "https://github.com/ultralytics/ultralytics" - for file_path, entry in git_data.items(): + for entry in git_data.values(): emails = entry.get("emails", {}) if not emails and default_author: emails = {default_author: 1}