Skip to content

Commit 77b5a0d

Browse files
authored
Рефракторинг (#499)
1 parent a5f545f commit 77b5a0d

20 files changed

+108
-252
lines changed

examples/bot_longpoll.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ def main():
2323
print(event.obj.from_id)
2424

2525
print('Текст:', event.obj.text)
26-
print()
27-
2826
elif event.type == VkBotEventType.MESSAGE_REPLY:
2927
print('Новое сообщение:')
3028

@@ -33,8 +31,6 @@ def main():
3331
print(event.obj.peer_id)
3432

3533
print('Текст:', event.obj.text)
36-
print()
37-
3834
elif event.type == VkBotEventType.MESSAGE_TYPING_STATE:
3935
print('Печатает ', end='')
4036

@@ -43,23 +39,18 @@ def main():
4339
print('для ', end='')
4440

4541
print(event.obj.to_id)
46-
print()
47-
4842
elif event.type == VkBotEventType.GROUP_JOIN:
4943
print(event.obj.user_id, end=' ')
5044

5145
print('Вступил в группу!')
52-
print()
53-
5446
elif event.type == VkBotEventType.GROUP_LEAVE:
5547
print(event.obj.user_id, end=' ')
5648

5749
print('Покинул группу!')
58-
print()
59-
6050
else:
6151
print(event.type)
62-
print()
52+
53+
print()
6354

6455

6556
if __name__ == '__main__':

examples/get_album_audio.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main():
2929
tracks = vkaudio.get(album_id=albums[0]['id'])
3030

3131
for n, track in enumerate(tracks, 1):
32-
print('{}. {} {}'.format(n, track['title'], track['url']))
32+
print(f"{n}. {track['title']} {track['url']}")
3333

3434

3535
if __name__ == '__main__':

examples/get_all_audio.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ def main():
2626
# Составляем рейтинг первых 15
2727
print('Top 15:')
2828
for artist, tracks in artists.most_common(15):
29-
print('{} - {} tracks'.format(artist, tracks))
29+
print(f'{artist} - {tracks} tracks')
3030

3131
# Ищем треки самого популярного
3232
most_common_artist = artists.most_common(1)[0][0]
3333

34-
print('\nSearching for {}:'.format(most_common_artist))
34+
print(f'\nSearching for {most_common_artist}:')
3535

3636
tracks = vkaudio.search(q=most_common_artist, count=10)
3737

3838
for n, track in enumerate(tracks, 1):
39-
print('{}. {} {}'.format(n, track['title'], track['url']))
39+
print(f"{n}. {track['title']} {track['url']}")
4040

4141

4242
if __name__ == '__main__':

examples/messages_bot/user_messages_bot.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def main():
3636

3737
for event in longpoll.listen():
3838
if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
39-
print('id{}: "{}"'.format(event.user_id, event.text), end=' ')
39+
print(f'id{event.user_id}: "{event.text}"', end=' ')
4040

4141
response = session.get(
4242
'http://api.duckduckgo.com/',
@@ -64,9 +64,7 @@ def main():
6464
image = session.get(image_url, stream=True)
6565
photo = upload.photo_messages(photos=image.raw)[0]
6666

67-
attachments.append(
68-
'photo{}_{}'.format(photo['owner_id'], photo['id'])
69-
)
67+
attachments.append(f"photo{photo['owner_id']}_{photo['id']}")
7068

7169
vk.messages.send(
7270
user_id=event.user_id,

examples/requests_pool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ def main():
106106

107107

108108
if __name__ == '__main__':
109-
main()
109+
main()

examples/upload_photo.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def main():
2525
group_id=74030368
2626
)
2727

28-
vk_photo_url = 'https://vk.com/photo{}_{}'.format(
29-
photo[0]['owner_id'], photo[0]['id']
30-
)
28+
vk_photo_url = f"https://vk.com/photo{photo[0]['owner_id']}_{photo[0]['id']}"
3129

3230
print(photo, '\nLink: ', vk_photo_url)
3331

setup.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,23 @@
1919
setup(
2020
name='vk_api',
2121
version=version,
22-
2322
author='python273',
2423
author_email='vk_api@python273.pw',
25-
2624
description=(
2725
'Python модуль для создания скриптов для социальной сети '
2826
'Вконтакте (vk.com API wrapper)'
2927
),
3028
long_description=long_description,
3129
long_description_content_type='text/markdown',
32-
3330
url='https://github.com/python273/vk_api',
34-
download_url='https://github.com/python273/vk_api/archive/v{}.zip'.format(
35-
version
36-
),
37-
31+
download_url=f'https://github.com/python273/vk_api/archive/v{version}.zip',
3832
license='Apache License, Version 2.0, see LICENSE file',
39-
4033
packages=['vk_api', 'jconfig'],
4134
install_requires=['requests'],
4235
extras_require={
4336
'vkstreaming': ['websocket-client'],
4437
'vkaudio': ['beautifulsoup4'],
4538
},
46-
4739
classifiers=[
4840
'License :: OSI Approved :: Apache Software License',
4941
'Operating System :: OS Independent',
@@ -54,5 +46,5 @@
5446
'Programming Language :: Python :: 3.8',
5547
'Programming Language :: Python :: 3.9',
5648
'Programming Language :: Python :: 3.10',
57-
]
49+
],
5850
)

0 commit comments

Comments
 (0)