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第三方库


热门话题
java中的else if语句返回语法错误   http如何解析从表单到REST Java/Webservice的post请求   java如何在SpringBoot中为RestTemplate编写JUnit测试   java动态检查实例是否实现接口   java在Android中使用ArrayAdaptor时,数据不会显示   根据前序遍历返回二进制树的java方法   Arquillian测试类中的java注入始终为空   用户界面Java Swing自定义控件   java使用CompletableFutures递归地从同一函数的多个调用构建列表   在Java中将“.00”添加到整数BigDecimal   卡夫卡java未知\u主题\u或\u部分错误间歇性   java为什么我的getString()方法总是返回null?   java renameTo无法重命名文件   java为什么我可以强制转换对象?可以用其他对象来完成吗?   带有回写条件的java多根记录器   关于stackoverflow错误的java帮助?   java Websphere消息队列多线程   Java图形窗口/画布未垂直显示完整的六边形网格   java Sakai未在Tomcat服务器中启动