跳转到主要内容

一个简单的库,用于基于基字符串合并两个字符串

项目描述

three-merge

Project License - MIT pypi version conda version download count Downloads PyPI status Linux tests MacOS tests Windows tests

版权所有 © 2020– Spyder项目贡献者

概述

一个简单的Python库,用于根据 diff-match-patch 在字符串之间执行3向合并。与大多数VCS系统选择基于行的方法相比,此库在字符级别执行合并。

安装

要安装three-merge,您可以使用conda或pip包管理器

# Using conda (Recommended)
conda install three-merge -c spyder-ide

# Using pip
pip install three-merge

依赖项

此包依赖于 diff-match-patch 来计算和跟踪相对于基字符串的源和目标字符串之间的差异。

本地安装

要本地安装和开发three-merge,您需要安装diff-match-patch

# Using conda
conda install diff-match-patch

# Using pip
pip install diff-match-patch

然后,您可以使用pip本地安装包

pip install -U -e .

运行测试

我们使用pytest来运行测试,如下所示

pytest -x -v three_merge/tests

包使用说明

Three-merge提供了一个merge函数,用于将两个字符串(源、目标)的变化合并到一个原始字符串(基准)中。这个库能够处理两个字符串中的添加、删除和保留部分,同时检测并突出显示可能的合并冲突(如Git)。

# Package import
from three_merge import merge

# Strings have non-conflicting additions
base = '123456789101112'
source = '0123456789101112'
target = '12345678910111213'

# merged = '012345678910111213'
merged = merge(source, target, base)

# Strings have an addition conflict
base = '123456789101112'
source = '123a456789101112'
target = '123b456789101112'

# merged = '123<<<<<<< ++ a ======= ++ b >>>>>>>456789101112'
merged = merge(source, target, base)

# Strings have non-conflicting addition/deletions
base = '123456789101112'
source = '123456789ab101112'
target = '123789101112'

# merged = '123789ab101112'
merged = merge(source, target, base)

更多示例,请参阅我们的测试

变更日志

请查看我们的变更日志文件,了解我们的新功能和改进。

贡献指南

我们遵循PEP8和PEP257对所有Python模块进行编码。我们对这个包中声明的所有函数和类使用MyPy类型注解。如果您有任何问题/疑问,请随时发送PR或创建问题。

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

three-merge-0.1.1.tar.gz (5.9 kB 查看哈希值)

上传时间

构建分发

three_merge-0.1.1-py2.py3-none-any.whl (6.4 kB 查看哈希值)

上传时间 Python 2 Python 3

支持者:

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面