Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ upload_to_PyPi.py
.project
.pydevproject
.settings/
.idea/
17 changes: 8 additions & 9 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# file GENERATED by distutils, do NOT edit
setup.py
jconfig\__init__.py
jconfig\jconfig.py
test\test.py
vk_api\__init__.py
vk_api\vk_api.py
vk_api\upload\__init__.py
vk_api\upload\vk_upload.py
# file GENERATED by distutils, do NOT edit
setup.py
jconfig\__init__.py
jconfig\jconfig.py
test\test.py
vk_api\__init__.py
vk_api\vk_api.py
vk_api\vk_upload.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vk_api

**vk_api** - модуль для использования API сайта ВКонтакте (vk.com). Пример смотрите в файле [example.py](https://github.com/python273/vk_api/blob/master/example.py)

Тестовая поддержка **Python 3**!
Python 2 / 3

С вопросами или советами можете [написать автору в ВК](https://vk.com/im?sel=183433824).

Expand Down
68 changes: 36 additions & 32 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
'''
@author: Kirill Python
@contact: http://vk.com/python273
@license Apache License, Version 2.0, see LICENSE file

Copyright (C) 2013
'''

# -*- coding: utf-8 -*-
import vk_api


def main():
u""" Пример получения последнего сообщения со стены """

login = u'python@vk.com'
password = u'mypassword'

try:
vk = vk_api.VkApi(login, password) # Авторизируемся
except vk_api.authorization_error as error_msg:
print(error_msg) # В случае ошибки выведем сообщение
return # и выйдем

values = {
'count': 1 # Получаем только одно сообщение
}
response = vk.method('wall.get', values) # Используем метод wall.get
print(response[1]['text']) # Печатаем текст последнего поста со стены

if __name__ == '__main__':
main()
# -*- coding: utf-8 -*-

'''
@author: Kirill Python
@contact: http://vk.com/python273
@license Apache License, Version 2.0, see LICENSE file

Copyright (C) 2013
'''

import vk_api


def main():
u""" Пример получения последнего сообщения со стены """

login = u'python@vk.com'
password = u'mypassword'

try:
vk = vk_api.VkApi(login, password) # Авторизируемся
except vk_api.AuthorizationError as error_msg:
print(error_msg) # В случае ошибки выведем сообщение
return # и выйдем

values = {
'count': 1 # Получаем только один пост
}
response = vk.method('wall.get', values) # Используем метод wall.get

if response['items']:
# Печатаем текст последнего поста со стены
print(response['items'][0]['text'])

if __name__ == '__main__':
main()
40 changes: 21 additions & 19 deletions jconfig/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
'''
@author: Kirill Python
@contact: http://vk.com/python273
@license Apache License, Version 2.0, see LICENSE file

Copyright (C) 2013
'''

__author__ = "Kirill Python"
__version__ = "1.1"
__email__ = "mikeking568@gmail.com"
__contact__ = "https://vk.com/python273"


import sys
if sys.version_info[0] == 2:
from jconfig import *
else:
from .jconfig import *
# -*- coding: utf-8 -*-

'''
@author: Kirill Python
@contact: http://vk.com/python273
@license Apache License, Version 2.0, see LICENSE file

Copyright (C) 2013
'''

__author__ = "Kirill Python"
__version__ = "1.1"
__email__ = "mikeking568@gmail.com"
__contact__ = "https://vk.com/python273"


import sys
if sys.version_info[0] == 2:
from jconfig import *
else:
from .jconfig import *
85 changes: 43 additions & 42 deletions jconfig/jconfig.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
'''
@author: Kirill Python
@contact: http://vk.com/python273
@license Apache License, Version 2.0, see LICENSE file

Copyright (C) 2013
'''

# -*- coding: utf-8 -*-
import os
import json


class config:
def __init__(self, section, filename='config'):
self.section = section # Секция настроек
self.filename = filename # Файл с настройками
self.all = self.parse() # Все настройки
self.settings = self.all.get(section, {}) # Настройки секции

def __getitem__(self, item):
return self.settings.get(item, {})

def __setitem__(self, key, value):
self.settings.update({key: value})
self.all.update({self.section: self.settings})
self.update(self.all)

def parse(self):
fileis = os.path.exists(self.filename)
if fileis:
settings = json.load(open(self.filename, 'r'))
return settings
else:
self.update()
return {}

def update(self, settings=None):
if not settings:
settings = {}

json.dump(settings, open(self.filename, 'w'))
# -*- coding: utf-8 -*-

'''
@author: Kirill Python
@contact: http://vk.com/python273
@license Apache License, Version 2.0, see LICENSE file

Copyright (C) 2013
'''

import os
import json


class Config(object):
def __init__(self, section, filename='config'):
self.section = section # Секция настроек
self.filename = filename # Файл с настройками
self.all = self.parse() # Все настройки
self.settings = self.all.get(section, {}) # Настройки секции

def __getitem__(self, item):
return self.settings.get(item, {})

def __setitem__(self, key, value):
self.settings.update({key: value})
self.all.update({self.section: self.settings})
self.update(self.all)

def parse(self):
fileis = os.path.exists(self.filename)
if fileis:
settings = json.load(open(self.filename, 'r'))
return settings
else:
self.update()
return {}

def update(self, settings=None):
if not settings:
settings = {}

json.dump(settings, open(self.filename, 'w'))
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
@author: Kirill Python
@contact: http://vk.com/python273
Expand All @@ -6,13 +9,10 @@
Copyright (C) 2013
'''

#!/usr/bin/env python
""" Setup file for vk_api package """

from distutils.core import setup
setup(name='vk_api',
version='4.6',
description='Module to use API VKontakte vk.com',
version='4.7',
description='Module to use API vk.com',
author='Kirill Python',
author_email='mikeking568@gmail.com',
url='https://github.com/python273/vk_api',
Expand Down
6 changes: 5 additions & 1 deletion vk_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

'''
@author: Kirill Python
@contact: http://vk.com/python273
Expand All @@ -7,7 +9,7 @@
'''

__author__ = "Kirill Python"
__version__ = "4.6"
__version__ = "4.6.6"
__email__ = "mikeking568@gmail.com"
__contact__ = "https://vk.com/python273"

Expand All @@ -16,6 +18,8 @@
if sys.version_info[0] == 2:
from vk_api import *
from vk_upload import *
from vk_tools import *
else:
from .vk_api import *
from .vk_upload import *
from .vk_tools import *
Loading