跨文件搜索和替换
项目描述
jupyterlab-search-replace
跨文件搜索和替换。
JupyterLab集成
笔记本集成
替换说明
有三种替换级别。除了替换所有匹配项外,都可以撤销。
- 替换所有匹配项:无法撤销。在应用替换操作之前,会弹出一个对话框要求确认,并将所有文件备份到
.ipynb_checkpoints
文件夹中。 - 在文件中替换所有匹配项:文件将在文本编辑器中打开,替换将作为一个单独的文本编辑操作完成。因此,所有替换都可以通过调用编辑器的撤销动作来撤销。
- 替换单个匹配项:文件将在文本编辑器中打开,替换将作为一个文本编辑操作完成。替换将通过调用编辑器的撤销动作来撤销。
要求
- JupyterLab >= 3.0 和 Notebook >= 7.0
- ripgrep
ripgrep 作为 conda 包 在 conda-forge 上可用。
安装
要安装扩展,执行
pip install jupyterlab jupyterlab-search-replace
注意:您仍然需要安装 ripgrep
以使 jupyterlab-search-replace
能够工作。
或
conda install -c conda-forge jupyterlab-search-replace ripgrep
卸载
要卸载扩展,执行
pip uninstall jupyterlab-search-replace
或
conda remove jupyterlab-search-replace ripgrep
故障排除
如果您看到前端扩展但无法使用,请检查服务器扩展是否启用
jupyter server extension list
如果服务器扩展已安装并启用,但您没有看到前端扩展,请检查前端扩展是否已安装
jupyter labextension list
贡献
开发安装
注意:您将需要 NodeJS 来构建扩展包。
jlpm
命令是 JupyterLab 的固定版本 yarn,它是与 JupyterLab 一起安装的。您可以使用 yarn
或 npm
替代下面的 jlpm
。
# Clone the repo to your local environment
# Change directory to the jupyterlab_search_replace directory
# Install package in development mode
pip install -e ".[test]"
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Server extension must be manually installed in develop mode
jupyter server extension enable jupyterlab_search_replace
# Rebuild extension Typescript source after making changes
jlpm run build
您可以在不同的终端中同时监视源目录并运行 JupyterLab,以监视扩展源中的更改并自动重新构建扩展。
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm run watch
# Run JupyterLab in another terminal
jupyter lab
在监视命令运行时,每次保存的更改都会立即在本地构建并可供运行的 JupyterLab 使用。刷新 JupyterLab 以在浏览器中加载更改(您可能需要等待几秒钟以重新构建扩展)。
默认情况下,jlpm run build
命令为该扩展生成源映射,以便更容易使用浏览器开发工具进行调试。要为 JupyterLab 核心扩展也生成源映射,可以运行以下命令
jupyter lab build --minimize=False
开发卸载
# Server extension must be manually disabled in develop mode
jupyter server extension disable jupyterlab_search_replace
pip uninstall jupyterlab_search_replace
在开发模式下,您还需要删除由 jupyter labextension develop
命令创建的符号链接。要找到其位置,可以运行 jupyter labextension list
以确定 labextensions
文件夹的位置。然后您可以在该文件夹中删除名为 jupyterlab-search-replace
的符号链接。
测试扩展
服务器测试
此扩展使用 Pytest 对 Python 代码进行测试。
安装测试依赖项(只需安装一次)
pip install -e ".[test]"
# Each time you install the Python package, you need to restore the front-end extension link
jupyter labextension develop . --overwrite
要执行它们,请运行
pytest -vv -r ap --cov jupyterlab_search_replace
集成测试
此扩展使用 Playwright 进行集成测试(也称为用户级测试)。更确切地说,JupyterLab 辅助程序 Galata 用于在 JupyterLab 中测试扩展。
更多信息请参阅 ui-tests 的 README。
打包扩展
见 RELEASE
项目详情
jupyterlab_search_replace-1.1.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f139bd7de9aa9b9c67a6fa4e0354ade4d9c07e8458e32f0287661c30db91723f |
|
MD5 | 0a27cc288c85747822900b484912fb9a |
|
BLAKE2b-256 | dda6ca5b0f711e56a12ebadc347302bc73e288f182094b647c37807371f6481d |
jupyterlab_search_replace-1.1.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | fae97cbf9de818c8b93601a4e929f76843a195e63a21452058a7cc6d41d8c85e |
|
MD5 | 111968cc0cd12fda7280779824151b35 |
|
BLAKE2b-256 | 92aa2376b2324e33ad87631138fed42b57d5ca61bc6d0f5c52ad3cf4f94ea663 |