relationships

redis backed user relationships


License
MIT
Install
pip install relationships==0.0.1

Documentation

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?