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这句话的第一个<U>是什么意思?   java在Android中转换为无符号字符和无符号短字符   java数学。显示工作结果的acos   java JDBC Mysqlconnector位于类路径中,但未找到   java hsqldb hibernate persist@Lob   集合对象无法显示在java、Arraylist、Collection中显示某些未定义值的输出   在Java中尝试在二叉搜索树上实现级别顺序遍历   如何在java对象中获取注释   java在会话超时时删除自定义cookie   java JDBC编程   返回语句上未选中强制转换的java警告   初学者二进制搜索中的java错误   java Azure BlockBlobClient下载时响应文件大小问题   JavaSeleniumWebDriver正在寻找Chrome的错误路径。exe   amazon web服务AWS Lambda(Java)调用错误的对象实例   检测到java Eclipse插件,但未加载   Java中类似于PHP的playframework Autoloader   java使用Google应用程序引擎生成实体列表,希望在Android客户端访问它   JavaZK国际化:UNICODE代替重音字符