Skip to content

Commit f1c15a6

Browse files
committed
local cache bugfixes, api consistency
1 parent 9fcfb8c commit f1c15a6

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

feedly/data.py

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
handy getter methods, but otherwise you can just use a .json property to access the
44
raw json passed back by the client.
55
"""
6-
from typing import Any, Dict, Optional, Callable
6+
from typing import Any, Dict, Optional, Callable, Union
77
from urllib.parse import quote_plus
88

99
from feedly.protocol import APIClient
@@ -197,21 +197,53 @@ def _get_category_or_tag(self, stream_id:StreamIdBase, cache:Dict[str,Streamable
197197

198198
return factory({'id': stream_id.id}, self._client)
199199

200-
def get_category(self, name:str):
201-
id_ = UserStreamId(parts=[STREAM_SOURCE_USER, self.id, 'category', name])
200+
def get_category(self, key:Union[str, UserStreamId]):
201+
"""
202+
:param key: the id of the category (e.g. "recipes"), or stream ID object
203+
:return: the category
204+
"""
205+
if isinstance(key, str):
206+
id_ = UserStreamId(parts=[STREAM_SOURCE_USER, self.id, 'category', key])
207+
else:
208+
id_ = key
202209

203210
return self._get_category_or_tag(id_, self._categories, UserCategory, False)
204211

205-
def get_tag(self, name:str) -> 'UserTag':
206-
id_ = UserStreamId(parts=[STREAM_SOURCE_USER, self.id, 'tag', name])
212+
def get_tag(self, key:Union[str, UserStreamId]) -> 'UserTag':
213+
"""
214+
:param key: the id of the tag (e.g. "recipes"), or stream ID object
215+
:return: the category
216+
"""
217+
if isinstance(key, str):
218+
id_ = UserStreamId(parts=[STREAM_SOURCE_USER, self.id, 'tag', key])
219+
else:
220+
id_ = key
207221

208222
return self._get_category_or_tag(id_, self._tags, UserTag, True)
209223

210-
def get_enterprise_category(self, stream_id:EnterpriseStreamId) -> 'EnterpriseCategory':
211-
return self._get_category_or_tag(stream_id, self._tags, EnterpriseCategory, False)
212-
213-
def get_enterprise_tag(self, stream_id:EnterpriseStreamId) -> 'EnterpriseTag':
214-
return self._get_category_or_tag(stream_id, self._tags, EnterpriseTag, False)
224+
def get_enterprise_category(self, key:Union[str, EnterpriseStreamId]) -> 'EnterpriseCategory':
225+
"""
226+
:param key: the UUID of the category (dash separated hex numbers), or a stream ID object)
227+
:return: the category
228+
"""
229+
if isinstance(key, str):
230+
id_ = EnterpriseStreamId(parts=[STREAM_SOURCE_ENTERPRISE, self.enterprise_name, 'category', key])
231+
else:
232+
id_ = key
233+
234+
return self._get_category_or_tag(id_, self._enterprise_categories, EnterpriseCategory, False)
235+
236+
def get_enterprise_tag(self, key:Union[str, EnterpriseStreamId]) -> 'EnterpriseTag':
237+
"""
238+
:param key: the UUID of the tag (dash separated hex numbers), or a stream ID object)
239+
:return: the category
240+
"""
241+
if isinstance(key, str):
242+
id_ = EnterpriseStreamId(parts=[STREAM_SOURCE_ENTERPRISE, self.enterprise_name, 'tag', key])
243+
else:
244+
id_ = key
245+
246+
return self._get_category_or_tag(id_, self._enterprise_tags, EnterpriseTag, False)
215247

216248

217249

feedly/stream.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ def __iter__(self):
157157
if self.continuation is not None and n < self.options._max_count:
158158
curl = f'{url}&continuation={quote_plus(self.continuation)}' if self.continuation else url
159159

160-
logging.debug('url: %s', curl)
161160
resp = self._client.do_api_request(curl)
162161
self.continuation = resp.get('continuation')
163162
if resp and self._items_prop in resp:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
EMAIL = 'kireet@feedly.com'
1919
AUTHOR = 'Kireet'
2020
REQUIRES_PYTHON = '>=3.6.0'
21-
VERSION = 0.15
21+
VERSION = 0.16
2222

2323
# What packages are required for this module to be executed?
2424
with open('requirements.txt') as f:

0 commit comments

Comments
 (0)