diff --git a/.github/workflows/ci-linux-ubuntu-latest.yml b/.github/workflows/ci-linux-ubuntu-latest.yml index 4a5230c..b269640 100644 --- a/.github/workflows/ci-linux-ubuntu-latest.yml +++ b/.github/workflows/ci-linux-ubuntu-latest.yml @@ -1,4 +1,4 @@ -name: "HTML2PDF on Linux" +name: "HTML2PDF4Doc on Linux" on: pull_request: @@ -30,7 +30,7 @@ jobs: run: | pip install -r requirements.development.txt - - name: Clone HTML2PDF.js + - name: Clone HTML2PDF4Doc.js run: | invoke bootstrap env: @@ -38,13 +38,13 @@ jobs: - name: Install HPDF dependencies. run: | - python developer/pip_install_html2print_deps.py + python developer/pip_install_html2pdf4doc_deps.py - name: Run Lint tasks run: | invoke lint - - name: Build HTML2PDF.js + - name: Build HTML2PDF4Doc.js run: | invoke build diff --git a/.github/workflows/ci-mac.yml b/.github/workflows/ci-mac.yml index 5a84528..2fedfa5 100644 --- a/.github/workflows/ci-mac.yml +++ b/.github/workflows/ci-mac.yml @@ -1,4 +1,4 @@ -name: "HTML2PDF on macOS" +name: "HTML2PDF4Doc on macOS" on: pull_request: @@ -30,19 +30,19 @@ jobs: run: | pip install -r requirements.development.txt - - name: Clone HTML2PDF.js + - name: Clone HTML2PDF4Doc.js run: | invoke bootstrap - name: Install HPDF dependencies. run: | - python developer/pip_install_html2print_deps.py + python developer/pip_install_html2pdf4doc_deps.py - name: Run Lint tasks run: | invoke lint - - name: Build HTML2PDF.js + - name: Build HTML2PDF4Doc.js run: | invoke build diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 90e30b3..b66d1ef 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -1,6 +1,6 @@ # NOTE: In contrast to Linux and macOS, the Windows build machines do not have Chrome installed. -name: "HTML2PDF on Windows" +name: "HTML2PDF4Doc on Windows" on: pull_request: @@ -39,25 +39,25 @@ jobs: run: | pip install -r requirements.development.txt - - name: Clone HTML2PDF.js + - name: Clone HTML2PDF4Doc.js run: | invoke bootstrap - name: Install HPDF dependencies. run: | - python developer/pip_install_html2print_deps.py + python developer/pip_install_html2pdf4doc_deps.py - name: Run Lint tasks run: | invoke lint - - name: Build HTML2PDF.js + - name: Build HTML2PDF4Doc.js run: | invoke build - name: Download ChromeDriver run: | - python html2print/html2print.py get_driver + python html2pdf4doc/html2pdf4doc.py get_driver - name: Run tests (Bash) run: | diff --git a/.gitignore b/.gitignore index ff8b010..8e088d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -# HTML2PDF JS file. -# html2print/html2pdf_js/ +# HTML2PDF4Doc JS file. +# html2pdf4doc/html2pdf4doc_js/ .idea/ **/.wdm/ diff --git a/Dockerfile b/Dockerfile index f2e1718..d69ef43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,15 +27,15 @@ ENV PATH="/opt/venv/bin:$PATH" # Install StrictDoc. Set default StrictDoc installation from PyPI but allow # overriding it with an environment variable. -ARG HTML2PRINT_SOURCE="pypi" -ENV HTML2PRINT_SOURCE=${HTML2PRINT_SOURCE} +ARG HTML2PDF4DOC_SOURCE="pypi" +ENV HTML2PDF4DOC_SOURCE=${HTML2PDF4DOC_SOURCE} -RUN if [ "$HTML2PRINT_SOURCE" = "pypi" ]; then \ +RUN if [ "$HTML2PDF4DOC_SOURCE" = "pypi" ]; then \ pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir html2print; \ + pip install --no-cache-dir html2pdf4doc; \ else \ pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir git+https://github.com/mettta/html2pdf_python.git@${HTML2PRINT_SOURCE}; \ + pip install --no-cache-dir git+https://github.com/mettta/html2pdf_python.git@${HTML2PDF4DOC_SOURCE}; \ fi; \ chmod -R 777 /opt/venv; diff --git a/developer/pip_install_html2print_deps.py b/developer/pip_install_html2pdf4doc_deps.py similarity index 86% rename from developer/pip_install_html2print_deps.py rename to developer/pip_install_html2pdf4doc_deps.py index 9733170..e313f96 100644 --- a/developer/pip_install_html2print_deps.py +++ b/developer/pip_install_html2pdf4doc_deps.py @@ -29,7 +29,7 @@ def check_if_package_installed(package_name: str): print( # noqa: T201 - "pip_install_html2print_deps.py: " + "pip_install_html2pdf4doc_deps.py: " "checking if the current Python environment has all packages installed" ".", flush=True, @@ -48,7 +48,7 @@ def check_if_package_installed(package_name: str): check_if_package_installed(dependency) except PackageNotFound: print( # noqa: T201 - f"pip_install_html2print_deps.py: " + f"pip_install_html2pdf4doc_deps.py: " f"Package is not installed: '{dependency}'.", flush=True, ) @@ -57,8 +57,8 @@ def check_if_package_installed(package_name: str): except PackageVersionConflict as exception_: print( # noqa: T201 ( - f"pip_install_html2print_deps.py: version conflict between " - f"html2print's requirement '{dependency}' " + f"pip_install_html2pdf4doc_deps.py: version conflict between " + f"html2pdf4doc's requirement '{dependency}' " f"and the already installed package: " f"{exception_.args[0]}." ), @@ -69,13 +69,13 @@ def check_if_package_installed(package_name: str): if not needs_installation: print( # noqa: T201 - "pip_install_html2print_deps.py: all packages seem to be installed.", + "pip_install_html2pdf4doc_deps.py: all packages seem to be installed.", flush=True, ) sys.exit(0) print( # noqa: T201 - "pip_install_html2print_deps.py: will install packages.", flush=True + "pip_install_html2pdf4doc_deps.py: will install packages.", flush=True ) all_packages = "\n".join(dependencies) + "\n" diff --git a/entrypoint.sh b/entrypoint.sh index 86b2ddf..eb0d959 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -15,41 +15,41 @@ if [ -z "$HOST_UID" ] || [ -z "$HOST_GID" ]; then exit 1 fi -echo "html2print/docker: running a Docker container entrypoint." -echo "html2print/docker: ensuring html2print user with UID=$HOST_UID and GID=$HOST_GID exists" +echo "html2pdf4doc/docker: running a Docker container entrypoint." +echo "html2pdf4doc/docker: ensuring html2pdf4doc user with UID=$HOST_UID and GID=$HOST_GID exists" # Check if a user with this UID already exists (e.g., "ubuntu") EXISTING_USER=$(getent passwd "$HOST_UID" | cut -d: -f1) if [ -n "$EXISTING_USER" ]; then - echo "error: html2print/docker: detected a wrong user: '$EXISTING_USER'. Ensure that any default users are removed from the Dockerfile. This entrypoint script is supposed to create a new user 'html2print'." + echo "error: html2pdf4doc/docker: detected a wrong user: '$EXISTING_USER'. Ensure that any default users are removed from the Dockerfile. This entrypoint script is supposed to create a new user 'html2pdf4doc'." exit 1 else # Ensure the group exists. EXISTING_GROUP=$(getent group "$HOST_GID" | cut -d: -f1) if [ -z "$EXISTING_GROUP" ]; then - echo "html2print/docker: creating new group html2print with GID=$HOST_GID" - groupadd -g "$HOST_GID" html2print + echo "html2pdf4doc/docker: creating new group html2pdf4doc with GID=$HOST_GID" + groupadd -g "$HOST_GID" html2pdf4doc else - echo "html2print/docker: group with GID=$HOST_GID already exists: $EXISTING_GROUP, reusing it." + echo "html2pdf4doc/docker: group with GID=$HOST_GID already exists: $EXISTING_GROUP, reusing it." fi # Create the user. - echo "html2print/docker: creating new user html2print with UID=$HOST_UID" - useradd -m -u "$HOST_UID" -g "$HOST_GID" -s /bin/bash html2print + echo "html2pdf4doc/docker: creating new user html2pdf4doc with UID=$HOST_UID" + useradd -m -u "$HOST_UID" -g "$HOST_GID" -s /bin/bash html2pdf4doc # Give the user root privileges. Useful for debugging. - echo "html2print ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/html2print + echo "html2pdf4doc ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/html2pdf4doc fi -echo "html2print/docker: show created user info:" -id html2print +echo "html2pdf4doc/docker: show created user info:" +id html2pdf4doc # Run as the correct user. If no command is provided, run a shell. if [ $# -eq 0 ]; then - echo "html2print/docker: no command provided, opening an interactive shell." - exec gosu html2print /bin/bash + echo "html2pdf4doc/docker: no command provided, opening an interactive shell." + exec gosu html2pdf4doc /bin/bash else # Otherwise, run the provided command. - exec gosu html2print "$@" + exec gosu html2pdf4doc "$@" fi diff --git a/html2print/html2print.py b/html2pdf4doc/html2pdf4doc.py similarity index 85% rename from html2print/html2print.py rename to html2pdf4doc/html2pdf4doc.py index ad5d878..36fc993 100644 --- a/html2print/html2print.py +++ b/html2pdf4doc/html2pdf4doc.py @@ -21,15 +21,17 @@ __version__ = "0.0.17" -PATH_TO_HTML2PDF_JS = os.path.join( - os.path.dirname(os.path.join(__file__)), "html2pdf_js", "html2pdf.min.js" +PATH_TO_HTML2PDF4DOC_JS = os.path.join( + os.path.dirname(os.path.join(__file__)), + "html2pdf4doc_js", + "html2pdf4doc.min.js", ) -DEFAULT_CACHE_DIR = os.path.join(Path.home(), ".html2print", "chromedriver") +DEFAULT_CACHE_DIR = os.path.join(Path.home(), ".html2pdf4doc", "chromedriver") PATH_TO_CHROME_DRIVER_DEBUG_LOG = "/tmp/chromedriver.log" -# HTML2PDF.js prints unicode symbols to console. The following makes it work on +# HTML2PDF4Doc.js prints unicode symbols to console. The following makes it work on # Windows which otherwise complains: # UnicodeEncodeError: 'charmap' codec can't encode characters in position 129-130: character maps to # How to make python 3 print() utf8 @@ -44,14 +46,14 @@ def get_chrome_driver(self, path_to_cache_dir: str) -> str: # If Web Driver Manager cannot detect Chrome, it returns None. if chrome_version is None: raise RuntimeError( - "html2print: " + "html2pdf4doc: " "Web Driver Manager could not detect an existing Chrome installation." ) chrome_major_version = chrome_version.split(".")[0] print( # noqa: T201 - f"html2print: Installed Chrome version: {chrome_version}" + f"html2pdf4doc: Installed Chrome version: {chrome_version}" ) system_map = { @@ -65,7 +67,7 @@ def get_chrome_driver(self, path_to_cache_dir: str) -> str: is_windows = platform.system() == "Windows" print( # noqa: T201 - f"html2print: OS system: {platform.system()}, OS type: {os_type}." + f"html2pdf4doc: OS system: {platform.system()}, OS type: {os_type}." ) path_to_cached_chrome_driver_dir = os.path.join( @@ -81,12 +83,12 @@ def get_chrome_driver(self, path_to_cache_dir: str) -> str: if os.path.isfile(path_to_cached_chrome_driver): print( # noqa: T201 - f"html2print: ChromeDriver exists in the local cache: " + f"html2pdf4doc: ChromeDriver exists in the local cache: " f"{path_to_cached_chrome_driver}" ) return path_to_cached_chrome_driver print( # noqa: T201 - f"html2print: ChromeDriver does not exist in the local cache: " + f"html2pdf4doc: ChromeDriver does not exist in the local cache: " f"{path_to_cached_chrome_driver}" ) @@ -149,7 +151,7 @@ def _download_chromedriver( ) print( # noqa: T201 - f"html2print: downloading ChromeDriver from: {driver_url}" + f"html2pdf4doc: downloading ChromeDriver from: {driver_url}" ) response = ChromeDriverManager.send_http_get_request(driver_url) @@ -161,7 +163,7 @@ def _download_chromedriver( Path(path_to_driver_cache_dir).mkdir(parents=True, exist_ok=True) zip_path = os.path.join(path_to_driver_cache_dir, "chromedriver.zip") print( # noqa: T201 - f"html2print: saving downloaded ChromeDriver to path: {zip_path}" + f"html2pdf4doc: saving downloaded ChromeDriver to path: {zip_path}" ) with open(zip_path, "wb") as file: file.write(response.content) @@ -170,7 +172,7 @@ def _download_chromedriver( zip_ref.extractall(path_to_driver_cache_dir) print( # noqa: T201 - f"html2print: ChromeDriver downloaded to: {path_to_cached_chrome_driver}" + f"html2pdf4doc: ChromeDriver downloaded to: {path_to_cached_chrome_driver}" ) return path_to_cached_chrome_driver @@ -179,7 +181,7 @@ def send_http_get_request(url: str) -> Response: last_error: Optional[Exception] = None for attempt in range(1, 4): print( # noqa: T201 - f"html2print: sending GET request attempt {attempt}: {url}" + f"html2pdf4doc: sending GET request attempt {attempt}: {url}" ) try: return requests.get(url, timeout=(5, 5)) @@ -189,10 +191,10 @@ def send_http_get_request(url: str) -> Response: last_error = read_timeout_ except Exception as exception_: raise AssertionError( - "html2print: unknown exception", exception_ + "html2pdf4doc: unknown exception", exception_ ) from None print( # noqa: T201 - f"html2print: " + f"html2pdf4doc: " f"failed to get response for URL: {url} with error: {last_error}" ) raise RuntimeError( @@ -210,7 +212,7 @@ def get_chrome_version() -> Optional[str]: chrome_path = "/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing" try: print( # noqa: T201 - "html2print: " + "html2pdf4doc: " "checking if there is Google Chrome for Testing instead of " "a normal Chrome available." ) @@ -231,15 +233,15 @@ def get_chrome_version() -> Optional[str]: chrome_version = match.group(0) print( # noqa: T201 - f"html2print: Google Chrome for Testing Version: {chrome_version}" + f"html2pdf4doc: Google Chrome for Testing Version: {chrome_version}" ) return chrome_version except FileNotFoundError: - print("html2print: Chrome for Testing not available.") # noqa: T201 + print("html2pdf4doc: Chrome for Testing not available.") # noqa: T201 except Exception as e: print( # noqa: T201 - f"html2print: Error getting Google Chrome for Testing version: {e}" + f"html2pdf4doc: Error getting Google Chrome for Testing version: {e}" ) os_manager = OperationSystemManager(os_type=None) # type: ignore[no-untyped-call] @@ -252,7 +254,7 @@ def get_inches_from_millimeters(mm: float) -> float: def get_pdf_from_html(driver: webdriver.Chrome, url: str) -> bytes: - print(f"html2print: opening URL with ChromeDriver: {url}") # noqa: T201 + print(f"html2pdf4doc: opening URL with ChromeDriver: {url}") # noqa: T201 driver.get(url) @@ -293,7 +295,7 @@ class Done(Exception): logs = driver.get_log("browser") # type: ignore[no-untyped-call] for entry_ in logs: if "[HTML2PDF4DOC] Total time:" in entry_["message"]: - print("success: HTML2PDF completed its job.") # noqa: T201 + print("success: HTML2PDF4Doc completed its job.") # noqa: T201 raise Done if (datetime.today() - datetime_start).total_seconds() > 60: raise TimeoutError @@ -302,11 +304,12 @@ class Done(Exception): pass except TimeoutError: print( # noqa: T201 - "error: could not receive a successful completion status from HTML2PDF." + "error: html2pdf4doc: " + "could not receive a successful completion status from HTML2PDF4Doc." ) sys.exit(1) - print("html2print: JS logs from the print session:") # noqa: T201 + print("html2pdf4doc: JS logs from the print session:") # noqa: T201 print('"""') # noqa: T201 for entry in logs: print(entry) # noqa: T201 @@ -315,7 +318,7 @@ class Done(Exception): # # Execute Print command with ChromeDriver. # - print("html2print: executing print command with ChromeDriver.") # noqa: T201 + print("html2pdf4doc: executing print command with ChromeDriver.") # noqa: T201 result = driver.execute_cdp_cmd("Page.printToPDF", calculated_print_options) data = base64.b64decode(result["data"]) @@ -328,7 +331,7 @@ def create_webdriver( page_load_timeout: int, debug: bool = False, ) -> webdriver.Chrome: - print("html2print: creating ChromeDriver service.", flush=True) # noqa: T201 + print("html2pdf4doc: creating ChromeDriver service.", flush=True) # noqa: T201 path_to_chrome_driver: str if chromedriver_argument is None: @@ -338,7 +341,7 @@ def create_webdriver( else: path_to_chrome_driver = chromedriver_argument print( # noqa: T201 - f"html2print: ChromeDriver available at path: {path_to_chrome_driver}" + f"html2pdf4doc: ChromeDriver available at path: {path_to_chrome_driver}" ) if debug: @@ -383,7 +386,7 @@ def create_webdriver( # Enable the capturing of everything in JS console. webdriver_options.set_capability("goog:loggingPrefs", {"browser": "ALL"}) - print("html2print: creating ChromeDriver.", flush=True) # noqa: T201 + print("html2pdf4doc: creating ChromeDriver.", flush=True) # noqa: T201 driver = webdriver.Chrome( options=webdriver_options, @@ -395,13 +398,14 @@ def create_webdriver( def main() -> None: - if not os.path.isfile(PATH_TO_HTML2PDF_JS): + if not os.path.isfile(PATH_TO_HTML2PDF4DOC_JS): raise RuntimeError( - f"Corrupted html2print package bundle. " - f"The HTML2PDF.js file is missing at path: {PATH_TO_HTML2PDF_JS}." + f"Corrupted html2pdf4doc package bundle. " + f"The html2pdf4doc JS file is missing at path: " + f"{PATH_TO_HTML2PDF4DOC_JS}." ) - parser = argparse.ArgumentParser(description="HTML2Print printer script.") + parser = argparse.ArgumentParser(description="html2pdf4doc printer script.") parser.add_argument( "-v", "--version", action="version", version=__version__ @@ -410,7 +414,7 @@ def main() -> None: command_subparsers = parser.add_subparsers(title="command", dest="command") command_subparsers.required = True - print(f"html2print: version {__version__}") # noqa: T201 + print(f"html2pdf4doc: version {__version__}") # noqa: T201 # # Get driver command. @@ -451,10 +455,10 @@ def main() -> None: # 10 minutes should be enough to print even the largest documents. choices=range(0, 10 * 60), help=( - "How long shall HTML2Print wait while the Chrome Driver is printing " - "a given HTML page to PDF. " + "How long shall html2pdf4doc Python driver wait while the " + "Chrome Driver is printing a given HTML page to PDF. " "This is mainly driven by the time it takes for Chrome to open an " - "HTML file, load it, and let HTML2PDF.js finish its job." + "HTML file, load it, and let HTML2PDF4Doc.js finish its job." ), ) command_parser_print.add_argument( @@ -480,7 +484,7 @@ def main() -> None: path_to_chrome = ChromeDriverManager().get_chrome_driver( path_to_cache_dir ) - print(f"html2print: ChromeDriver available at path: {path_to_chrome}") # noqa: T201 + print(f"html2pdf4doc: ChromeDriver available at path: {path_to_chrome}") # noqa: T201 sys.exit(0) elif args.command == "print": @@ -500,7 +504,7 @@ def main() -> None: @atexit.register def exit_handler() -> None: - print("html2print: exit handler: quitting the ChromeDriver.") # noqa: T201 + print("html2pdf4doc: exit handler: quitting the ChromeDriver.") # noqa: T201 driver.quit() assert len(paths) % 2 == 0, ( @@ -521,7 +525,7 @@ def exit_handler() -> None: with open(path_to_output_pdf, "wb") as f: f.write(pdf_bytes) else: - print("html2print: unknown command.") # noqa: T201 + print("html2pdf4doc: unknown command.") # noqa: T201 sys.exit(1) diff --git a/html2print/html2pdf_js/html2pdf.min.js b/html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js similarity index 100% rename from html2print/html2pdf_js/html2pdf.min.js rename to html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js diff --git a/pyproject.toml b/pyproject.toml index 7ac79bd..4af7105 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,17 +3,18 @@ requires = ["hatchling"] build-backend = "hatchling.build" [tool.hatch.version] -path = "html2print/html2print.py" +path = "html2pdf4doc/html2pdf4doc.py" [tool.hatch.build] -# We want HTML2PDF.js to be gitignored, but we want it to make into the dist/ +# Currently unused: +# We want html2pdf4doc.min.js to be gitignored, but we want it to make into the dist/ # folder, into both tar.gz and .whl when the Pip package is built. # This option prevents Hatch from using .gitignore to exclude files. -ignore-vcs = true +# ignore-vcs = true include = [ - "html2print/html2print.py", - "html2print/html2pdf_js/html2pdf.min.js", + "html2pdf4doc/html2pdf4doc.py", + "html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js", ] exclude = [ @@ -22,9 +23,9 @@ exclude = [ ] [project] -name = "html2print" +name = "html2pdf4doc" dynamic = ["version"] -description = "Python client for HTML2PDF JavaScript library." +description = "Python client for HTML2PDF4Doc JavaScript library." readme = "README.md" # https://github.com/pypa/twine/issues/1216 license-files is broken as of 2025-02-03 # Using [] as a suggested workaround. @@ -36,7 +37,7 @@ authors = [ { name = "Maryna Balioura", email = "mettta@gmail.com" }, ] classifiers = [ - # "License :: OSI Approved :: BSD License", + "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", @@ -48,11 +49,12 @@ classifiers = [ ] dependencies = [ - # HTML2PDF dependencies "selenium", + + # Currently only used for detecting a local Chrome installation. "webdriver-manager", - # requests is used by HTML2PDF_HTTPClient. + # requests is used for downloading the Chrome driver. "requests", ] @@ -64,7 +66,7 @@ development = [ ] [project.scripts] -html2print = "html2print.html2print:main" +html2pdf4doc = "html2pdf4doc.html2pdf4doc:main" [project.urls] Changelog = "https://github.com/mettta/html2pdf_python/releases/" diff --git a/tasks.py b/tasks.py index 86a6162..9707cd9 100644 --- a/tasks.py +++ b/tasks.py @@ -65,17 +65,17 @@ def build(context): context, "cd submodules/html2pdf && npm install && npm run build" ) # Windows can't do slashes for this one. - if not os.path.isdir(os.path.join("html2print", "html2pdf_js")): + if not os.path.isdir(os.path.join("html2pdf4doc", "html2pdf4doc_js")): run_invoke( context, """ - cd html2print && mkdir html2pdf_js + cd html2pdf4doc && mkdir html2pdf4doc_js """, ) run_invoke( context, """ - cp submodules/html2pdf/dist/bundle.js html2print/html2pdf_js/html2pdf.min.js + cp submodules/html2pdf/dist/bundle.js html2pdf4doc/html2pdf4doc_js/html2pdf4doc.min.js """, ) @@ -99,7 +99,7 @@ def get_chrome_driver( run_invoke( context, """ - python html2print/html2print.py get_driver + python html2pdf4doc/html2pdf4doc.py get_driver """, ) @@ -112,7 +112,7 @@ def lint_ruff_format(context): ruff format *.py - html2print/ + html2pdf4doc/ tests/integration/ """, ) @@ -128,7 +128,7 @@ def lint_ruff(context): run_invoke( context, """ - ruff check *.py html2print/ --fix --cache-dir build/ruff + ruff check *.py html2pdf4doc/ --fix --cache-dir build/ruff """, ) @@ -141,7 +141,7 @@ def lint_mypy(context): run_invoke( context, """ - mypy html2print/ + mypy html2pdf4doc/ --show-error-codes --disable-error-code=import --disable-error-code=misc @@ -171,7 +171,7 @@ def test_integration( cwd = os.getcwd() - html2pdf_exec = f'python3 \\"{cwd}/html2print/html2print.py\\"' + html2pdf_exec = f'python3 \\"{cwd}/html2pdf4doc/html2pdf4doc.py\\"' focus_or_none = f"--filter {focus}" if focus else "" debug_opts = "-vv --show-all" if debug else "" @@ -182,7 +182,7 @@ def test_integration( itest_command = f""" lit --threads 1 - --param HTML2PRINT_EXEC="{html2pdf_exec}" + --param HTML2PDF4DOC_EXEC="{html2pdf_exec}" -v {debug_opts} {focus_or_none} @@ -236,8 +236,8 @@ def package(context): def release(context, test_pypi=False, username=None, password=None): """ A release can be made to PyPI or test package index (TestPyPI): - https://pypi.org/project/html2print/ - https://test.pypi.org/project/html2print/ + https://pypi.org/project/html2pdf4doc/ + https://test.pypi.org/project/html2pdf4doc/ """ # When a username is provided, we also need password, and then we don't use @@ -250,9 +250,9 @@ def release(context, test_pypi=False, username=None, password=None): "" if username else ( - "--repository html2print_test" + "--repository html2pdf4doc_test" if test_pypi - else "--repository html2print_release" + else "--repository html2pdf4doc_release" ) ) user_password = f"-u{username} -p{password}" if username is not None else "" @@ -263,7 +263,7 @@ def release(context, test_pypi=False, username=None, password=None): run_invoke( context, f""" - twine upload dist/html2print-*.tar.gz + twine upload dist/html2pdf4doc-*.tar.gz {repository_argument_or_none} {user_password} """, @@ -273,7 +273,7 @@ def release(context, test_pypi=False, username=None, password=None): @task(aliases=["bd"]) def build_docker( context, - image: str = "html2print:latest", + image: str = "html2pdf4doc:latest", no_cache: bool = False, source="pypi", ): @@ -282,7 +282,7 @@ def build_docker( context, f""" docker build . - --build-arg HTML2PRINT_SOURCE={source} + --build-arg HTML2PDF4DOC_SOURCE={source} -t {image} {no_cache_argument} """, @@ -291,7 +291,7 @@ def build_docker( @task(aliases=["rd"]) def run_docker( - context, image: str = "html2print:latest", command: Optional[str] = None + context, image: str = "html2pdf4doc:latest", command: Optional[str] = None ): command_argument = ( f'/bin/bash -c "{command}"' if command is not None else "" @@ -301,7 +301,7 @@ def run_docker( context, f""" docker run - --name html2print + --name html2pdf4doc --rm -it -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) @@ -314,7 +314,7 @@ def run_docker( @task(aliases=["td"]) -def test_docker(context, image: str = "html2print:latest"): +def test_docker(context, image: str = "html2pdf4doc:latest"): run_invoke( context, """ @@ -325,6 +325,6 @@ def test_docker(context, image: str = "html2print:latest"): context, image=image, command=( - "cd tests/integration/01_hello_world && html2print print index.html /data/output/index.pdf" + "cd tests/integration/01_hello_world && html2pdf4doc print index.html /data/output/index.pdf" ), ) diff --git a/tests/integration/01_hello_world/index.html b/tests/integration/01_hello_world/index.html index 81a4dc3..6d83ff3 100644 --- a/tests/integration/01_hello_world/index.html +++ b/tests/integration/01_hello_world/index.html @@ -4,7 +4,7 @@ Test page - + diff --git a/tests/integration/02_two_pages/index.html b/tests/integration/02_two_pages/index.html index 383775f..c07d48b 100644 --- a/tests/integration/02_two_pages/index.html +++ b/tests/integration/02_two_pages/index.html @@ -4,7 +4,7 @@ Test page - + diff --git a/tests/integration/03_cache_dir_argument/index.html b/tests/integration/03_cache_dir_argument/index.html index 81a4dc3..6d83ff3 100644 --- a/tests/integration/03_cache_dir_argument/index.html +++ b/tests/integration/03_cache_dir_argument/index.html @@ -4,7 +4,7 @@ Test page - + diff --git a/tests/integration/03_cache_dir_argument/test.itest b/tests/integration/03_cache_dir_argument/test.itest index c4db5fb..b43684f 100644 --- a/tests/integration/03_cache_dir_argument/test.itest +++ b/tests/integration/03_cache_dir_argument/test.itest @@ -2,10 +2,10 @@ RUN: %html2pdf print --cache-dir %S/Output/cache %S/index.html %S/Output/index.p RUN: %check_exists --file "%S/Output/index.pdf" RUN: python %S/test.py -CHECK-RUN1: html2print: ChromeDriver does not exist in the local cache: +CHECK-RUN1: html2pdf4doc: ChromeDriver does not exist in the local cache: RUN: %html2pdf print --cache-dir %S/Output/cache %S/index.html %S/Output/index.pdf | filecheck %s --dump-input=fail --check-prefix CHECK-RUN2 RUN: %check_exists --file "%S/Output/index.pdf" RUN: python %S/test.py -CHECK-RUN2: html2print: ChromeDriver exists in the local cache: +CHECK-RUN2: html2pdf4doc: ChromeDriver exists in the local cache: diff --git a/tests/integration/04_two_documents/index1.html b/tests/integration/04_two_documents/index1.html index 81a4dc3..6d83ff3 100644 --- a/tests/integration/04_two_documents/index1.html +++ b/tests/integration/04_two_documents/index1.html @@ -4,7 +4,7 @@ Test page - + diff --git a/tests/integration/04_two_documents/index2.html b/tests/integration/04_two_documents/index2.html index 81a4dc3..6d83ff3 100644 --- a/tests/integration/04_two_documents/index2.html +++ b/tests/integration/04_two_documents/index2.html @@ -4,7 +4,7 @@ Test page - + diff --git a/tests/integration/05_page_load_timeout/index1.html b/tests/integration/05_page_load_timeout/index1.html index ac8cb15..9c33b4c 100644 --- a/tests/integration/05_page_load_timeout/index1.html +++ b/tests/integration/05_page_load_timeout/index1.html @@ -4,7 +4,7 @@ Test page - + diff --git a/tests/integration/lit.cfg b/tests/integration/lit.cfg index c84db86..10baaed 100644 --- a/tests/integration/lit.cfg +++ b/tests/integration/lit.cfg @@ -4,12 +4,12 @@ import subprocess import lit.formats -config.name = "html2print Python API integration tests" +config.name = "html2pdf4doc Python API integration tests" config.test_format = lit.formats.ShTest("0") current_dir = os.getcwd() -html2pdf_exec = lit_config.params['HTML2PRINT_EXEC'] +html2pdf_exec = lit_config.params['HTML2PDF4DOC_EXEC'] assert(html2pdf_exec) config.substitutions.append(('%project_root', current_dir))