Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.
/ relationships Public archive

redis backed user relationships on its simplest form.

License

Notifications You must be signed in to change notification settings

emre/relationships

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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?

About

redis backed user relationships on its simplest form.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages