Skip to content

Commit 6c9ffeb

Browse files
committed
Fix docs
1 parent fc10bfc commit 6c9ffeb

9 files changed

Lines changed: 67 additions & 61 deletions

File tree

docs/bots_longpoll.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
Модуль для работы с Bots Long Poll
55

6-
.. module:: vk_api.bots_longpoll
6+
.. module:: vk_api.bot_longpoll
77
.. autoclass:: VkBotLongPoll
88
:members:
99
.. autoclass:: BotEvent
10-
:members:
10+
:members:

docs/keyboard.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ VkKeyboard
66
.. module:: vk_api.keyboard
77
.. autoclass:: VkKeyboard
88
:members:
9-
.. autoclass:: KeyboardColor
9+
.. autoclass:: VkKeyboardColor
1010
:members:

docs/longpoll.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
.. autoclass:: VkMessageFlag
2020
:members:
2121
.. autoclass:: VkPeerFlag
22-
:members:
22+
:members:

examples/keyboard.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
import vk_api
3-
from vk_api.keyboard import KeyboardColor
3+
from vk_api.keyboard import VkKeyboard, VkKeyboardColor
44

55

66
def main():
@@ -9,16 +9,16 @@ def main():
99
vk_session = vk_api.VkApi(token='bot_api_token')
1010
vk = vk_session.get_api()
1111

12-
keyboard = vk_api.VkKeyboard(one_time=True)
12+
keyboard = VkKeyboard(one_time=True)
1313

14-
keyboard.add_button('Белая кнопка', color=KeyboardColor.DEFAULT)
15-
keyboard.add_button('Зелёная кнопка', color=KeyboardColor.POSITIVE)
14+
keyboard.add_button('Белая кнопка', color=VkKeyboardColor.DEFAULT)
15+
keyboard.add_button('Зелёная кнопка', color=VkKeyboardColor.POSITIVE)
1616

1717
keyboard.add_line() # Переход на вторую строку
18-
keyboard.add_button('Красная кнопка', color=KeyboardColor.NEGATIVE)
18+
keyboard.add_button('Красная кнопка', color=VkKeyboardColor.NEGATIVE)
1919

2020
keyboard.add_line()
21-
keyboard.add_button('Синяя кнопка', color=KeyboardColor.PRIMARY)
21+
keyboard.add_button('Синяя кнопка', color=VkKeyboardColor.PRIMARY)
2222

2323
vk.messages.send(
2424
peer_id=123456,

jconfig/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010

1111
class BaseConfig(object):
12-
r"""Абстрактный базовый класс конфигурации.
13-
У наследуемых классов должен быть определен `__slots__`
12+
""" Абстрактный базовый класс конфигурации.
13+
У наследуемых классов должен быть определен `__slots__`
1414
1515
:param section: имя подкатегории в конфиге
16-
:param \**kwargs: будут переданы в :func:`load`
16+
:param \\**kwargs: будут переданы в :func:`load`
1717
"""
1818

1919
__slots__ = ('section_name', '_settings', '_section')

vk_api/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from .exceptions import *
44
from .requests_pool import VkRequestsPool, vk_request_one_param_pool
55
from .tools import VkTools
6-
from .keyboard import VkKeyboard
76
from .upload import VkUpload
87
from .vk_api import VkApi
98

vk_api/keyboard.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,20 @@
1414
from .utils import sjson_dumps
1515

1616

17-
class KeyboardColor(Enum):
17+
class VkKeyboardColor(Enum):
1818
""" Возможные цвета кнопок """
19-
PRIMARY = 'primary' # синяя
20-
DEFAULT = 'default' # белая
21-
NEGATIVE = 'negative' # красная
22-
POSITIVE = 'positive' # зелёная
19+
20+
PRIMARY = 'primary'
21+
""" Синяя """
22+
23+
DEFAULT = 'default'
24+
""" Белая"""
25+
26+
NEGATIVE = 'negative'
27+
""" Красная """
28+
29+
POSITIVE = 'positive'
30+
""" Зелёная """
2331

2432

2533
class VkKeyboard(object):
@@ -54,14 +62,14 @@ def get_empty_keyboard(cls):
5462
keyboard.keyboard['buttons'] = []
5563
return keyboard.get_keyboard()
5664

57-
def add_button(self, label, color=KeyboardColor.DEFAULT, payload=None):
65+
def add_button(self, label, color=VkKeyboardColor.DEFAULT, payload=None):
5866
""" Добавить кнопку. Максимальное количество кнопок на строке - 4
5967
6068
:param label: Надпись на кнопке и текст, отправляющийся при её нажатии.
6169
:type label: str
6270
6371
:param color: цвет кнопки.
64-
:type color: KeyboardColor or str
72+
:type color: VkKeyboardColor or str
6573
6674
:param payload: Параметр для callback api
6775
:type payload: str or list or dict
@@ -74,7 +82,7 @@ def add_button(self, label, color=KeyboardColor.DEFAULT, payload=None):
7482

7583
color_value = color
7684

77-
if isinstance(color, KeyboardColor):
85+
if isinstance(color, VkKeyboardColor):
7886
color_value = color_value.value
7987

8088
if payload is not None and not isinstance(payload, six.string_types):

vk_api/streaming.py

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
import json
1313

1414

15-
URL_TEMPLATE = "{schema}://{server}/{method}?key={key}"
16-
1715

1816
class VkStreaming(object):
1917

2018
__slots__ = ('vk', 'url', 'key', 'server')
2119

20+
URL_TEMPLATE = '{schema}://{server}/{method}?key={key}'
21+
2222
def __init__(self, vk):
2323
"""
2424
:param vk: объект VkApi
@@ -38,60 +38,60 @@ def update_streaming_server(self):
3838
self.server = response['endpoint']
3939

4040
def get_rules(self):
41-
response = self.vk.http.get(URL_TEMPLATE.format(
42-
schema="https",
41+
response = self.vk.http.get(self.URL_TEMPLATE.format(
42+
schema='https',
4343
server=self.server,
44-
method="rules",
44+
method='rules',
4545
key=self.key)
4646
).json()
4747

48-
if response["code"] == 200:
48+
if response['code'] == 200:
4949
return response['rules'] or []
50-
elif response["code"] == 400:
50+
elif response['code'] == 400:
5151
raise VkStreamingError(response['error'])
5252

5353
def add_rule(self, value, tag):
54-
response = self.vk.http.post(URL_TEMPLATE.format(
55-
schema="https",
54+
response = self.vk.http.post(self.URL_TEMPLATE.format(
55+
schema='https',
5656
server=self.server,
57-
method="rules",
57+
method='rules',
5858
key=self.key),
59-
json={"rule": {"value": value, "tag": tag}}
59+
json={'rule': {'value': value, 'tag': tag}}
6060
).json()
6161

62-
if response["code"] == 200:
62+
if response['code'] == 200:
6363
return True
64-
elif response["code"] == 400:
64+
elif response['code'] == 400:
6565
raise VkStreamingError(response['error'])
6666

6767
def delete_rule(self, tag):
68-
response = self.vk.http.delete(URL_TEMPLATE.format(
69-
schema="https",
68+
response = self.vk.http.delete(self.URL_TEMPLATE.format(
69+
schema='https',
7070
server=self.server,
71-
method="rules",
71+
method='rules',
7272
key=self.key),
73-
json={"tag": tag}
73+
json={'tag': tag}
7474
).json()
7575

76-
if response["code"] == 200:
76+
if response['code'] == 200:
7777
return True
78-
elif response["code"] == 400:
78+
elif response['code'] == 400:
7979
raise VkStreamingError(response['error'])
8080

8181
def listen(self):
82-
ws = websocket.create_connection(URL_TEMPLATE.format(
83-
schema="wss",
82+
ws = websocket.create_connection(self.URL_TEMPLATE.format(
83+
schema='wss',
8484
server=self.server,
85-
method="stream",
86-
key=self.key)
87-
)
85+
method='stream',
86+
key=self.key
87+
))
8888

8989
while True:
90-
response = ws.recv()
91-
response = json.loads(response)
92-
if response["code"] == 100:
93-
yield response["event"]
94-
elif response["code"] == 300:
90+
response = json.loads(ws.recv())
91+
92+
if response['code'] == 100:
93+
yield response['event']
94+
elif response['code'] == 300:
9595
raise VkStreamingServiceMessage(response['service_message'])
9696

9797

@@ -113,5 +113,4 @@ def __init__(self, error):
113113
self.message = error['message']
114114

115115
def __str__(self):
116-
return '[{}] {}'.format(self.service_code,
117-
self.message)
116+
return '[{}] {}'.format(self.service_code, self.message)

vk_api/tools.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class VkTools(object):
1515
""" Содержит некоторые вспомогательные функции, которые могут понадобиться
16-
при использовании API
16+
при использовании API
1717
1818
:param vk: Объект :class:`VkApi`
1919
"""
@@ -26,8 +26,9 @@ def __init__(self, vk):
2626
def get_all_iter(self, method, max_count, values=None, key='items',
2727
limit=None, stop_fn=None, negative_offset=False):
2828
""" Получить все элементы.
29-
Работает в методах, где в ответе есть count и items или users.
30-
За один запрос получает max_count * 25 элементов
29+
30+
Работает в методах, где в ответе есть count и items или users.
31+
За один запрос получает max_count * 25 элементов
3132
3233
:param method: имя метода
3334
:type method: str
@@ -91,8 +92,7 @@ def get_all_iter(self, method, max_count, values=None, key='items',
9192

9293
def get_all(self, method, max_count, values=None, key='items', limit=None,
9394
stop_fn=None, negative_offset=False):
94-
"""
95-
Использовать только если нужно загрузить все объекты в память.
95+
""" Использовать только если нужно загрузить все объекты в память.
9696
9797
Eсли вы можете обрабатывать объекты по частям, то лучше
9898
использовать get_all_iter
@@ -112,7 +112,8 @@ def get_all(self, method, max_count, values=None, key='items', limit=None,
112112
def get_all_slow_iter(self, method, max_count, values=None, key='items',
113113
limit=None, stop_fn=None, negative_offset=False):
114114
""" Получить все элементы (без использования execute)
115-
Работает в методах, где в ответе есть count и items или users
115+
116+
Работает в методах, где в ответе есть count и items или users
116117
117118
:param method: имя метода
118119
:type method: str
@@ -182,8 +183,7 @@ def get_all_slow_iter(self, method, max_count, values=None, key='items',
182183

183184
def get_all_slow(self, method, max_count, values=None, key='items',
184185
limit=None, stop_fn=None, negative_offset=False):
185-
"""
186-
Использовать только если нужно загрузить все объекты в память.
186+
""" Использовать только если нужно загрузить все объекты в память.
187187
188188
Eсли вы можете обрабатывать объекты по частям, то лучше
189189
использовать get_all_slow_iter

0 commit comments

Comments
 (0)