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(签出许可证文件)