diff --git a/docs/samples/story-write-stabilized-links.py b/docs/samples/story-write-stabilized-links.py index 47b7f86b0..924afb21f 100644 --- a/docs/samples/story-write-stabilized-links.py +++ b/docs/samples/story-write-stabilized-links.py @@ -42,7 +42,7 @@ def contentfn(positions): ret += f"
Contents of first section. diff --git a/docs/samples/story-write-stabilized.py b/docs/samples/story-write-stabilized.py index 334449456..531bc4921 100644 --- a/docs/samples/story-write-stabilized.py +++ b/docs/samples/story-write-stabilized.py @@ -46,7 +46,7 @@ def contentfn(positions): ret += f"
Contents of first section.
diff --git a/pipcl.py b/pipcl.py
index 8557f1500..93a3f3fdd 100644
--- a/pipcl.py
+++ b/pipcl.py
@@ -657,7 +657,7 @@ def add_str(content, to_):
log1( f'Have created wheel size={st.st_size}: {path}')
if g_verbose >= 2:
with zipfile.ZipFile(path, compression=self.wheel_compression) as z:
- log2(f'Contents are:')
+ log2('Contents are:')
for zi in sorted(z.infolist(), key=lambda z: z.filename):
log2(f' {zi.file_size: 10d} {zi.filename}')
@@ -737,14 +737,14 @@ def add_string(text, name):
add(from_, to_rel)
if not found_pyproject_toml:
- log0(f'Warning: no pyproject.toml specified.')
+ log0('Warning: no pyproject.toml specified.')
# Always add a PKG-INFO file.
add_string(self._metainfo(), 'PKG-INFO')
if self.license:
if 'COPYING' in names_in_tar:
- log2(f'Not writing .license because file already in sdist: COPYING')
+ log2('Not writing .license because file already in sdist: COPYING')
else:
add_string(self.license, 'COPYING')
@@ -978,7 +978,7 @@ def add_str(content, to_abs, to_rel):
with open(record_path, 'w') as f:
f.write(record.get())
- log2(f'Finished.')
+ log2('Finished.')
def _argv_dist_info(self, root):
@@ -1269,7 +1269,7 @@ def add(key, value):
# This is ok because we write `self.license` into
# *.dist-info/COPYING.
#
- log1( f'Omitting license because contains newline(s).')
+ log1( 'Omitting license because contains newline(s).')
return
assert '\n' not in value, f'key={key} value contains newline: {value!r}'
if key == 'Project-URL':
@@ -2040,7 +2040,7 @@ def __init__(self):
#
python_config = None
for pc in (
- f'python3-config',
+ 'python3-config',
f'{sys.executable} {sysconfig.get_config_var("srcdir")}/python-config.py',
f'{python_exe}-config',
):
@@ -2054,7 +2054,7 @@ def __init__(self):
log2(f'{e=} from {pc!r}.')
if e == 0:
python_config = pc
- assert python_config, f'Cannot find python-config'
+ assert python_config, 'Cannot find python-config'
else:
python_config = f'{python_exe}-config'
log2(f'Using {python_config=}.')
@@ -2254,7 +2254,7 @@ def run_if( command, out, *prerequisites):
if cmd is None:
doit = 'No previous command stored'
else:
- doit = f'Command has changed'
+ doit = 'Command has changed'
if 0:
doit += f': {cmd!r} => {command!r}'
diff --git a/scripts/gh_release.py b/scripts/gh_release.py
index 1cc836894..9b3b6a226 100755
--- a/scripts/gh_release.py
+++ b/scripts/gh_release.py
@@ -313,7 +313,7 @@ def make_string(*items):
),
)
if env_extra.get('CIBW_ARCHS_LINUX') == '':
- log(f'Not running cibuildwheel because CIBW_ARCHS_LINUX is empty string.')
+ log('Not running cibuildwheel because CIBW_ARCHS_LINUX is empty string.')
return
if platform.system() == 'Windows':
@@ -324,7 +324,7 @@ def make_string(*items):
),
)
if env_extra.get('CIBW_ARCHS_WINDOWS') == '':
- log(f'Not running cibuildwheel because CIBW_ARCHS_WINDOWS is empty string.')
+ log('Not running cibuildwheel because CIBW_ARCHS_WINDOWS is empty string.')
return
if platform.system() == 'Darwin':
@@ -336,7 +336,7 @@ def make_string(*items):
),
)
if env_extra.get('CIBW_ARCHS_MACOS') == '':
- log(f'Not running cibuildwheel because CIBW_ARCHS_MACOS is empty string.')
+ log('Not running cibuildwheel because CIBW_ARCHS_MACOS is empty string.')
return
def env_pass(name):
@@ -401,7 +401,7 @@ def set_cibuild_test():
assert CIBW_BUILD_old is not None
cp = cps.split()[0]
env_set('CIBW_BUILD', cp)
- log(f'Building single wheel.')
+ log('Building single wheel.')
run( f'cibuildwheel{platform_arg}', env_extra=env_extra)
# Fake-build with all python versions, using the wheel we have
@@ -411,7 +411,7 @@ def set_cibuild_test():
# wheels having extra platform tags (from cibuildwheel's use of
# auditwheel).
#
- env_set('PYMUPDF_SETUP_URL_WHEEL', f'file://wheelhouse/', pass_=True)
+ env_set('PYMUPDF_SETUP_URL_WHEEL', 'file://wheelhouse/', pass_=True)
set_cibuild_test()
env_set('CIBW_BUILD', CIBW_BUILD_old)
@@ -425,15 +425,15 @@ def set_cibuild_test():
env_set('CIBW_REPAIR_WHEEL_COMMAND', '')
if platform.system() == 'Linux' and env_extra.get('CIBW_ARCHS_LINUX') == 'aarch64':
- log(f'Testing all Python versions on linux-aarch64 is too slow and is killed by github after 6h.')
- log(f'Testing on restricted python versions using wheels in wheelhouse/.')
+ log('Testing all Python versions on linux-aarch64 is too slow and is killed by github after 6h.')
+ log('Testing on restricted python versions using wheels in wheelhouse/.')
# Testing only on first and last python versions.
cp1 = cps.split()[0]
cp2 = cps.split()[-1]
cp = cp1 if cp1 == cp2 else f'{cp1} {cp2}'
env_set('CIBW_BUILD', cp)
else:
- log(f'Testing on all python versions using wheels in wheelhouse/.')
+ log('Testing on all python versions using wheels in wheelhouse/.')
run( f'cibuildwheel{platform_arg}', env_extra=env_extra)
elif inputs_flavours:
@@ -475,7 +475,7 @@ def set_cibuild_test():
# careful to avoid incompatible wheels, e.g. 32 vs 64-bit wheels
# coexist during Windows builds.
#
- env_set('CIBW_BEFORE_TEST', f'python scripts/gh_release.py pip_install wheelhouse/pymupdfb')
+ env_set('CIBW_BEFORE_TEST', 'python scripts/gh_release.py pip_install wheelhouse/pymupdfb')
set_cibuild_test()
@@ -526,10 +526,10 @@ def venv( command=None, packages=None, quick=False, system_site_packages=False):
# explicit `pip install swig psutil`.
system_site_packages = True
#ssp = ' --system-site-packages'
- log(f'OpenBSD: libclang not available from pypi.org.')
- log(f'OpenBSD: system package `py3-llvm` must be installed.')
- log(f'OpenBSD: creating venv with --system-site-packages.')
- log(f'OpenBSD: `pip install .../PyMuPDF` must be preceded by install of swig etc.')
+ log('OpenBSD: libclang not available from pypi.org.')
+ log('OpenBSD: system package `py3-llvm` must be installed.')
+ log('OpenBSD: creating venv with --system-site-packages.')
+ log('OpenBSD: `pip install .../PyMuPDF` must be preceded by install of swig etc.')
ssp = ' --system-site-packages' if system_site_packages else ''
if quick and os.path.isdir(venv_name):
log(f'{quick=}: Not creating venv because directory already exists: {venv_name}')
@@ -564,9 +564,9 @@ def test( project, package, valgrind):
run(f'pip install {test_packages}')
if valgrind:
log('Installing valgrind.')
- run(f'sudo apt update')
- run(f'sudo apt install valgrind')
- run(f'valgrind --version')
+ run('sudo apt update')
+ run('sudo apt install valgrind')
+ run('valgrind --version')
log('Running PyMuPDF tests under valgrind.')
# We ignore memory leaks.
diff --git a/scripts/sysinstall.py b/scripts/sysinstall.py
index a5f9a42ea..d89662a9b 100755
--- a/scripts/sysinstall.py
+++ b/scripts/sysinstall.py
@@ -123,10 +123,10 @@ def main():
log(f'{os.environ.get("PYMUDF_SCRIPTS_SYSINSTALL_ARGS_POST")=}')
log(f'{sys.argv=}')
log(f'{sysconfig.get_path("platlib")=}')
- run_command(f'python -V', check=0)
- run_command(f'python3 -V', check=0)
- run_command(f'sudo python -V', check=0)
- run_command(f'sudo python3 -V', check=0)
+ run_command('python -V', check=0)
+ run_command('python3 -V', check=0)
+ run_command('sudo python -V', check=0)
+ run_command('sudo python3 -V', check=0)
run_command(f'sudo PATH={os.environ["PATH"]} python -V', check=0)
run_command(f'sudo PATH={os.environ["PATH"]} python3 -V', check=0)
@@ -215,12 +215,12 @@ def run(command, env_extra=None):
# Install required system packages. We assume a Debian package system.
#
log('## Install system packages required by MuPDF.')
- run(f'sudo apt update')
+ run('sudo apt update')
run(f'sudo apt install {" ".join(g_sys_packages)}')
# Ubuntu-22.04 has freeglut3-dev, not libglut-dev.
- run(f'sudo apt install libglut-dev | sudo apt install freeglut3-dev')
+ run('sudo apt install libglut-dev | sudo apt install freeglut3-dev')
if tesseract5:
- log(f'## Force installation of libtesseract-dev version 5.')
+ log('## Force installation of libtesseract-dev version 5.')
# https://stackoverflow.com/questions/76834972/how-can-i-run-pytesseract-python-library-in-ubuntu-22-04
#
run('sudo apt install -y software-properties-common')
@@ -244,20 +244,20 @@ def run(command, env_extra=None):
command += f' -j {multiprocessing.cpu_count()}'
#command += f' EXE_LDFLAGS=-Wl,--trace' # Makes linker generate diagnostics as it runs.
command += f' DESTDIR={root}'
- command += f' HAVE_LEPTONICA=yes'
- command += f' HAVE_TESSERACT=yes'
- command += f' USE_SYSTEM_LIBS=yes'
+ command += ' HAVE_LEPTONICA=yes'
+ command += ' HAVE_TESSERACT=yes'
+ command += ' USE_SYSTEM_LIBS=yes'
# We need latest zxingcpp so system version not ok.
- command += f' USE_SYSTEM_ZXINGCPP=no'
- command += f' barcode=yes'
+ command += ' USE_SYSTEM_ZXINGCPP=no'
+ command += ' barcode=yes'
command += f' VENV_FLAG={"--venv" if pip == "venv" else ""}'
if mupdf_so_mode:
command += f' SO_INSTALL_MODE={mupdf_so_mode}'
- command += f' build_prefix=system-libs-'
+ command += ' build_prefix=system-libs-'
command += f' prefix={prefix}'
- command += f' verbose=yes'
- command += f' install-shared-python'
- command += f' INSTALL_MODE=755'
+ command += ' verbose=yes'
+ command += ' install-shared-python'
+ command += ' INSTALL_MODE=755'
run( command)
# Build+install PyMuPDF.
@@ -272,13 +272,13 @@ def run(command):
env += f'CFLAGS="{compile_flags}" '
env += f'CXXFLAGS="{compile_flags}" '
env += f'LDFLAGS="-L {root}/{prefix}/lib" '
- env += f'PYMUPDF_SETUP_MUPDF_BUILD= ' # Use system MuPDF.
+ env += 'PYMUPDF_SETUP_MUPDF_BUILD= ' # Use system MuPDF.
if use_installer:
- log(f'## Building wheel.')
+ log('## Building wheel.')
if pip == 'venv':
venv_name = 'venv-pymupdf-sysinstall'
- run(f'pwd')
- run(f'rm dist/* || true')
+ run('pwd')
+ run('rm dist/* || true')
if pip == 'venv':
run(f'{sys.executable} -m venv {venv_name}')
run(f'. {venv_name}/bin/activate && pip install --upgrade pip')
@@ -286,14 +286,14 @@ def run(command):
run(f'{env} {venv_name}/bin/python -m pip wheel -vv -w dist {os.path.abspath(pymupdf_dir)}')
elif pip == 'sudo':
#run(f'sudo pip install --upgrade pip') # Breaks on Github see: https://github.com/pypa/get-pip/issues/226.
- run(f'sudo pip install installer')
+ run('sudo pip install installer')
run(f'{env} pip wheel -vv -w dist {os.path.abspath(pymupdf_dir)}')
else:
log(f'Not installing "installer" because {pip=}.')
- wheel = glob.glob(f'dist/*')
+ wheel = glob.glob('dist/*')
assert len(wheel) == 1, f'{wheel=}'
wheel = wheel[0]
- log(f'## Installing wheel using `installer`.')
+ log('## Installing wheel using `installer`.')
pv = '.'.join(platform.python_version_tuple()[:2])
p = f'{root_prefix}/lib/python{pv}'
# `python -m installer` fails to overwrite existing files.
@@ -352,7 +352,7 @@ def run(command, env_extra=None):
run(f'{sys.executable} -m venv {test_venv}')
# Install required packages.
command = f'. {test_venv}/bin/activate'
- command += f' && pip install --upgrade pip'
+ command += ' && pip install --upgrade pip'
command += f' && pip install --upgrade {gh_release.test_packages}'
run(command)
elif pip == 'sudo':
@@ -374,7 +374,7 @@ def run(command, env_extra=None):
command += f' {pymupdf_dir}/scripts/test.py'
if gdb:
command += ' --gdb 1'
- command += f' -v 0'
+ command += ' -v 0'
if pytest_name is None:
excluded_tests = (
'test_color_count',
diff --git a/scripts/test.py b/scripts/test.py
index 7c425c867..875d5892f 100755
--- a/scripts/test.py
+++ b/scripts/test.py
@@ -269,7 +269,7 @@ def main(argv):
assert 0, f'Unrecognised option: {arg=}.'
if arg is None:
- log(f'No command specified.')
+ log('No command specified.')
return
commands = list()
@@ -368,7 +368,7 @@ def github_workflow_unimportant():
GITHUB_EVENT_NAME = os.environ.get('GITHUB_EVENT_NAME')
GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY')
if GITHUB_EVENT_NAME == 'schedule' and GITHUB_REPOSITORY != 'pymupdf/PyMuPDF':
- log(f'## This is an unimportant Github workflow: a scheduled event, not in the main repository `pymupdf/PyMuPDF`.')
+ log('## This is an unimportant Github workflow: a scheduled event, not in the main repository `pymupdf/PyMuPDF`.')
log(f'## {GITHUB_EVENT_NAME=}.')
log(f'## {GITHUB_REPOSITORY=}.')
return True
@@ -472,7 +472,7 @@ def build_pyodide_wheel(pyodide_build_version=None):
This runs `pyodide build` inside the PyMuPDF directory, which in turn runs
setup.py in a Pyodide build environment.
'''
- log(f'## Building Pyodide wheel.')
+ log('## Building Pyodide wheel.')
# Our setup.py does not know anything about Pyodide; we set a few
# required environmental variables here.
@@ -563,7 +563,7 @@ def pyodide_setup(
# important to remove it here.
shutil.rmtree('.pyodide-xbuildenv', ignore_errors=1)
if not os.path.exists(f'{directory}/{dir_emsdk}'):
- command += f' && echo "### Cloning emsdk.git"'
+ command += ' && echo "### Cloning emsdk.git"'
command += f' && git clone https://github.com/emscripten-core/emsdk.git {dir_emsdk}'
command += f' && echo "### Updating checkout {dir_emsdk}"'
command += f' && (cd {dir_emsdk} && git pull -r)'
@@ -579,8 +579,8 @@ def pyodide_setup(
command += f' && echo "### Creating venv {venv_pyodide}"'
command += f' && {python} -m venv {venv_pyodide}'
command += f' && . {venv_pyodide}/bin/activate'
- command += f' && echo "### Installing Python packages."'
- command += f' && python -m pip install --upgrade pip wheel pyodide-build'
+ command += ' && echo "### Installing Python packages."'
+ command += ' && python -m pip install --upgrade pip wheel pyodide-build'
if pyodide_build_version:
command += f'=={pyodide_build_version}'
@@ -725,9 +725,9 @@ def getmtime(path):
if valgrind:
if packages:
log('Installing valgrind.')
- run(f'sudo apt update')
- run(f'sudo apt install --upgrade valgrind')
- run(f'valgrind --version')
+ run('sudo apt update')
+ run('sudo apt install --upgrade valgrind')
+ run('valgrind --version')
log('Running PyMuPDF tests under valgrind.')
command = (
@@ -776,19 +776,19 @@ def getmtime(path):
with open(p2, 'w', encoding='utf8') as f:
f.write(text2)
- log(f'Running tests with tests/run_compound.py and pytest.')
+ log('Running tests with tests/run_compound.py and pytest.')
run(command, env_extra=env_extra, timeout=timeout)
except subprocess.TimeoutExpired as e:
- log(f'Timeout when running tests.')
+ log('Timeout when running tests.')
raise
finally:
- log(f'\n'
- f'[As of 2024-10-10 we get warnings from pytest/Python such as:\n'
- f' DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute\n'
- f'This seems to be due to Swig\'s handling of Py_LIMITED_API.\n'
- f'For details see https://github.com/swig/swig/issues/2881.\n'
- f']'
+ log('\n'
+ '[As of 2024-10-10 we get warnings from pytest/Python such as:\n'
+ ' DeprecationWarning: builtin type SwigPyPacked has no __module__ attribute\n'
+ 'This seems to be due to Swig\'s handling of Py_LIMITED_API.\n'
+ 'For details see https://github.com/swig/swig/issues/2881.\n'
+ ']'
)
log('\n' + venv_info(pytest_args=f'{pytest_options} {pytest_arg}'))
diff --git a/setup.py b/setup.py
index 01bc391fd..c1413fa49 100755
--- a/setup.py
+++ b/setup.py
@@ -220,7 +220,7 @@ def run(command, check=1):
if 1:
# For debugging.
- log(f'### Starting.')
+ log('### Starting.')
log(f'__name__: {__name__!r}')
log(f'platform.platform(): {platform.platform()!r}')
log(f'platform.python_version(): {platform.python_version()!r}')
@@ -648,7 +648,7 @@ def build():
g_py_limited_api,
)
else:
- log(f'Not building extension.')
+ log('Not building extension.')
path_so_leaf = None
# Generate list of (from, to) items to return to pipcl. What we add depends
@@ -824,19 +824,19 @@ def build_mupdf_windows(
if devenv.startswith( q) and devenv.endswith( q):
devenv = devenv[1:-1]
command += f' -d {windows_build_tail}'
- command += f' -b'
+ command += ' -b'
if PYMUPDF_SETUP_MUPDF_REFCHECK_IF:
command += f' --refcheck-if "{PYMUPDF_SETUP_MUPDF_REFCHECK_IF}"'
if PYMUPDF_SETUP_MUPDF_TRACE_IF:
command += f' --trace-if "{PYMUPDF_SETUP_MUPDF_TRACE_IF}"'
command += f' --devenv "{devenv}"'
- command += f' all'
+ command += ' all'
if os.environ.get( 'PYMUPDF_SETUP_MUPDF_REBUILD') == '0':
log( f'PYMUPDF_SETUP_MUPDF_REBUILD is "0" so not building MuPDF; would have run: {command}')
else:
log( f'Building MuPDF by running: {command}')
subprocess.run( command, shell=True, check=True)
- log( f'Finished building mupdf.')
+ log( 'Finished building mupdf.')
return windows_build_dir
@@ -880,14 +880,14 @@ def build_mupdf_unix(
system MuPDF.
'''
if not mupdf_local:
- log( f'Using system mupdf.')
+ log( 'Using system mupdf.')
return None
env = dict()
if overwrite_config:
# By predefining TOFU_CJK_EXT here, we don't need to modify
# MuPDF's include/mupdf/fitz/config.h.
- log( f'Setting XCFLAGS and XCXXFLAGS to predefine TOFU_CJK_EXT.')
+ log( 'Setting XCFLAGS and XCXXFLAGS to predefine TOFU_CJK_EXT.')
env_add(env, 'XCFLAGS', '-DTOFU_CJK_EXT')
env_add(env, 'XCXXFLAGS', '-DTOFU_CJK_EXT')
@@ -905,8 +905,8 @@ def build_mupdf_unix(
# See:
# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md
#
- log(f'Using llvm@15 clang and clang++')
- cl15 = pipcl.run(f'brew --prefix llvm@15', capture=1)
+ log('Using llvm@15 clang and clang++')
+ cl15 = pipcl.run('brew --prefix llvm@15', capture=1)
log(f'{cl15=}')
cl15 = cl15.strip()
pipcl.run(f'ls -lL {cl15}')
@@ -950,7 +950,7 @@ def build_mupdf_unix(
# a system limit, not the actual limit of the current shell, and there
# doesn't seem to be a way to find the current shell's limit.
#
- build_prefix = f'PyMuPDF-'
+ build_prefix = 'PyMuPDF-'
if mupdf_version_tuple >= (1, 26):
# Avoid link command length problems seen on musllinux.
build_prefix = ''
@@ -965,16 +965,16 @@ def build_mupdf_unix(
if msys2:
# Error in mupdf/scripts/tesseract/endianness.h:
# #error "I don't know what architecture this is!"
- log(f'msys2: building MuPDF without tesseract.')
+ log('msys2: building MuPDF without tesseract.')
elif os.environ.get('PYMUPDF_SETUP_MUPDF_TESSERACT') == '0':
- log(f'PYMUPDF_SETUP_MUPDF_TESSERACT=0 so building mupdf without tesseract.')
+ log('PYMUPDF_SETUP_MUPDF_TESSERACT=0 so building mupdf without tesseract.')
else:
build_prefix += 'tesseract-'
if (
linux
and os.environ.get('PYMUPDF_SETUP_MUPDF_BSYMBOLIC', '1') == '1'
):
- log(f'Appending `bsymbolic-` to MuPDF build path.')
+ log('Appending `bsymbolic-` to MuPDF build path.')
build_prefix += 'bsymbolic-'
log(f'{g_py_limited_api=}')
if g_py_limited_api:
@@ -1004,7 +1004,7 @@ def build_mupdf_unix(
else:
log( f'Building MuPDF by running: {command}')
subprocess.run( command, shell=True, check=True)
- log( f'Finished building mupdf.')
+ log( 'Finished building mupdf.')
return unix_build_dir
@@ -1205,7 +1205,7 @@ def sdist():
if tgz:
ret.append((tgz, mupdf_tgz))
else:
- log(f'Not including MuPDF .tgz in sdist.')
+ log('Not including MuPDF .tgz in sdist.')
return ret
@@ -1246,7 +1246,7 @@ def sdist():
# the required binaries, but pip will still see `requires_dist` set to
# 'PyMuPDFb', so will also download and build PyMuPDFb's sdist.
#
- log(f'Specifying dummy PyMuPDFb wheel.')
+ log('Specifying dummy PyMuPDFb wheel.')
def get_requires_for_build_wheel(config_settings=None):
return list()
@@ -1357,9 +1357,9 @@ def platform_release_tuple():
print(f'Overriding to use {libclang=}.')
ret.append(libclang)
elif openbsd:
- print(f'OpenBSD: libclang not available via pip; assuming `pkg_add py3-llvm`.')
+ print('OpenBSD: libclang not available via pip; assuming `pkg_add py3-llvm`.')
elif darwin and platform.machine() == 'arm64':
- print(f'MacOS/arm64: forcing use of libclang 16.0.6 because 18.1.1 known to fail with `clang.cindex.TranslationUnitLoadError: Error parsing translation unit.`')
+ print('MacOS/arm64: forcing use of libclang 16.0.6 because 18.1.1 known to fail with `clang.cindex.TranslationUnitLoadError: Error parsing translation unit.`')
ret.append('libclang==16.0.6')
elif darwin and platform_release_tuple() < (18,):
# There are still of problems when building on old macos.
@@ -1367,9 +1367,9 @@ def platform_release_tuple():
else:
ret.append('libclang')
if msys2:
- print(f'msys2: pip install of swig does not build; assuming `pacman -S swig`.')
+ print('msys2: pip install of swig does not build; assuming `pacman -S swig`.')
elif openbsd:
- print(f'OpenBSD: pip install of swig does not build; assuming `pkg_add swig`.')
+ print('OpenBSD: pip install of swig does not build; assuming `pkg_add swig`.')
else:
ret.append( 'swig')
return ret
@@ -1397,7 +1397,7 @@ def build_wheel(
url += leaf
log(f'Downloading from {url=} to {out_path_temp=}.')
urllib.request.urlretrieve(url, out_path_temp)
- elif url.startswith(f'file://'):
+ elif url.startswith('file://'):
in_path = url[len('file://'):]
log(f'{in_path=}')
if in_path.endswith('/'):
diff --git a/src/__init__.py b/src/__init__.py
index 8d48ce717..e33b273e2 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -273,7 +273,7 @@ def message(text=''):
def exception_info():
import traceback
- log(f'exception_info:')
+ log('exception_info:')
log(traceback.format_exc())
@@ -456,7 +456,7 @@ def _as_fz_document(document):
elif isinstance(document, mupdf.PdfDocument):
return document.super()
elif document is None:
- assert 0, f'document is None'
+ assert 0, 'document is None'
else:
assert 0, f'Unrecognised {type(document)=}'
@@ -479,7 +479,7 @@ def _as_pdf_document(document, required=True):
assert ret.m_internal
return ret
elif document is None:
- assert 0, f'document is None'
+ assert 0, 'document is None'
else:
assert 0, f'Unrecognised {type(document)=}'
@@ -494,7 +494,7 @@ def _as_fz_page(page):
elif isinstance(page, mupdf.FzPage):
return page
elif page is None:
- assert 0, f'page is None'
+ assert 0, 'page is None'
else:
assert 0, f'Unrecognised {type(page)=}'
@@ -514,7 +514,7 @@ def _as_pdf_page(page, required=True):
assert ret.m_internal
return ret
elif page is None:
- assert 0, f'page is None'
+ assert 0, 'page is None'
else:
assert 0, f'Unrecognised {type(page)=}'
@@ -2449,7 +2449,7 @@ def set_attribute( self, key, value):
def set_bgcolor(self, color):
"""Set background color via CSS style"""
- text = f"background-color: %s" % self.color_text(color)
+ text = f"background-color: {self.color_text(color)}"
self.add_style(text) # does not work on span level
return self
@@ -2465,7 +2465,7 @@ def set_bold(self, val=True):
def set_color(self, color):
"""Set text color via CSS style"""
- text = f"color: %s" % self.color_text(color)
+ text = f"color: {self.color_text(color)}"
self.append_styled_span(text)
return self
@@ -3489,7 +3489,7 @@ def _make_page_map(self):
"""Make an array page number -> page object."""
if self.is_closed:
raise ValueError("document closed")
- assert 0, f'_make_page_map() is no-op'
+ assert 0, '_make_page_map() is no-op'
def _move_copy_page(self, pno, nb, before, copy):
"""Move or copy a PDF page reference."""
@@ -7451,7 +7451,7 @@ def __init__(self):
self.sopts = sopts
def filter(self, ctx, doc, chain, struct_parents, transform, options):
if 0:
- log(f'sanitize filter.filter():')
+ log('sanitize filter.filter():')
log(f' {self=}')
log(f' {ctx=}')
log(f' {doc=}')
@@ -12114,9 +12114,9 @@ def add_pdf_links(document_or_stream, positions):
# Make link from `position_from`'s rect to top-left of
# `position_to`'s rect.
if 0:
- log(f"add_pdf_links(): making link from:")
+ log("add_pdf_links(): making link from:")
log(f"add_pdf_links(): {position_from}")
- log(f"add_pdf_links(): to:")
+ log("add_pdf_links(): to:")
log(f"add_pdf_links(): {position_to}")
link["kind"] = LINK_GOTO
x0, y0, x1, y1 = position_to.rect
@@ -12389,7 +12389,7 @@ def ret():
if state.pmax is not None:
if state.last_p != state.pmax:
if verbose:
- log(f'Calling update() with pmax, because was overwritten by later calls.')
+ log('Calling update() with pmax, because was overwritten by later calls.')
big_enough = update(state.pmax)
assert big_enough
result = state.pmax_result
@@ -12412,7 +12412,7 @@ def update(parameter):
big_enough = False
result = Story.FitResult(parameter=parameter, numcalls=state.numcalls)
if verbose:
- log(f'update(): not calling self.place() because rect is empty.')
+ log('update(): not calling self.place() because rect is empty.')
else:
more, filled = self.place(rect)
state.numcalls += 1
@@ -12449,7 +12449,7 @@ def opposite(p, direction):
if state.pmin is None:
# Find an initial finite pmin value.
- if verbose: log(f'finding pmin.')
+ if verbose: log('finding pmin.')
parameter = opposite(state.pmax, -1)
while 1:
if not update(parameter):
@@ -12462,7 +12462,7 @@ def opposite(p, direction):
if state.pmax is None:
# Find an initial finite pmax value.
- if verbose: log(f'finding pmax.')
+ if verbose: log('finding pmax.')
parameter = opposite(state.pmin, +1)
while 1:
if update(parameter):
@@ -15714,7 +15714,7 @@ def JM_get_fontbuffer(doc, xref):
obj = mupdf.pdf_dict_get(o, PDF_NAME('FontDescriptor'))
if not obj.m_internal:
- message(f"invalid font - FontDescriptor missing")
+ message("invalid font - FontDescriptor missing")
return
o = obj
@@ -16419,7 +16419,7 @@ def JM_make_annot_DA(annot, ncol, col, fontname, fontsize):
# string directly in Python.
buf = ''
if ncol < 1:
- buf += f'0 g '
+ buf += '0 g '
elif ncol == 1:
buf += f'{col[0]:g} g '
elif ncol == 2:
@@ -19049,7 +19049,7 @@ def lineto(self, ctx, x, y): # trace_lineto().
def moveto(self, ctx, x, y): # trace_moveto().
if 0 and isinstance(self.dev.pathdict, dict):
- log(f'self.dev.pathdict:')
+ log('self.dev.pathdict:')
for n, v in self.dev.pathdict.items():
log( ' {type(n)=} {len(n)=} {n!r} {n}: {v!r}: {v}')
@@ -20385,21 +20385,21 @@ def pdfobj_string(o, prefix=''):
elif mupdf.pdf_is_embedded_file(o):
ret += f'embedded_file: {o.embedded_file_name()}\n'
elif mupdf.pdf_is_indirect(o):
- ret += f'indirect: ...\n'
+ ret += 'indirect: ...\n'
elif mupdf.pdf_is_int(o):
ret += f'int: {mupdf.pdf_to_int(o)}\n'
elif mupdf.pdf_is_jpx_image(o):
- ret += f'jpx_image:\n'
+ ret += 'jpx_image:\n'
elif mupdf.pdf_is_name(o):
ret += f'name: {mupdf.pdf_to_name(o)}\n'
elif o.pdf_is_null:
- ret += f'null\n'
+ ret += 'null\n'
#elif o.pdf_is_number:
# ret += f'number\n'
elif o.pdf_is_real:
ret += f'real: {o.pdf_to_real()}\n'
elif mupdf.pdf_is_stream(o):
- ret += f'stream\n'
+ ret += 'stream\n'
elif mupdf.pdf_is_string(o):
ret += f'string: {mupdf.pdf_to_string(o)}\n'
else:
diff --git a/src/_apply_pages.py b/src/_apply_pages.py
index 0aae54c78..4e9d7ff55 100644
--- a/src/_apply_pages.py
+++ b/src/_apply_pages.py
@@ -205,7 +205,7 @@ def childfn():
if stats:
t = time.time()
if verbose:
- pymupdf.log(f'Sending page numbers.')
+ pymupdf.log('Sending page numbers.')
for page_num in range(len(pages)):
queue_down.put(page_num)
if stats:
@@ -230,7 +230,7 @@ def childfn():
# send None, which makes workers terminate.
for i in range(concurrency):
queue_down.put(None)
- if verbose: pymupdf.log(f'Closing queues.')
+ if verbose: pymupdf.log('Closing queues.')
queue_down.close()
if error:
diff --git a/src/utils.py b/src/utils.py
index 84c657bce..3a8ac2035 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -5576,7 +5576,7 @@ def find_buffer_by_name(name):
repl_fontnames(doc) # populate font information
if not font_buffers: # nothing found to do
if verbose:
- pymupdf.message(f'No fonts to subset.')
+ pymupdf.message('No fonts to subset.')
return 0
old_fontsize = 0
diff --git a/tests/conftest.py b/tests/conftest.py
index 7e123435e..8c23b6312 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -53,7 +53,7 @@ def get_fds():
# Test has run; check it did not create any MuPDF warnings etc.
wt = pymupdf.TOOLS.mupdf_warnings()
if not hasattr(pymupdf, 'mupdf'):
- print(f'Not checking mupdf_warnings on classic.')
+ print('Not checking mupdf_warnings on classic.')
else:
assert not wt, f'Warnings text not empty: {wt=}'
@@ -70,12 +70,12 @@ def get_fds():
open_fds_after, open_fds_after_l = get_fds()
if open_fds_after != open_fds_before:
import textwrap
- print(f'Test has changed process fds:')
+ print('Test has changed process fds:')
print(f' {open_fds_before=}')
print(f' {open_fds_after=}')
- print(f'open_fds_before_l:')
+ print('open_fds_before_l:')
print(textwrap.indent(open_fds_before_l, ' '))
- print(f'open_fds_after_l:')
+ print('open_fds_after_l:')
print(textwrap.indent(open_fds_after_l, ' '))
#assert 0
diff --git a/tests/test_2904.py b/tests/test_2904.py
index 21b55fb18..cfcfe92e8 100644
--- a/tests/test_2904.py
+++ b/tests/test_2904.py
@@ -19,7 +19,7 @@ def test_2904():
except Exception as ee:
print(f'Exception: {page_id=} {i=} {img=}: {ee}')
if 0 and hasattr(pymupdf, 'mupdf'):
- print(f'pymupdf.exception_info:')
+ print('pymupdf.exception_info:')
pymupdf.exception_info()
sys.stdout.flush()
e = ee
diff --git a/tests/test_annots.py b/tests/test_annots.py
index 2c67f906d..054c5a09b 100644
--- a/tests/test_annots.py
+++ b/tests/test_annots.py
@@ -422,7 +422,7 @@ def test_3863():
pixmap.save(path_png)
# Compare with expected png.
- print(f'Comparing page PNGs with expected PNGs.')
+ print('Comparing page PNGs with expected PNGs.')
for num, _ in enumerate(document):
path_png = f'{path_out}.{num}.png'
path_png_expected = f'{path_in}.pdf.{num}.png'
@@ -469,7 +469,7 @@ def test_parent():
assert isinstance(e, pymupdf.mupdf.FzErrorArgument), f'Incorrect {type(e)=}.'
assert str(e) == 'code=4: annotation not bound to any page', f'Incorrect error text {str(e)=}.'
else:
- assert 0, f'Failed to get expected exception.'
+ assert 0, 'Failed to get expected exception.'
def test_4047():
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4047.pdf')
diff --git a/tests/test_codespell.py b/tests/test_codespell.py
index 2c4b4d75c..312afdcfb 100644
--- a/tests/test_codespell.py
+++ b/tests/test_codespell.py
@@ -18,7 +18,7 @@ def test_codespell():
if platform.system() == 'Windows':
# Git commands seem to fail on Github Windows runners.
- print(f'test_codespell(): Not running on Widows')
+ print('test_codespell(): Not running on Widows')
return
root = os.path.abspath(f'{__file__}/../..')
@@ -63,6 +63,6 @@ def test_codespell():
# Don't print entire command because very long, and will be displayed
# anyway if there is an error.
#print(f'test_codespell(): Running: {command}')
- print(f'Running codespell.')
+ print('Running codespell.')
subprocess.run(command, shell=1, check=1)
print('test_codespell(): codespell succeeded.')
diff --git a/tests/test_docs_samples.py b/tests/test_docs_samples.py
index da3a3e8ea..860483031 100644
--- a/tests/test_docs_samples.py
+++ b/tests/test_docs_samples.py
@@ -35,7 +35,7 @@ def _test_all():
if 0:
# Curiously this fails in an odd way when testing compound
# package with $PYTHONPATH set.
- print( f'os.environ is:')
+ print( 'os.environ is:')
for n, v in os.environ.items():
print( f' {n}: {v!r}')
command = f'{sys.executable} {sample}'
diff --git a/tests/test_flake8.py b/tests/test_flake8.py
index ddc55fece..40c7f679a 100644
--- a/tests/test_flake8.py
+++ b/tests/test_flake8.py
@@ -10,7 +10,7 @@ def test_flake8():
Check rebased Python code with flake8.
'''
if not hasattr(pymupdf, 'mupdf'):
- print(f'Not running flake8 with classic implementation.')
+ print('Not running flake8 with classic implementation.')
return
ignores = (
'E123', # closing bracket does not match indentation of opening bracket's line
@@ -51,4 +51,4 @@ def run(command):
print(f'test_flake8(): Running: {command}')
subprocess.run(command, shell=1, check=1)
run(f'flake8 --ignore={ignores} --statistics {root}/src/__init__.py {root}/src/utils.py {root}/src/table.py')
- print(f'test_flake8(): flake8 succeeded.')
+ print('test_flake8(): flake8 succeeded.')
diff --git a/tests/test_font.py b/tests/test_font.py
index 4cc857751..c41795bfc 100644
--- a/tests/test_font.py
+++ b/tests/test_font.py
@@ -97,7 +97,7 @@ def test_fontarchive():
def test_load_system_font():
if not hasattr(pymupdf, 'mupdf'):
- print(f'test_load_system_font(): Not running on classic.')
+ print('test_load_system_font(): Not running on classic.')
return
trace = list()
def font_f(name, bold, italic, needs_exact_metrics):
@@ -212,7 +212,7 @@ def test_3887():
document.ez_save(path2)
with pymupdf.open(path2) as document:
- text = f"\u0391\u3001\u0392\u3001\u0393\u3001\u0394\u3001\u0395\u3001\u0396\u3001\u0397\u3001\u0398\u3001\u0399\u3001\u039a\u3001\u039b\u3001\u039c\u3001\u039d\u3001\u039e\u3001\u039f\u3001\u03a0\u3001\u03a1\u3001\u03a3\u3001\u03a4\u3001\u03a5\u3001\u03a6\u3001\u03a7\u3001\u03a8\u3001\u03a9\u3002\u03b1\u3001\u03b2\u3001\u03b3\u3001\u03b4\u3001\u03b5\u3001\u03b6\u3001\u03b7\u3001\u03b8\u3001\u03b9\u3001\u03ba\u3001\u03bb\u3001\u03bc\u3001\u03bd\u3001\u03be\u3001\u03bf\u3001\u03c0\u3001\u03c1\u3001\u03c2\u3001\u03c4\u3001\u03c5\u3001\u03c6\u3001\u03c7\u3001\u03c8\u3001\u03c9\u3002"
+ text = "\u0391\u3001\u0392\u3001\u0393\u3001\u0394\u3001\u0395\u3001\u0396\u3001\u0397\u3001\u0398\u3001\u0399\u3001\u039a\u3001\u039b\u3001\u039c\u3001\u039d\u3001\u039e\u3001\u039f\u3001\u03a0\u3001\u03a1\u3001\u03a3\u3001\u03a4\u3001\u03a5\u3001\u03a6\u3001\u03a7\u3001\u03a8\u3001\u03a9\u3002\u03b1\u3001\u03b2\u3001\u03b3\u3001\u03b4\u3001\u03b5\u3001\u03b6\u3001\u03b7\u3001\u03b8\u3001\u03b9\u3001\u03ba\u3001\u03bb\u3001\u03bc\u3001\u03bd\u3001\u03be\u3001\u03bf\u3001\u03c0\u3001\u03c1\u3001\u03c2\u3001\u03c4\u3001\u03c5\u3001\u03c6\u3001\u03c7\u3001\u03c8\u3001\u03c9\u3002"
page = document[0]
chars = [c for b in page.get_text("rawdict",flags=0)["blocks"] for l in b["lines"] for s in l["spans"] for c in s["chars"]]
output = [c["c"] for c in chars]
diff --git a/tests/test_general.py b/tests/test_general.py
index a923ad19c..f922fc6d9 100644
--- a/tests/test_general.py
+++ b/tests/test_general.py
@@ -373,27 +373,27 @@ def test_2108():
if 1:
# Verbose info.
print(f'test_2108(): text is:\n{text}')
- print(f'')
+ print('')
print(f'test_2108(): repr(text) is:\n{text!r}')
- print(f'')
+ print('')
print(f'test_2108(): repr(text.encode("utf8")) is:\n{text.encode("utf8")!r}')
- print(f'')
+ print('')
print(f'test_2108(): text_expected is:\n{text_expected}')
- print(f'')
+ print('')
print(f'test_2108(): repr(text_expected) is:\n{text_expected!r}')
- print(f'')
+ print('')
print(f'test_2108(): repr(text_expected.encode("utf8")) is:\n{text_expected.encode("utf8")!r}')
ok1 = (text == text_expected)
ok2 = (text.encode("utf8") == text_expected.encode("utf8"))
ok3 = (repr(text.encode("utf8")) == repr(text_expected.encode("utf8")))
- print(f'')
+ print('')
print(f'ok1={ok1}')
print(f'ok2={ok2}')
print(f'ok3={ok3}')
- print(f'')
+ print('')
print(f'{pymupdf.mupdf_version_tuple=}')
if pymupdf.mupdf_version_tuple >= (1, 21, 2):
@@ -501,12 +501,12 @@ def average_color(page):
def test_2182():
- print(f'test_2182() started')
+ print('test_2182() started')
doc = pymupdf.open(f'{scriptdir}/resources/test2182.pdf')
page = doc[0]
for annot in page.annots():
print(annot)
- print(f'test_2182() finished')
+ print('test_2182() finished')
def test_2246():
@@ -734,7 +734,7 @@ def assert_rects_approx_eq(a, b):
assert_rects_approx_eq(page.mediabox, pymupdf.Rect(0.0, 0.0, 595.3200073242188, 841.9199829101562))
print(f'test_2710(): {pymupdf.mupdf_version_tuple=}')
# 2023-11-05: Currently broken in mupdf master.
- print(f'test_2710(): Not Checking page.rect and rect.')
+ print('test_2710(): Not Checking page.rect and rect.')
rebased = hasattr(pymupdf, 'mupdf')
if rebased:
wt = pymupdf.TOOLS.mupdf_warnings()
@@ -976,7 +976,7 @@ def test_3112_set_xml_metadata():
def test_archive_3126():
if not hasattr(pymupdf, 'mupdf'):
- print(f'Not running because known to fail with classic.')
+ print('Not running because known to fail with classic.')
return
p = os.path.abspath(f'{__file__}/../../tests/resources')
p = pathlib.Path(p)
@@ -984,7 +984,7 @@ def test_archive_3126():
def test_3140():
if not hasattr(pymupdf, 'mupdf'):
- print(f'Not running test_3140 on classic, because Page.insert_htmlbox() not available.')
+ print('Not running test_3140 on classic, because Page.insert_htmlbox() not available.')
return
css2 = ''
path = os.path.abspath(f'{__file__}/../../tests/resources/2.pdf')
@@ -1022,14 +1022,14 @@ def test_cli():
print('test_cli(): Not running on classic because of fitz_old.')
return
import subprocess
- subprocess.run(f'pymupdf -h', shell=1, check=1)
+ subprocess.run('pymupdf -h', shell=1, check=1)
def check_lines(expected_regexes, actual):
'''
Checks lines in {time.strftime("%F-%T")}\n')
- f.write(f' Contents of first section.
\n')
+ f.write('
\n')
+ f.write('/\n')
+ f.write('\n')
print(f'Have created: {path_html}')
path_out = os.path.normpath(f'{__file__}/../../tests/test_open2.json')
@@ -1558,7 +1558,7 @@ def dict_set_path(dict_, *items):
with open(os.path.normpath(f'{__file__}/../../tests/resources/test_open2_expected.json')) as f:
results_expected = json.load(f)
if results != results_expected:
- print(f'results != results_expected:')
+ print('results != results_expected:')
def show(r, name):
text = json.dumps(r, indent=4, sort_keys=1)
print(f'{name}:')
@@ -1666,7 +1666,7 @@ def test_3450():
# On a mac-mini, PyMuPDF-1.24.8 takes 60s, PyMuPDF-1.24.9 takes 4s.
#
if os.environ.get('PYMUPDF_RUNNING_ON_VALGRIND') == '1':
- print(f'test_3450(): not running on valgrind because very slow.', flush=1)
+ print('test_3450(): not running on valgrind because very slow.', flush=1)
return
path = os.path.normpath(f'{__file__}/../../tests/resources/test_3450.pdf')
pdf = pymupdf.open(path)
@@ -1684,7 +1684,7 @@ def test_3859():
name2 = f'PDF_{name}'
v = getattr(pymupdf.mupdf, name2)
print(f'{name=} {name2=} {v=} {type(v)=}')
- assert type(v)==pymupdf.mupdf.PdfObj, f'`v` is not a pymupdf.mupdf.PdfObj.'
+ assert type(v)==pymupdf.mupdf.PdfObj, '`v` is not a pymupdf.mupdf.PdfObj.'
def test_3905():
data = b'A,B,C,D\r\n1,2,1,2\r\n2,2,1,2\r\n'
diff --git a/tests/test_memory.py b/tests/test_memory.py
index 7d37833db..0db7bf911 100644
--- a/tests/test_memory.py
+++ b/tests/test_memory.py
@@ -18,10 +18,10 @@ def test_2791():
Check for memory leaks.
'''
if os.environ.get('PYMUPDF_RUNNING_ON_VALGRIND') == '1':
- print(f'test_2791(): not running because PYMUPDF_RUNNING_ON_VALGRIND=1.')
+ print('test_2791(): not running because PYMUPDF_RUNNING_ON_VALGRIND=1.')
return
if platform.system().startswith('MSYS_NT-'):
- print(f'test_2791(): not running on msys2 - psutil not available.')
+ print('test_2791(): not running on msys2 - psutil not available.')
return
#stat_type = 'tracemalloc'
stat_type = 'psutil'
@@ -68,10 +68,10 @@ def get_stat():
# Values from psutil indicate larger memory leaks on non-Linux. Don't
# yet know whether this is because rss is measured differently or a
# genuine leak is being exposed.
- print(f'test_2791(): not asserting ratio because not running on Linux.')
+ print('test_2791(): not asserting ratio because not running on Linux.')
elif not hasattr(pymupdf, 'mupdf'):
# Classic implementation has unfixed leaks.
- print(f'test_2791(): not asserting ratio because using classic implementation.')
+ print('test_2791(): not asserting ratio because using classic implementation.')
elif [int(x) for x in platform.python_version_tuple()[:2]] < [3, 11]:
print(f'test_2791(): not asserting ratio because python version less than 3.11: {platform.python_version()=}.')
elif stat_type == 'tracemalloc':
@@ -130,7 +130,7 @@ def show_tracemalloc_diff(snapshot1, snapshot2):
for stat in top_stats[:10]:
print(f' {stat}')
snapshot_diff = snapshot2.compare_to(snapshot1, key_type='lineno')
- print(f'snapshot_diff:')
+ print('snapshot_diff:')
count_diff = 0
size_diff = 0
for i, s in enumerate(snapshot_diff):
@@ -143,10 +143,10 @@ def show_tracemalloc_diff(snapshot1, snapshot2):
def test_4125():
if os.environ.get('PYMUPDF_RUNNING_ON_VALGRIND') == '1':
- print(f'test_4125(): not running because PYMUPDF_RUNNING_ON_VALGRIND=1.')
+ print('test_4125(): not running because PYMUPDF_RUNNING_ON_VALGRIND=1.')
return
if platform.system().startswith('MSYS_NT-'):
- print(f'test_4125(): not running on msys2 - psutil not available.')
+ print('test_4125(): not running on msys2 - psutil not available.')
return
print('')
@@ -219,4 +219,4 @@ def get_stat():
# to vary a lot, which causes spurious test failures. So for at least
# we don't actually check.
#
- print(f'Not checking results because non-Linux behaviour is too variable.')
+ print('Not checking results because non-Linux behaviour is too variable.')
diff --git a/tests/test_named_links.py b/tests/test_named_links.py
index 0ff070da4..bd5b30616 100644
--- a/tests/test_named_links.py
+++ b/tests/test_named_links.py
@@ -6,7 +6,7 @@
def test_2886():
"""Confirm correct insertion of a 'named' link."""
if not hasattr(pymupdf, "mupdf"):
- print(f"test_2886(): not running on classic.")
+ print("test_2886(): not running on classic.")
return
path = os.path.abspath(f"{__file__}/../../tests/resources/cython.pdf")
@@ -39,7 +39,7 @@ def test_2922():
"nameddest" instead.
"""
if not hasattr(pymupdf, "mupdf"):
- print(f"test_2922(): not running on classic.")
+ print("test_2922(): not running on classic.")
return
path = os.path.abspath(f"{__file__}/../../tests/resources/cython.pdf")
@@ -68,7 +68,7 @@ def test_3301():
is converted to a URI if not explicitly starting with "file://".
"""
if not hasattr(pymupdf, "mupdf"):
- print(f"test_3301(): not running on classic.")
+ print("test_3301(): not running on classic.")
return
# list of links and their expected link "kind" upon extraction
diff --git a/tests/test_pixmap.py b/tests/test_pixmap.py
index 08556363a..45ca1373b 100644
--- a/tests/test_pixmap.py
+++ b/tests/test_pixmap.py
@@ -329,7 +329,7 @@ def run_code(code, code_path, *, check=True, venv=None, venv_args='', pythonpath
stdout=subprocess.PIPE,
)
if r.returncode:
- print(f'test_3493(): Not running test because --system-site-packages venv cannot import gi.')
+ print('test_3493(): Not running test because --system-site-packages venv cannot import gi.')
return
gi = r.stdout.strip()
gi_pythonpath = os.path.abspath(f'{gi}/../..')
@@ -373,7 +373,7 @@ def do(gi):
def test_3848():
if os.environ.get('PYMUPDF_RUNNING_ON_VALGRIND') == '1':
# Takes 40m on Github.
- print(f'test_3848(): not running on valgrind because very slow.', flush=1)
+ print('test_3848(): not running on valgrind because very slow.', flush=1)
return
path = os.path.normpath(f'{__file__}/../../tests/resources/test_3848.pdf')
with pymupdf.open(path) as document:
@@ -462,7 +462,7 @@ def test_4155():
print(f'Received exception: {e}')
assert 'operation forbidden on released memoryview object' in str(e)
else:
- assert 0, f'Did not receive expected exception when using defunct memoryview.'
+ assert 0, 'Did not receive expected exception when using defunct memoryview.'
def test_4336():
@@ -492,7 +492,7 @@ def test_4336():
venv = os.path.normpath(f'{__file__}/../../tests/resources/test_4336_venv')
command = f'{sys.executable} -m venv {venv}'
command += f' && . {venv}/bin/activate'
- command += f' && pip install --force-reinstall pymupdf==1.23.8'
+ command += ' && pip install --force-reinstall pymupdf==1.23.8'
command += f' && python {path_code}'
print(f'Running: {command}', flush=1)
subprocess.run(command, shell=1, check=1)
@@ -517,9 +517,9 @@ def test_4435():
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4435.pdf')
with pymupdf.open(path) as document:
page = document[2]
- print(f'Calling page.get_pixmap().', flush=1)
+ print('Calling page.get_pixmap().', flush=1)
pixmap = page.get_pixmap(alpha=False, dpi=120)
- print(f'Called page.get_pixmap().', flush=1)
+ print('Called page.get_pixmap().', flush=1)
wt = pymupdf.TOOLS.mupdf_warnings()
assert wt == 'bogus font ascent/descent values (0 / 0)\n... repeated 9 times...'
@@ -543,7 +543,7 @@ def test_4423():
ee = e
if (1, 25, 5) <= pymupdf.mupdf_version_tuple < (1, 26):
- assert ee, f'Did not receive the expected exception.'
+ assert ee, 'Did not receive the expected exception.'
wt = pymupdf.TOOLS.mupdf_warnings()
assert wt == 'dropping unclosed output'
else:
diff --git a/tests/test_pylint.py b/tests/test_pylint.py
index 0f0c40fa9..5c388be38 100644
--- a/tests/test_pylint.py
+++ b/tests/test_pylint.py
@@ -8,7 +8,7 @@
def test_pylint():
if not hasattr(pymupdf, 'mupdf'):
- print(f'test_pylint(): Not running with classic implementation.')
+ print('test_pylint(): Not running with classic implementation.')
return
ignores = ''
diff --git a/tests/test_story.py b/tests/test_story.py
index 1f1f1b396..999f7ee53 100644
--- a/tests/test_story.py
+++ b/tests/test_story.py
@@ -103,7 +103,7 @@ def make_pdf(html, path_out):
def test_fit_springer():
if not hasattr(pymupdf, 'mupdf'):
- print(f'test_fit_springer(): not running on classic.')
+ print('test_fit_springer(): not running on classic.')
return
verbose = 0
@@ -178,7 +178,7 @@ def contentfn(positions):
ret += f' \n')
f.write(f'
\n')
- f.write(f'/\n')
- f.write(f'\n')
+ f.write('Extension/magic')
- f.write(f' Data file ')
+ f.write(' \n')
- f.write(f'Data file ')
for ext in extensions:
f.write(f'{ext} ')
f.write('\n')
@@ -1545,9 +1545,9 @@ def dict_set_path(dict_, *items):
f.write(f'file: {b1}{text_file}{b2} ')
f.write('
')
f.write(f'stream: {b1}{text_stream}{b2}First section
diff --git a/tests/test_tesseract.py b/tests/test_tesseract.py
index c3c9f7283..269bfd57f 100644
--- a/tests/test_tesseract.py
+++ b/tests/test_tesseract.py
@@ -29,7 +29,7 @@ def test_tesseract():
# 2023-12-12: For some reason the SWIG catch code only catches
# the exception as FzErrorBase.
e_expected_type = pymupdf.mupdf.FzErrorBase
- print(f'OpenBSD workaround - expecting FzErrorBase, not FzErrorLibrary.')
+ print('OpenBSD workaround - expecting FzErrorBase, not FzErrorLibrary.')
else:
e_expected_type = pymupdf.mupdf.FzErrorLibrary
else:
@@ -39,13 +39,13 @@ def test_tesseract():
tessdata_prefix = os.environ.get('TESSDATA_PREFIX')
if tessdata_prefix:
tp = page.get_textpage_ocr(full=True)
- print(f'test_tesseract(): page.get_textpage_ocr() succeeded')
+ print('test_tesseract(): page.get_textpage_ocr() succeeded')
else:
try:
tp = page.get_textpage_ocr(full=True, tessdata='/foo/bar')
except Exception as e:
e_text = str(e)
- print(f'Received exception as expected.')
+ print('Received exception as expected.')
print(f'{type(e)=}')
print(f'{e_text=}')
assert e_text == e_expected, f'Unexpected exception: {e_text!r}'
diff --git a/tests/test_textbox.py b/tests/test_textbox.py
index d8003624d..a3222f573 100644
--- a/tests/test_textbox.py
+++ b/tests/test_textbox.py
@@ -284,5 +284,5 @@ def test_4400():
page = document.new_page()
writer = pymupdf.TextWriter(page.rect)
text = '111111111'
- print(f'Calling writer.fill_textbox().', flush=1)
+ print('Calling writer.fill_textbox().', flush=1)
writer.fill_textbox(rect=pymupdf.Rect(0, 0, 100, 20), pos=(80, 0), text=text, fontsize=8)
diff --git a/tests/test_textextract.py b/tests/test_textextract.py
index 60368441b..9c54cc25e 100644
--- a/tests/test_textextract.py
+++ b/tests/test_textextract.py
@@ -551,7 +551,7 @@ def test_4179():
# Looks like Python code doesn't behave same as C++, probably because
# of the code not being correct for Python's native unicode strings.
#
- print(f'test_4179(): Not running with PYMUPDF_USE_EXTRA=0 because known to fail.')
+ print('test_4179(): Not running with PYMUPDF_USE_EXTRA=0 because known to fail.')
return
# We check that using TEXT_ACCURATE_BBOXES gives the correct boxes. But
# this also requires that we disable PyMuPDF quad corrections.
@@ -736,18 +736,18 @@ def test_extendable_textpage():
text_page = pymupdf.TextPage(stext_page)
# Read text from stext_page using text_page.extractDICT().
- print(f'Using text_page.extractDICT().')
+ print('Using text_page.extractDICT().')
print(f'{text_page.this.m_internal.mediabox=}')
d = text_page.extractDICT(sort=True)
y0_prev = None
pno = 0
ydelta = 0
for block in d['blocks']:
- print(f'block')
+ print('block')
for line in block['lines']:
- print(f' line')
+ print(' line')
for span in line['spans']:
- print(f' span')
+ print(' span')
bbox = span['bbox']
x0, y0, x1, y1 = bbox
dy = y0 - y0_prev if y0_prev else 0
@@ -762,21 +762,21 @@ def test_extendable_textpage():
print('\n\n\n\n')
- print(f'Using text_page.extractText()')
+ print('Using text_page.extractText()')
text = text_page.extractText(True)
print(f'{text}')
print('\n\n\n\n')
- print(f'Using extractBLOCKS')
+ print('Using extractBLOCKS')
text = list()
for x0, y0, x1, y1, line, no, type_ in text_page.extractBLOCKS():
- print(f'block:')
+ print('block:')
print(f' bbox={x0, y0, x1, y1} {no=}')
print(f' {line=}')
text.append(line)
print("\n\n\n")
- print(f'extractBLOCKS joined by newlines:')
+ print('extractBLOCKS joined by newlines:')
print('\n'.join(text))
# This checks that lines before/after pages break are treated as a
diff --git a/tests/test_toc.py b/tests/test_toc.py
index bad82c7ef..fdf5cdd41 100644
--- a/tests/test_toc.py
+++ b/tests/test_toc.py
@@ -29,7 +29,7 @@ def test_simple_toc():
def test_full_toc():
if not hasattr(pymupdf, "mupdf"):
# Classic implementation does not have fix for this test.
- print(f"Not running test_full_toc on classic implementation.")
+ print("Not running test_full_toc on classic implementation.")
return
expected_path = f"{scriptdir}/resources/full_toc.txt"
expected = pathlib.Path(expected_path).read_bytes()
@@ -109,7 +109,7 @@ def test_2788():
'''
if not hasattr(pymupdf, 'mupdf'):
# Classic implementation does not have fix for this test.
- print(f'Not running test_2788 on classic implementation.')
+ print('Not running test_2788 on classic implementation.')
return
path = os.path.abspath(f'{__file__}/../../tests/resources/test_2788.pdf')
document = pymupdf.open(path)
diff --git a/tests/util.py b/tests/util.py
index dbb246581..9cddbf51e 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -16,7 +16,7 @@ def download(url, name, size=None):
print(f'Using existing file {path=}.')
else:
print(f'Downloading from {url=}.')
- subprocess.run(f'pip install -U requests', check=1, shell=1)
+ subprocess.run('pip install -U requests', check=1, shell=1)
import requests
r = requests.get(url, path, timeout=10)
r.raise_for_status()
diff --git a/wdev.py b/wdev.py
index d2d1c86ac..887b531c5 100644
--- a/wdev.py
+++ b/wdev.py
@@ -89,7 +89,7 @@ def default(value, name):
# We use r'...' for regex strings because an extra level of escaping is
# required for backslashes.
#
- regex = rf'^C:\\Program Files.*\\Microsoft Visual Studio\\([^\\]+)\\([^\\]+)'
+ regex = r'^C:\\Program Files.*\\Microsoft Visual Studio\\([^\\]+)\\([^\\]+)'
m = re.match( regex, directory)
assert m, f'No match: {regex=} {directory=}'
year2 = m.group(1)
@@ -167,7 +167,7 @@ def default(value, name):
self.year = year
self.cpu = cpu
except Exception as e:
- raise Exception( f'Unable to find Visual Studio') from e
+ raise Exception( 'Unable to find Visual Studio') from e
def description_ml( self, indent=''):
'''