Skip to content

Commit

Permalink
Make methods publish_doc/hide_doc deprecated in favor publish/unpublish.
Browse files Browse the repository at this point in the history
  • Loading branch information
TyVik committed Jan 7, 2018
1 parent b0d1c69 commit b695f52
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions YaDiskClient/YaDiskClient.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
#coding: utf-8
# coding: utf-8
from warnings import warn

from requests import request
import xml.etree.ElementTree as ET

Expand Down Expand Up @@ -81,7 +83,7 @@ def parseContent(content):
return result

url = path
if (offset != None) and (amount != None):
if (offset is not None) and (amount is not None):
url += "?offset={offset}&amount={amount}".format(offset=offset, amount=amount)
resp = self._sendRequest("PROPFIND", url, {'Depth': '1'})
if resp.status_code == 207:
Expand Down Expand Up @@ -168,7 +170,7 @@ def download(self, path, file):
else:
raise YaDiskException(resp.status_code, resp.content)

def publish_doc(self, path):
def publish(self, path):
"""Publish file or folder and return public url"""

def parseContent(content):
Expand All @@ -193,7 +195,7 @@ def parseContent(content):
else:
raise YaDiskException(resp.status_code, resp.content)

def hide_doc(self, path):
def unpublish(self, path):
"""Make public file or folder private (delete public url)"""

data = """
Expand All @@ -212,3 +214,11 @@ def hide_doc(self, path):
pass
else:
raise YaDiskException(resp.status_code, resp.content)

def publish_doc(self, path):
warn('This method was deprecated in favor method "publish"', DeprecationWarning, stacklevel=2)
return self.publish(path)

def hide_doc(self, path):
warn('This method was deprecated in favor method "unpublish"', DeprecationWarning, stacklevel=2)
return self.unpublish(path)

0 comments on commit b695f52

Please sign in to comment.