mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-06 07:47:53 +10:00
bump package versions
This commit is contained in:
@@ -79,8 +79,8 @@ def hint(text: Union[Tuple[str, ...], List[str], str], prefix=' ', config: Op
|
||||
ansi = DEFAULT_CLI_COLORS if (config or {}).get('USE_COLOR') else ANSI
|
||||
|
||||
if isinstance(text, str):
|
||||
stderr('{}{lightred}Hint:{reset} {}'.format(prefix, text, **ansi))
|
||||
stderr(f"{prefix}{ansi['lightred']}Hint:{ansi['reset']} {text}")
|
||||
else:
|
||||
stderr('{}{lightred}Hint:{reset} {}'.format(prefix, text[0], **ansi))
|
||||
stderr(f"{prefix}{ansi['lightred']}Hint:{ansi['reset']} {text[0]}")
|
||||
for line in text[1:]:
|
||||
stderr('{} {}'.format(prefix, line))
|
||||
stderr(f'{prefix} {line}')
|
||||
|
||||
@@ -5,6 +5,8 @@ import os
|
||||
import stat
|
||||
import posixpath
|
||||
import mimetypes
|
||||
import importlib
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from django.contrib.staticfiles import finders
|
||||
@@ -69,9 +71,9 @@ mimetypes.add_type("application/xml", ".xml")
|
||||
mimetypes.add_type("image/svg+xml", ".svg")
|
||||
|
||||
try:
|
||||
import markdown as _markdown
|
||||
except Exception:
|
||||
_markdown = None
|
||||
_markdown = getattr(importlib.import_module('markdown'), 'markdown')
|
||||
except ImportError:
|
||||
_markdown: Callable[..., str] | None = None
|
||||
|
||||
MARKDOWN_INLINE_LINK_RE = re.compile(r'\[([^\]]+)\]\(([^)\s]+(?:\([^)]*\)[^)\s]*)*)\)')
|
||||
MARKDOWN_INLINE_IMAGE_RE = re.compile(r'!\[([^\]]*)\]\(([^)]+)\)')
|
||||
@@ -108,7 +110,7 @@ def _looks_like_markdown(text: str) -> bool:
|
||||
def _render_markdown_fallback(text: str) -> str:
|
||||
if _markdown is not None and not HTML_TAG_RE.search(text):
|
||||
try:
|
||||
return _markdown.markdown(
|
||||
return _markdown(
|
||||
text,
|
||||
extensions=["extra", "toc", "sane_lists"],
|
||||
output_format="html",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, List, Callable
|
||||
from typing import Any, List, Callable, cast
|
||||
|
||||
import json
|
||||
import ast
|
||||
@@ -94,7 +94,8 @@ class JSONSchemaWithLambdas(GenerateJsonSchema):
|
||||
|
||||
def better_toml_dump_str(val: Any) -> str:
|
||||
try:
|
||||
return toml.encoder._dump_str(val) # type: ignore
|
||||
dump_str = cast(Callable[[Any], str], getattr(toml.encoder, '_dump_str'))
|
||||
return dump_str(val)
|
||||
except Exception:
|
||||
# if we hit any of toml's numerous encoding bugs,
|
||||
# fall back to using json representation of string
|
||||
@@ -108,7 +109,8 @@ class CustomTOMLEncoder(toml.encoder.TomlEncoder):
|
||||
"""
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.dump_funcs[Path] = lambda x: json.dumps(str(x))
|
||||
self.dump_funcs[PosixPath] = lambda x: json.dumps(str(x))
|
||||
self.dump_funcs[str] = better_toml_dump_str
|
||||
self.dump_funcs[re.RegexFlag] = better_toml_dump_str
|
||||
dump_funcs = cast(dict[Any, Callable[[Any], str]], self.dump_funcs)
|
||||
dump_funcs[Path] = lambda x: json.dumps(str(x))
|
||||
dump_funcs[PosixPath] = lambda x: json.dumps(str(x))
|
||||
dump_funcs[str] = better_toml_dump_str
|
||||
dump_funcs[re.RegexFlag] = better_toml_dump_str
|
||||
|
||||
@@ -16,7 +16,7 @@ from datetime import datetime, timezone
|
||||
from dateparser import parse as dateparser
|
||||
from requests.exceptions import RequestException, ReadTimeout
|
||||
|
||||
from base32_crockford import encode as base32_encode # type: ignore
|
||||
from base32_crockford import encode as base32_encode
|
||||
from w3lib.encoding import html_body_declared_encoding, http_content_type_encoding
|
||||
try:
|
||||
import chardet # type:ignore
|
||||
@@ -200,7 +200,7 @@ def parse_date(date: Any) -> datetime | None:
|
||||
"""Parse unix timestamps, iso format, and human-readable strings"""
|
||||
|
||||
if date is None:
|
||||
return None # type: ignore
|
||||
return None
|
||||
|
||||
if isinstance(date, datetime):
|
||||
if date.tzinfo is None:
|
||||
|
||||
Reference in New Issue
Block a user