8000 Add ability to archive a repository · pythonthings/github3.py@eb57e7e · GitHub
[go: up one dir, main page]

Skip to content

Commit eb57e7e

Browse files
committed
Add ability to archive a repository
Also add the attribute to determine whether a given Repository is archived or not. While we're here, let's also trim out some dead attributes that seem to have come from our PullRequest objects. Closes sigmavirus24gh-752
1 parent f757c5f commit eb57e7e

File tree

1 file changed

+17
-51
lines changed

1 file changed

+17
-51
lines changed

github3/repos/repo.py

Lines changed: 17 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ def directory_contents(self, directory_path, ref=None, return_as=list):
956956
@requires_auth
957957
def edit(self, name, description=None, homepage=None, private=None,
958958
has_issues=None, has_wiki=None, has_downloads=None,
959-
default_branch=None):
959+
default_branch=None, archived=None):
960960
"""Edit this repository.
961961
962962
:param str name: (required), name of the repository
@@ -980,12 +980,15 @@ def edit(self, name, description=None, homepage=None, private=None,
980980
:param str default_branch: (optional), If not ``None``, change the
981981
default branch for this repository. API default: ``None`` - leave
982982
value unchanged.
983+
:param bool archived: (optional), If not ``None``, toggle the archived
984+
attribute on the repository to control whether it is archived or
985+
not.
983986
:returns: bool -- True if successful, False otherwise
984987
"""
985988
edit = {'name': name, 'description': description, 'homepage': homepage,
986989
'private': private, 'has_issues': has_issues,
987990
'has_wiki': has_wiki, 'has_downloads': has_downloads,
988-
'default_branch': default_branch}
991+
'default_branch': default_branch, 'archived': archived}
989992
self._remove_none(edit)
990993
json = None
991994
if edit:
@@ -2107,6 +2110,11 @@ class Repository(_Repository):
21072110
This object has all the same attributes as
21082111
:class:`~github3.repos.repo.ShortRepository` as well as:
21092112
2113+
.. attribute:: archived
2114+
2115+
A boolean attribute that describes whether the current repository has
2116+
been archived or not.
2117+
21102118
.. attribute:: clone_url
21112119
21122120
This is the URL that can be used to clone the repository via HTTPS,
@@ -2223,6 +2231,7 @@ class Repository(_Repository):
22232231

22242232
def _update_attributes(self, repo):
22252233
super(Repository, self)._update_attributes(repo)
2234+
self.archived = repo['archived']
22262235
self.clone_url = repo['clone_url']
22272236
self.created_at = self._strptime(repo['created_at'])
22282237
self.default_branch = repo['default_branch']
@@ -2232,68 +2241,25 @@ def _update_attributes(self, repo):
22322241
self.has_downloads = repo['has_downloads']
22332242
self.has_issues = repo['has_issues']
22342243
self.has_pages = repo['has_pages']
2244+
self.has_projects = repo['has_projects']
22352245
self.has_wiki = repo['has_wiki']
22362246
self.homepage = repo['homepage']
22372247
self.language = repo['language']
2248+
self.original_license = repo['license']
2249+
if self.original_license is not None:
2250+
self.original_license = License(self.original_license, self)
22382251
self.mirror_url = repo['mirror_url']
2252+
self.network_count = repo['network_count']
22392253
self.open_issues_count = repo['open_issues_count']
22402254
self.pushed_at = self._strptime(repo['pushed_at'])
22412255
self.size = repo['size']
22422256
self.ssh_url = repo['ssh_url']
22432257
self.stargazers_count = repo['stargazers_count']
2258+
self.subscribers_count = repo['subscribers_count']
22442259
self.svn_url = self._get_attribute(repo, 'svn_url')
22452260
self.updated_at = self._strptime_attribute(repo, 'updated_at')
22462261
self.watchers_count = self.watchers = repo['watchers_count']
22472262

2248-
# Some repositories do not have these attributes at all
2249-
self.original_license = repo.get('license')
2250-
if self.original_license is not None:
2251-
self.original_license = License(self.original_license, self)
2252-
self.network_count = repo.get('network_count')
2253-
self.subscribers_count = repo.get('subscribers_count')
2254-
2255-
# .......... OLD ...... Deprecated?
2256-
2257-
#: URL of the pure diff of the pull request
2258-
self.diff_url = self._get_attribute(repo, 'diff_url')
2259-
2260-
#: URL of the pure patch of the pull request
2261-
self.patch_url = self._get_attribute(repo, 'patch_url')
2262-
2263-
#: API URL of the issue representation of this Pull Request
2264-
self.issue_url = self._get_attribute(repo, 'issue_url')
2265-
2266-
#: Permissions for this repository
2267-
self.permissions = self._get_attribute(repo, 'permissions')
2268-
2269-
#: ``datetime`` object representing when the repository was starred
2270-
self.starred_at = self._strptime_attribute(repo, 'starred_at')
2271-
2272-
#: Parent of this fork, if it exists :class:`Repository`
2273-
self.source = self._class_attribute(repo, 'source', Repository, self)
2274-
2275-
#: Parent of this fork, if it exists :class:`Repository`
2276-
self.parent = self._class_attribute(repo, 'parent', Repository, self)
2277-
2278-
#: master (default) branch for the repository
2279-
self.master_branch = self._get_attribute(repo, 'master_branch')
2280-
2281-
# Template URLS
2282-
2283-
#: Pull Request Review Comments URL
2284-
self.review_comments_url = self._class_attribute(
2285-
repo,
2286-
'review_comments_url',
2287-
URITemplate
2288-
)
2289-
2290-
#: Pull Request Review Comments URL Template. Expand with ``number``
2291-
self.issue_events_urlt = self._class_attribute(
2292-
repo,
2293-
'review_comment_url',
2294-
URITemplate
2295-
)
2296-
22972263

22982264
class StarredRepository(GitHubCore):
22992265
"""This object represents the data returned about a user's starred repos.

0 commit comments

Comments
 (0)
0