git url解析模块(支持解析和重写)

giturlparse的Python项目详细描述


解析并重写git url(支持github、bitbucket、friendcode、assembla、gitlab…)

这是giturlparse.py的一个分支,具有更新的解析器。

原始项目位于https://github.com/FriendCode/giturlparse.py

安装

pip install giturlparse

示例

解析

from giturlparse import parse

p = parse('git@bitbucket.org:AaronO/some-repo.git')

p.host, p.owner, p.repo

# => ('bitbucket.org', 'AaronO', 'some-repo')

重写

from giturlparse import parse

url = 'git@github.com:Org/Private-repo.git'

p = parse(url)

p.url2ssh, p.url2https, p.url2git, p.url2http
# => ('git@github.com:Org/Private-repo.git', 'https://github.com/Org/Private-repo.git', 'git://github.com/Org/Private-repo.git', None)

网址

同一回购的备选网址:

from giturlparse import parse

url = 'git@github.com:Org/Private-repo.git'

parse(url).urls
# => {
#     'ssh': 'git@github.com:Org/Private-repo.git',
#     'https': 'https://github.com/Org/Private-repo.git',
#     'git': 'git://github.com/Org/Private-repo.git'
# }

验证

from giturlparse import parse, validate

url = 'git@github.com:Org/Private-repo.git'

parse(url).valid
# => True

# Or

validate(url)
# => True

测试

python setup.py test

许可证

apache v2(签出许可证文件)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javapojo到org。布森。文件,反之亦然   java突然增加了G1老一代的承诺内存,减少了Eden的大小   java为什么对多个RXJava观察对象不执行并行执行?   java中的枚举是故障安全的吗?如果是,怎么做?   java是等待字符串变为相等的正确方法   java CodeAbbey挑战14个数据输入问题?   在java中的任意位置插入。util。列表   java替换html中的值   java需要帮助破译一个小堆栈跟踪:我使用的是哪种WS?   java Guice依赖项注入器空指针异常   java如何在3D引擎中实现视图剪裁平面?   JavaEclipseRCP:操作与命令需要更新   java如何使用XPAGES DesignerFacesServlet显示泰语字母(以及另一个亚洲/阿拉伯字母)   java装饰器模式问题   java我对空间复杂性的分析正确吗?   不显示java OpenGL ES 2纹理   使用java问题中的wc命令计算行数   java为什么空指针异常取决于条件的顺序?   Java日期在同一天或同一个月   java在使用lambda表达式时在变量中存储一些值