diff --git a/CHANGELOG.md b/CHANGELOG.md index b0518c1..021f2d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to htmltools for Python will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [UNRELEASED] + +* The `HTMLDependency.copy()` method can now correctly copy folders in depenendencies that both include directories and have `all_files=True`. (#87) + ## [0.5.1] 2023-12-18 * `Tag` objects can now be used as context managers, as in `with tags.div():`. When used this way, then inside the `with` block, `sys.displayhook` is replaced with a function which adds items as children to the `Tag`. This is meant to be used with Shiny Express, Quarto, or Jupyter. (#76) diff --git a/htmltools/_core.py b/htmltools/_core.py index 8c71287..d2feb9d 100644 --- a/htmltools/_core.py +++ b/htmltools/_core.py @@ -133,8 +133,7 @@ class Tagifiable(Protocol): returns a `TagList`, the children of the `TagList` must also be tagified. """ - def tagify(self) -> "TagList | Tag | MetadataNode | str": - ... + def tagify(self) -> "TagList | Tag | MetadataNode | str": ... @runtime_checkable @@ -148,8 +147,7 @@ def __call__( *args: TagChild | TagAttrs, _add_ws: TagAttrValue = ..., **kwargs: TagAttrValue, - ) -> "Tag": - ... + ) -> "Tag": ... @runtime_checkable @@ -158,8 +156,7 @@ class ReprHtml(Protocol): Objects with a `_repr_html_()` method. """ - def _repr_html_(self) -> str: - ... + def _repr_html_(self) -> str: ... # ============================================================================= @@ -1609,7 +1606,7 @@ def copy_to(self, path: str, include_version: bool = True) -> None: # Verify they all exist for f in src_files: src_file = os.path.join(paths["source"], f) - if not os.path.isfile(src_file): + if not os.path.exists(src_file): raise Exception( f"Failed to copy HTML dependency {self.name}-{str(self.version)} " + f"because {src_file} doesn't exist." @@ -1626,7 +1623,10 @@ def copy_to(self, path: str, include_version: bool = True) -> None: src_file = os.path.join(paths["source"], f) target_file = os.path.join(target_dir, f) os.makedirs(os.path.dirname(target_file), exist_ok=True) - shutil.copy2(src_file, target_file) + if os.path.isfile(src_file): + shutil.copy2(src_file, target_file) + elif os.path.isdir(src_file): + shutil.copytree(src_file, target_file) def _validate_dicts(self, ld: Iterable[object], req_attr: list[str]) -> None: for d in ld: @@ -1740,7 +1740,7 @@ def _tag_show( import IPython # pyright: ignore[reportUnknownVariableType] ipy = ( # pyright: ignore[reportUnknownVariableType] - IPython.get_ipython() # pyright: ignore[reportUnknownMemberType] + IPython.get_ipython() # pyright: ignore[reportUnknownMemberType, reportPrivateImportUsage] ) renderer = "ipython" if ipy else "browser" except ImportError: diff --git a/htmltools/_jsx.py b/htmltools/_jsx.py index 6d75ddb..02a1c9d 100644 --- a/htmltools/_jsx.py +++ b/htmltools/_jsx.py @@ -4,6 +4,7 @@ that's an issue for HTML() and