Skip to content

Commit cc054e8

Browse files
committed
Add ability to use snake case with VkApiMethod
1 parent 5394ad1 commit cc054e8

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

vk_api/vk_api.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,13 @@ def method(self, method, values=None, captcha_sid=None, captcha_key=None,
595595

596596

597597
class VkApiMethod(object):
598+
""" Дает возможность обращаться к методам API через:
599+
600+
>>> vk = VkApiMethod(...)
601+
>>> vk.wall.getById(posts='...')
602+
или
603+
>>> vk.wall.get_by_id(posts='...')
604+
"""
598605

599606
__slots__ = ('_vk', '_method')
600607

@@ -603,6 +610,10 @@ def __init__(self, vk, method=None):
603610
self._method = method
604611

605612
def __getattr__(self, method):
613+
if '_' in method:
614+
m = method.split('_')
615+
method = m[0] + ''.join(i.title() for i in m[1:])
616+
606617
return VkApiMethod(
607618
self._vk,
608619
(self._method + '.' if self._method else '') + method

0 commit comments

Comments
 (0)