Skip to content

Commit

Permalink
Remove deprecated methods
Browse files Browse the repository at this point in the history
Also deprecate {un,}archive_() in favor of {un,}archive().

Fix #115
  • Loading branch information
Gauvain Pocentek committed Nov 5, 2016
1 parent 258aab4 commit c970a22
Showing 1 changed file with 13 additions and 66 deletions.
79 changes: 13 additions & 66 deletions gitlab/objects.py
Expand Up @@ -1852,11 +1852,6 @@ class ProjectSnippet(GitlabObject):
[('project_id', 'project_id'), ('snippet_id', 'id')]),
)

def Content(self, **kwargs):
warnings.warn("`Content` is deprecated, use `content` instead",
DeprecationWarning)
return self.content()

def content(self, streamed=False, action=None, chunk_size=1024, **kwargs):
"""Return the raw content of a snippet.
Expand Down Expand Up @@ -2082,11 +2077,6 @@ class Project(GitlabObject):
VISIBILITY_INTERNAL = gitlab.VISIBILITY_INTERNAL
VISIBILITY_PUBLIC = gitlab.VISIBILITY_PUBLIC

def tree(self, path='', ref_name='', **kwargs):
warnings.warn("`tree` is deprecated, use `repository_tree` instead",
DeprecationWarning)
return self.repository_tree(path, ref_name, **kwargs)

def repository_tree(self, path='', ref_name='', **kwargs):
"""Return a list of files in the repository.
Expand All @@ -2113,11 +2103,6 @@ def repository_tree(self, path='', ref_name='', **kwargs):
raise_error_from_response(r, GitlabGetError)
return r.json()

def blob(self, sha, filepath, **kwargs):
warnings.warn("`blob` is deprecated, use `repository_blob` instead",
DeprecationWarning)
return self.repository_blob(sha, filepath, **kwargs)

def repository_blob(self, sha, filepath, streamed=False, action=None,
chunk_size=1024, **kwargs):
"""Return the content of a file for a commit.
Expand Down Expand Up @@ -2205,12 +2190,6 @@ def repository_contributors(self):
raise_error_from_response(r, GitlabListError)
return r.json()

def archive(self, sha=None, **kwargs):
warnings.warn("`archive` is deprecated, "
"use `repository_archive` instead",
DeprecationWarning)
return self.repository_archive(sha, **kwargs)

def repository_archive(self, sha=None, streamed=False, action=None,
chunk_size=1024, **kwargs):
"""Return a tarball of the repository.
Expand Down Expand Up @@ -2238,49 +2217,6 @@ def repository_archive(self, sha=None, streamed=False, action=None,
raise_error_from_response(r, GitlabGetError)
return utils.response_content(r, streamed, action, chunk_size)

def create_file(self, path, branch, content, message, **kwargs):
"""Creates file in project repository
Args:
path (str): Full path to new file.
branch (str): The name of branch.
content (str): Content of the file.
message (str): Commit message.
**kwargs: Arbitrary keyword arguments.
Raises:
GitlabConnectionError: If the server cannot be reached.
GitlabCreateError: If the server fails to perform the request.
"""
warnings.warn("`create_file` is deprecated, "
"use `files.create()` instead",
DeprecationWarning)
url = "/projects/%s/repository/files" % self.id
url += ("?file_path=%s&branch_name=%s&content=%s&commit_message=%s" %
(path, branch, content, message))
r = self.gitlab._raw_post(url, data=None, content_type=None, **kwargs)
raise_error_from_response(r, GitlabCreateError, 201)

def update_file(self, path, branch, content, message, **kwargs):
warnings.warn("`update_file` is deprecated, "
"use `files.update()` instead",
DeprecationWarning)
url = "/projects/%s/repository/files" % self.id
url += ("?file_path=%s&branch_name=%s&content=%s&commit_message=%s" %
(path, branch, content, message))
r = self.gitlab._raw_put(url, data=None, content_type=None, **kwargs)
raise_error_from_response(r, GitlabUpdateError)

def delete_file(self, path, branch, message, **kwargs):
warnings.warn("`delete_file` is deprecated, "
"use `files.delete()` instead",
DeprecationWarning)
url = "/projects/%s/repository/files" % self.id
url += ("?file_path=%s&branch_name=%s&commit_message=%s" %
(path, branch, message))
r = self.gitlab._raw_delete(url, **kwargs)
raise_error_from_response(r, GitlabDeleteError)

def create_fork_relation(self, forked_from_id):
"""Create a forked from/to relation between existing projects.
Expand Down Expand Up @@ -2336,7 +2272,7 @@ def unstar(self, **kwargs):
raise_error_from_response(r, GitlabDeleteError, [200, 304])
return Project(self.gitlab, r.json()) if r.status_code == 200 else self

def archive_(self, **kwargs):
def archive(self, **kwargs):
"""Archive a project.
Returns:
Expand All @@ -2351,7 +2287,12 @@ def archive_(self, **kwargs):
raise_error_from_response(r, GitlabCreateError, 201)
return Project(self.gitlab, r.json()) if r.status_code == 201 else self

def unarchive_(self, **kwargs):
def archive_(self, **kwargs):
warnings.warn("`archive_()` is deprecated, use `archive()` instead",
DeprecationWarning)
return self.archive(**kwargs)

def unarchive(self, **kwargs):
"""Unarchive a project.
Returns:
Expand All @@ -2366,6 +2307,12 @@ def unarchive_(self, **kwargs):
raise_error_from_response(r, GitlabCreateError, 201)
return Project(self.gitlab, r.json()) if r.status_code == 201 else self

def unarchive_(self, **kwargs):
warnings.warn("`unarchive_()` is deprecated, "
"use `unarchive()` instead",
DeprecationWarning)
return self.unarchive(**kwargs)

def share(self, group_id, group_access, **kwargs):
"""Share the project with a group.
Expand Down

0 comments on commit c970a22

Please sign in to comment.