Downloads data about friends from social networks (vk.com and twitter) and makes CSV file for exporting into google contacts.
./address_book_console.py --vk VK_ID --twitter Twitter_ID [--output FILE]
or
./address_book_gui.py
and then add VK
and Twitter
friends. Then click merge
. And, finally, save
button.
./address_book_console.py --vk 44232785 --twitter 891227432
--vk id
— id of vk.com user, whose friends would be imported--twitter id
— id of twitter user, whose friends would be imported--output filename
— name of CSV file
pip3 install TwitterAPI
Test for this project
Subsidiary functions.
translit(string)
— translitiratesstring
from English to Russiandistance(a, b)
— Calculates the Levenshtein distance between a and bextract_name_parts(fullname)
— splitsfullname
into first name and last nameextract_phone(input_string)
— extracts phone number frominput_string
extract_date(input_string)
— extracts datetime frominput_string
normalize_name(input_string)
— extracts datetime frominput_string
get_input(question, choice=('y', 'n'))
— printsquestion
into console until the answer isn't inchoice
equal(val1, val2)
— returns similarity coefficient ofval1
andval2
absolutely_equal(val1, val2)
— return 1 ifval1
is equal toval2
and 0 otherwiseVK_API
— class for getting friends from vk.com:get_friends(user_id)
returns friend list of user withuser_id
Twitter_API
— class for getting friends from twitter.com:get_friends(user_id)
returns friend list of user withuser_id
CSV_Generator
— class for generating CSV-data
Describes classes for handling friend info.
- Friend — general friend class
__init__(**kwargs)
— accepts userdata as**kwargs
dictmerge(other)
— mergesself
andother
or raisesValueError
is_mergeble(other)
— checks if it is possible to mergeself
andother
automaticallyis_similar(other)
— checks ifself
andother
look similar (may be need to be merged)
- VK_Friend(Friend) — vk friend class inherited from
Friend
.__init__(**kwargs)
— accepts data in format of VK API.
- Twitter_Friend(Friend) — twitter friend class inherited from
Friend
.__init__(**kwargs)
— accepts data in format of Twitter API.
Describes AddressBook main class (implementation should be inherited from this one).
AddressBook
— main class_wrong_id()
— abstract method, describes program behavior if either twitter or vk id is wrongsave_CSV(filename=None)
— abstract method, saves result CSV fileget_friends()
— abstract method, gets user id and returns friend list_merge_friends(friend1, friend2)
— abstract method, returns Friend object, merged fromfriend1
andfriend2
merge_friend_list()
— abstract method, merges all friends in self friend list_merge_friend_lists(friends, set_percentage=None)
— merges friends infriends
list. Callsset_percentage(percentage)
on each step.