A Git URL解析模块(支持解析和重写)
项目描述
解析和重写git urls(支持GitHub、Bitbucket、FriendCode、Assembla、Gitlab等)
这是一个giturlparse.py的分支,并更新了解析器。
原始项目可在https://github.com/FriendCode/giturlparse.py找到
安装
pip install giturlparse
示例
公开属性
platform:平台代号
host:服务器主机名
resource:与host相同
port:URL端口(仅当在URL中明确定义时)
protocol:URL协议(git、ssh、http/https)
protocols:URL中明确定义的协议列表
user:仓库用户
owner:仓库所有者(用户或组织)
repo:仓库名称
name:与repo相同
groups:组列表 - 仅Gitlab
path:文件或目录的路径(包括分支名称) - 仅Gitlab / GitHub
path_raw:从仓库名称开始的原始路径(可能包含平台关键字) - 仅Gitlab / GitHub
分支:分支名称(当可解析时) - 仅限 GitLab / GitHub
用户名:从 <username>:<access_token>@<url> GitLab / GitHub 网址中获取的用户名
访问令牌:从 <username>:<access_token>@<url> GitLab / GitHub 网址中获取的访问令牌
解析
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)
URLS
同一仓库的替代 URL
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 -munittest
许可证
Apache v2(查看 LICENSE 文件)
历史
0.12.0 (2023-09-24)
特性
添加 github/gitlab 用户名:access_token 解析支持 (#21)
迁移到 bump-my-version (#79)
错误修复
修复带有分支的 Gitlab URL (#42)
使 tox.ini 与 github actions 保持一致 (#71)
0.11.1 (2023-08-04)
错误修复
移除调试打印语句 (#66)
0.11.0 (2023-08-03)
特性
为 gitlab 解析器添加用户解析变量 (#47)
添加对 Python 3.8+ 的支持 (#48)
错误修复
更新测试调用方法以避免未来的中断 (#29)
更新代码风格检查工具并修复代码风格 (#34)
添加更多 github 用例 (#43)
修复解析通用 git url (#46)
0.10.0 (2020-12-05)
特性
一般匹配改进 (#18)
更新工具,删除 python2 (#10213)
0.9.2 (2018-10-27)
从基本平台正则表达式中移除“s”
修复 setup.py 中的许可分类器
更新元文件
0.9.1 (2018-01-20)
首次分支发布
项目详情
下载文件
下载适合您平台的应用程序。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源分布
构建分布
giturlparse-0.12.0.tar.gz 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | c0fff7c21acc435491b1779566e038757a205c1ffdcb47e4f81ea52ad8c3859a |
|
MD5 | 1e19953533eab452548a304c3dac96b1 |
|
BLAKE2b-256 | 375f543dc54c82842376139748226e5aa61eb95093992f63dd495af9c6b4f076 |
giturlparse-0.12.0-py2.py3-none-any.whl 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 412b74f2855f1da2fefa89fd8dde62df48476077a72fc19b62039554d27360eb |
|
MD5 | 89222d2c1220eb17387941da034bf4dc |
|
BLAKE2b-256 | dd94c6ff3388b8e3225a014e55aed957188639aa0966443e0408d38f0c9614a7 |