Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
pep257 and pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
dotzero committed Jun 28, 2016
1 parent e515197 commit 5eac4cb
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 11 deletions.
2 changes: 1 addition & 1 deletion habrahabr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""A library that provides a Python interface to the Habrahabr.ru API"""
"""A library that provides a Python interface to the Habrahabr.ru API."""

from .api import Api
from .auth import Auth
Expand Down
21 changes: 21 additions & 0 deletions habrahabr/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright (c) 2016 dotzero <mail@dotzero.ru>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a objects that represents a Habrahabr Resources."""
8 changes: 8 additions & 0 deletions habrahabr/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a BaseResource."""

import sys
import json
Expand All @@ -41,7 +42,14 @@


class BaseResource(object):
"""Базовый ресурс."""

def __init__(self, auth=None):
"""Конструктор BaseResource.
:param auth: Экземпляр класса Auth.
:rtype: object
"""
if auth is None:
raise ApiHandlerError('Auth handler is not defined')

Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a CommentsResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class CommentsResource(BaseResource):
"""Ресурс работы с комментариями."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(CommentsResource, self).__init__(*args, **kwargs)

@accepts(int)
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a CompanyResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class CompanyResource(BaseResource):
"""Ресурс работы с компаниями."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(CompanyResource, self).__init__(*args, **kwargs)

@accepts(str, int)
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a FeedResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class FeedResource(BaseResource):
"""Ресурс работы с "основной" лентой постов."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(FeedResource, self).__init__(*args, **kwargs)

@accepts(int)
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a FlowResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class FlowResource(BaseResource):
"""Ресурс работы с потоками."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(FlowResource, self).__init__(*args, **kwargs)

def list(self):
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a HubResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class HubResource(BaseResource):
"""Ресурс работы с хабами."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(HubResource, self).__init__(*args, **kwargs)

@accepts(str)
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a PollResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class PollResource(BaseResource):
"""Ресурс работы с опросами."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(PollResource, self).__init__(*args, **kwargs)

@accepts(int)
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a PostResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class PostResource(BaseResource):
"""Ресурс работы с постами."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(PostResource, self).__init__(*args, **kwargs)

@accepts(int)
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a SearchResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class SearchResource(BaseResource):
"""Ресурс работы с поиском."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(SearchResource, self).__init__(*args, **kwargs)

@accepts(str, int)
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a SettingsResource."""

from .base import BaseResource

Expand All @@ -27,6 +28,7 @@ class SettingsResource(BaseResource):
"""Ресурс работы с настройками профиля."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(SettingsResource, self).__init__(*args, **kwargs)

def agreement(self):
Expand Down
27 changes: 17 additions & 10 deletions habrahabr/resources/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a TrackerResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class TrackerResource(BaseResource):
"""Ресурс работы с трекером."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(TrackerResource, self).__init__(*args, **kwargs)

@accepts(str, str)
Expand All @@ -45,8 +47,9 @@ def push(self, title, text):
})

def counters(self):
"""Возвращает счетчики новых сообщений из трекера,
элементы не отмечаются как просмотренные.
"""Возвращает счетчики новых сообщений из трекера.
Элементы не отмечаются как просмотренные.
:returns: ответ API сервера.
:rtype: dict
Expand All @@ -55,8 +58,9 @@ def counters(self):

@accepts(int)
def posts(self, page=1):
"""Возвращает список постов из трекера,
элементы не отмечаются как просмотренные.
"""Возвращает список постов из трекера.
Элементы не отмечаются как просмотренные.
:param page: Номер страницы.
:returns: ответ API сервера.
Expand All @@ -66,8 +70,9 @@ def posts(self, page=1):

@accepts(int)
def subscribers(self, page=1):
"""Возвращает список подписчиков из трекера,
элементы не отмечаются как просмотренные.
"""Возвращает список подписчиков из трекера.
Элементы не отмечаются как просмотренные.
:param page: Номер страницы.
:returns: ответ API сервера.
Expand All @@ -77,8 +82,9 @@ def subscribers(self, page=1):

@accepts(int)
def mentions(self, page=1):
"""Возвращает список упоминаний из трекера,
элементы не отмечаются как просмотренные.
"""Возвращает список упоминаний из трекера.
Элементы не отмечаются как просмотренные.
:param page: Номер страницы.
:returns: ответ API сервера.
Expand All @@ -87,8 +93,9 @@ def mentions(self, page=1):
return self._request('/tracker/mentions?page=%d' % page)

def apps(self):
"""Возвращает список сообщений приложений из трекера,
элементы не отмечаются как просмотренные.
"""Возвращает список сообщений приложений из трекера.
Элементы не отмечаются как просмотренные.
:returns: ответ API сервера.
:rtype: dict
Expand Down
2 changes: 2 additions & 0 deletions habrahabr/resources/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""This module contains a object that represents a UserResource."""

from .base import BaseResource
from habrahabr.utils import accepts
Expand All @@ -28,6 +29,7 @@ class UserResource(BaseResource):
"""Ресурс работы с пользователями."""

def __init__(self, *args, **kwargs):
"""Конструктор ресурса."""
super(UserResource, self).__init__(*args, **kwargs)

def me(self):
Expand Down

0 comments on commit 5eac4cb

Please sign in to comment.