Skip to content

Commit ab3f248

Browse files
committed
Fix removed utility from Click Extra 7.6.2
1 parent 24ecf4e commit ab3f248

File tree

4 files changed

+171
-120
lines changed

4 files changed

+171
-120
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
> [!IMPORTANT]
66
> This version is not released yet and is under active development.
77
8+
- [mpm] Inline `replace_content` utility from `click-extra` which was removed in `7.6.2`.
9+
810
## [6.1.1 (2026-02-05)](https://github.com/kdeldycke/meta-package-manager/compare/v6.1.0...v6.1.1)
911

1012
- [choco] Add `--retry-count=3` option to all `choco` invocations.

meta_package_manager/inventory.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from pathlib import Path
2121
from textwrap import dedent
2222

23-
from click_extra.docs_update import replace_content
2423
from click_extra.table import TableFormat, render_table
2524
from extra_platforms import (
2625
ALL_WINDOWS,
@@ -143,9 +142,40 @@ def operation_matrix() -> tuple[str, str]:
143142
return rendered_table, "\n\n".join(footnotes)
144143

145144

145+
def replace_content(
146+
filepath: Path,
147+
new_content: str,
148+
start_tag: str,
149+
end_tag: str | None = None,
150+
) -> None:
151+
"""Replace in a file the content surrounded by the provided start and end tags.
152+
153+
If no end tag is provided, the whole content found after the start tag will be
154+
replaced.
155+
"""
156+
filepath = filepath.resolve()
157+
assert filepath.exists(), f"File {filepath} does not exist."
158+
assert filepath.is_file(), f"File {filepath} is not a file."
159+
160+
orig_content = filepath.read_text()
161+
162+
assert start_tag, "Start tag must be empty."
163+
assert start_tag in orig_content, f"Start tag {start_tag!r} not found in content."
164+
pre_content, table_start = orig_content.split(start_tag, 1)
165+
166+
if end_tag:
167+
_, post_content = table_start.split(end_tag, 1)
168+
else:
169+
end_tag = ""
170+
post_content = ""
171+
172+
filepath.write_text(
173+
f"{pre_content}{start_tag}{new_content}{end_tag}{post_content}",
174+
)
175+
176+
146177
def update_readme() -> None:
147178
"""Update ``readme.md`` with implementation table for each manager we support."""
148-
149179
readme = Path(__file__).parent.parent.joinpath("readme.md")
150180

151181
replace_content(

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ dependencies = [
113113
"backports.strenum >= 1.3.0 ; python_version < '3.11'",
114114
# boltons 25.0.0 is the first version to support Python 3.13.
115115
"boltons >= 25.0.0",
116-
# We need click-extra 7.5.1 for its new "aligned" table rendering.
117-
"click-extra >= 7.5.1",
116+
# click-extra 7.6.2 removed the docs_update module we used to depend on.
117+
"click-extra >= 7.6.2",
118118
# cyclonedx-python-lib 11.2.0 is the first to support Python 3.14.
119119
"cyclonedx-python-lib [validation] >= 11.2.0",
120120
# extra-platforms 8.0.0 removes deprecated symbols and add extract_members().
@@ -197,6 +197,8 @@ module-root = ""
197197
[tool.uv]
198198
# Cooldown period.
199199
exclude-newer = "1 week"
200+
# Bypass cooldown for packages that need a newer version than the window allows.
201+
exclude-newer-package = { click-extra = "1 hour" }
200202

201203
[tool.nuitka]
202204
product-name = "Meta Package Manager"

0 commit comments

Comments
 (0)