Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Repository.get_archive_link (issue #65)

  • Loading branch information...
commit f109c644fddee5512f8e88a4a22d9c3aac68a306 1 parent f963e6a
@jacquev6 jacquev6 authored
View
21 codegen/JsonDescriptionOfGithubApiV3/description.human_readable.json
@@ -1865,6 +1865,27 @@
}
},
{
+ "name": [ "get", "archive", "link" ],
+ "type": "string",
+ "group": "contents",
+ "mandatoryParameters": [
+ { "name": "archive_format", "type": "string" }
+ ],
+ "optionalParameters": [
+ { "name": "ref", "type": "string" }
+ ],
+ "request": {
+ "verb": "GET",
+ "url": [
+ { "type": "attribute", "value": [ "url" ] },
+ { "type": "constant", "value": "/" },
+ { "type": "argument", "value": [ "archive_format" ] },
+ { "type": "constant", "value": "/" },
+ { "type": "argument", "value": [ "ref" ] }
+ ]
+ }
+ },
+ {
"name": [ "compare" ],
"type": "Comparison",
"group": "Comparison",
View
65 codegen/JsonDescriptionOfGithubApiV3/description.normalized.json
@@ -10835,6 +10835,71 @@
}
},
{
+ "group": "contents",
+ "name": [
+ "get",
+ "archive",
+ "link"
+ ],
+ "mandatoryParameters": [
+ {
+ "type": {
+ "simple": true,
+ "cardinality": "scalar",
+ "name": "string"
+ },
+ "name": "archive_format"
+ }
+ ],
+ "request": {
+ "url": [
+ {
+ "type": "attribute",
+ "value": [
+ "url"
+ ]
+ },
+ {
+ "type": "constant",
+ "value": "/"
+ },
+ {
+ "type": "argument",
+ "value": [
+ "archive_format"
+ ]
+ },
+ {
+ "type": "constant",
+ "value": "/"
+ },
+ {
+ "type": "argument",
+ "value": [
+ "ref"
+ ]
+ }
+ ],
+ "verb": "GET"
+ },
+ "isMutation": false,
+ "optionalParameters": [
+ {
+ "type": {
+ "simple": true,
+ "cardinality": "scalar",
+ "name": "string"
+ },
+ "name": "ref"
+ }
+ ],
+ "type": {
+ "simple": true,
+ "cardinality": "scalar",
+ "name": "string"
+ }
+ },
+ {
"group": "Comparison",
"name": [
"compare"
View
2  doc/ReferenceOfApis.md
@@ -135,7 +135,7 @@ API `/repos/:user/:repo`
API `/repos/:user/:repo/:archive_format/:ref`
=============================================
-* GET: (TODO)
+* GET: `Repository.get_archive_link`
API `/repos/:user/:repo/assignees`
==================================
View
3  doc/ReferenceOfClasses.md
@@ -1163,6 +1163,9 @@ Contents
* `get_readme()`: `ContentFile`
* `get_contents( path )`: `ContentFile`
* `path`: string
+* `get_archive_link( archive_format, [ref] )`: string
+ * `archive_format`: string
+ * `ref`: string
Contributors
------------
View
14 github/Repository.py
@@ -498,6 +498,20 @@ def edit( self, name, description = GithubObject.NotSet, homepage = GithubObject
)
self._useAttributes( data )
+ def get_archive_link( self, archive_format, ref = GithubObject.NotSet ):
+ assert isinstance( archive_format, ( str, unicode ) ), archive_format
+ assert ref is GithubObject.NotSet or isinstance( ref, ( str, unicode ) ), ref
+ url = self.url + "/" + archive_format
+ if ref is not GithubObject.NotSet:
+ url += "/" + ref
+ headers, data = self._requester.requestAndCheck(
+ "GET",
+ url,
+ None,
+ None
+ )
+ return headers[ "location" ]
+
def get_assignees( self ):
headers, data = self._requester.requestAndCheck(
"GET",
View
20 test/ReplayData/Repository.testGetArchiveLink.txt
@@ -0,0 +1,20 @@
+https GET api.github.com None /repos/jacquev6/PyGithub/tarball {'Authorization': 'Basic login_and_password_removed'} null
+302
+[('status', '302 Found'), ('content-length', '0'), ('x-content-type-options', 'nosniff'), ('expires', 'Sat, 08 Sep 2012 11:03:00 GMT'), ('x-ratelimit-remaining', '4990'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('location', 'https://nodeload.github.com/jacquev6/PyGithub/tarball/master'), ('cache-control', 'public, must-revalidate, max-age=0'), ('date', 'Sat, 08 Sep 2012 11:03:00 GMT'), ('content-type', 'text/html;charset=utf-8')]
+
+
+https GET api.github.com None /repos/jacquev6/PyGithub/zipball {'Authorization': 'Basic login_and_password_removed'} null
+302
+[('status', '302 Found'), ('x-ratelimit-remaining', '4989'), ('x-content-type-options', 'nosniff'), ('expires', 'Sat, 08 Sep 2012 11:03:01 GMT'), ('content-length', '0'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('location', 'https://nodeload.github.com/jacquev6/PyGithub/zipball/master'), ('cache-control', 'public, must-revalidate, max-age=0'), ('date', 'Sat, 08 Sep 2012 11:03:01 GMT'), ('content-type', 'text/html;charset=utf-8')]
+
+
+https GET api.github.com None /repos/jacquev6/PyGithub/zipball/master {'Authorization': 'Basic login_and_password_removed'} null
+302
+[('status', '302 Found'), ('content-length', '0'), ('x-content-type-options', 'nosniff'), ('expires', 'Sat, 08 Sep 2012 11:03:01 GMT'), ('x-ratelimit-remaining', '4988'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('location', 'https://nodeload.github.com/jacquev6/PyGithub/zipball/master'), ('cache-control', 'public, must-revalidate, max-age=0'), ('date', 'Sat, 08 Sep 2012 11:03:01 GMT'), ('content-type', 'text/html;charset=utf-8')]
+
+
+https GET api.github.com None /repos/jacquev6/PyGithub/tarball/develop {'Authorization': 'Basic login_and_password_removed'} null
+302
+[('status', '302 Found'), ('x-ratelimit-remaining', '4987'), ('x-content-type-options', 'nosniff'), ('expires', 'Sat, 08 Sep 2012 11:03:01 GMT'), ('content-length', '0'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('location', 'https://nodeload.github.com/jacquev6/PyGithub/tarball/develop'), ('cache-control', 'public, must-revalidate, max-age=0'), ('date', 'Sat, 08 Sep 2012 11:03:01 GMT'), ('content-type', 'text/html;charset=utf-8')]
+
+
View
6 test/Repository.py
@@ -360,3 +360,9 @@ def testAssignees( self ):
def testGetContents( self ):
self.assertEqual( len( self.repo.get_readme().content ), 10212 )
self.assertEqual( len( self.repo.get_contents( "doc/ReferenceOfClasses.md" ).content ), 38121 )
+
+ def testGetArchiveLink( self ):
+ self.assertEqual( self.repo.get_archive_link( "tarball" ), "https://nodeload.github.com/jacquev6/PyGithub/tarball/master" )
+ self.assertEqual( self.repo.get_archive_link( "zipball" ), "https://nodeload.github.com/jacquev6/PyGithub/zipball/master" )
+ self.assertEqual( self.repo.get_archive_link( "zipball", "master" ), "https://nodeload.github.com/jacquev6/PyGithub/zipball/master" )
+ self.assertEqual( self.repo.get_archive_link( "tarball", "develop" ), "https://nodeload.github.com/jacquev6/PyGithub/tarball/develop" )
Please sign in to comment.
Something went wrong with that request. Please try again.