我正在为Gitlab API使用python-gitlab驱动程序。我的存储库上的以下工作正常:
>>> rf_blob = p.repository_blob(p_latest_commit.id, 'iOSBoilerplate/GooglePlus/GoogleOpenSource.framework/Versions/A/Headers/GTMOAuth2Authentication.h')
>>> rf_blob = p.repository_blob(p_latest_commit.id, 'iOSBoilerplate/GooglePlus/GoogleOpenSource.framework/Versions/A/Headers/GTMOAuth2SignIn.h')
但是,当我尝试打开包含+
字符的文件时,即使该文件明确存在于存储库中,我也会得到以下内容:
>>> rf_blob = p.repository_blob(p_latest_commit.id, 'iOSBoilerplate/GooglePlus/GoogleOpenSource.framework/Versions/A/Headers/GTMNSString+URLArguments.h')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/gitlab/objects.py", line 1521, in repository_blob
raise_error_from_response(r, GitlabGetError)
File "/usr/local/lib/python2.7/site-packages/gitlab/exceptions.py", line 140, in raise_error_from_response
response_body=response.content)
gitlab.exceptions.GitlabGetError: 404: 404 File Not Found
我究竟如何在python中转义+
以便获取文件的blob?
答案 0 :(得分:0)
解决方案是使用app.service('MyHttpService', function($http) {
this.getData = function(id) {
$http.get(<URL>, <PARAMS>).then(function(success) {
return success;
}, function(err) {
return err;
});
}
});
// In you Controller
app.controller('MyCtrl', function(MyHttpService){
$scope.data = getData .getData();
})
。
python-gitlab是真正的Gitlab API的表面包装器。 Gitlab API在url请求上运行,因此这个解决方案似乎很自然:
urllib.quote