relationships

redis backed user relationships on its simplest form.

installation

$ [sudo] pip install relationships

or if you like 90s:

$ [sudo] easy_install relationships

usage

getting the Relationship class

from relationships import Relationship
r = Relationship()

follow

r('Guido').follow('Rasmus')
r('Guido').follow('Larry')
r('Larry').follow('Guido')
r('Rasmus').follow('Guido')
r('Dave').follow('Guido')
r('Larry').follow('Guido')

unfollow

r('Guido').unfollow("Rasmus")

block

r('Guido').block("Guido")
r('Rasmus').block("Guido")

unblock

r('Rasmus').unblock('Guido')

getting friends

r('Guido').friends()
>>> {'Larry', 'Rasmus'}

getting mutual friends

r('Guido').mutual_friends('Rasmus')

getting followers

r("Guido").followers()
>>> {'Dave', 'Larry', 'Rasmus'}

getting followings

r("Guido").following()
>>> {'Larry', 'Rasmus'}

getting a simple graph of spesific user

r('Zlatan Ibrahimovic').follow("Galatasaray")
r('Galatasaray').follow("Zlatan Ibrahimovic")
r('Galatasaray').follow("Podolski")
r('Galatasaray').follow("Drogba")
r('Galatasaray').follow("Sneijder")
r('Galatasaray').follow("Zlatan Ibrahimovic")
r('Sneijder').follow("Galatasaray")
r('Podolski').follow("Galatasaray")

r("Galatasaray").get_network("/tmp/galatasaray_network.png")

(you need graphviz (system library) and pydot (pylibrary) installed to get this functionality.

getting block list by user

# people blocked by guido
r('Guido').blocks()
>>> {'Rasmus'}

getting blocked list by user

# people who blocked Guido
r('Guido').blocked()
>>> {'Rasmus'}

counts

r('Guido').block_count() # count of people blocked by Guido
r('Guido').blocked_count() # count of people who blocked Guido

r('Guido').follower_count() # count of people who follows Guido
r('Guido').following_count() # count of people following by Guido

checks

r('Guido').is_following('Rasmus') # does Guido follows Rasmus?
r('Rasmus').is_follower('Guido') # is Rasmus a follower of Guido?

r('Guido').is_blocked('Rasmus') # did Guido blocked Rasmus?
r('Rasmus').is_blocked_by('Guido') # is Rasmus blocked by Guido?
::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

大妈的多重宇宙 - YouTube

全新自媒体:科幻/读书/说故事...欢迎订阅;

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:
Zoom.Quiet’s Chaos42 | Substack


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet



粤ICP备18025058号-1
公安备案号: 44049002000656 ...::