mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 13:11:15 -07:00
Bump mako from 1.1.6 to 1.2.0 (#1684)
* Bump mako from 1.1.6 to 1.2.0 Bumps [mako](https://github.com/sqlalchemy/mako) from 1.1.6 to 1.2.0. - [Release notes](https://github.com/sqlalchemy/mako/releases) - [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES) - [Commits](https://github.com/sqlalchemy/mako/commits) --- updated-dependencies: - dependency-name: mako dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Update mako==1.2.0 * Update MarkupSafe==2.1.1 * Add importlib-metadata==4.11.3 * Update requirements.txt Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci]
This commit is contained in:
parent
aa0c58ef0e
commit
238afb4794
45 changed files with 2948 additions and 848 deletions
67
lib/mako/testing/helpers.py
Normal file
67
lib/mako/testing/helpers.py
Normal file
|
@ -0,0 +1,67 @@
|
|||
import contextlib
|
||||
import pathlib
|
||||
from pathlib import Path
|
||||
import re
|
||||
import time
|
||||
from typing import Union
|
||||
from unittest import mock
|
||||
|
||||
|
||||
def flatten_result(result):
|
||||
return re.sub(r"[\s\r\n]+", " ", result).strip()
|
||||
|
||||
|
||||
def result_lines(result):
|
||||
return [
|
||||
x.strip()
|
||||
for x in re.split(r"\r?\n", re.sub(r" +", " ", result))
|
||||
if x.strip() != ""
|
||||
]
|
||||
|
||||
|
||||
def make_path(
|
||||
filespec: Union[Path, str],
|
||||
make_absolute: bool = True,
|
||||
check_exists: bool = False,
|
||||
) -> Path:
|
||||
path = Path(filespec)
|
||||
if make_absolute:
|
||||
path = path.resolve(strict=check_exists)
|
||||
if check_exists and (not path.exists()):
|
||||
raise FileNotFoundError(f"No file or directory at {filespec}")
|
||||
return path
|
||||
|
||||
|
||||
def _unlink_path(path, missing_ok=False):
|
||||
# Replicate 3.8+ functionality in 3.7
|
||||
cm = contextlib.nullcontext()
|
||||
if missing_ok:
|
||||
cm = contextlib.suppress(FileNotFoundError)
|
||||
|
||||
with cm:
|
||||
path.unlink()
|
||||
|
||||
|
||||
def replace_file_with_dir(pathspec):
|
||||
path = pathlib.Path(pathspec)
|
||||
_unlink_path(path, missing_ok=True)
|
||||
path.mkdir(exist_ok=True)
|
||||
return path
|
||||
|
||||
|
||||
def file_with_template_code(filespec):
|
||||
with open(filespec, "w") as f:
|
||||
f.write(
|
||||
"""
|
||||
i am an artificial template just for you
|
||||
"""
|
||||
)
|
||||
return filespec
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def rewind_compile_time(hours=1):
|
||||
rewound = time.time() - (hours * 3_600)
|
||||
with mock.patch("mako.codegen.time") as codegen_time:
|
||||
codegen_time.time.return_value = rewound
|
||||
yield
|
Loading…
Add table
Add a link
Reference in a new issue