Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emre/relationships
redis backed user relationships on its simplest form.
https://github.com/emre/relationships
Last synced: about 2 months ago
JSON representation
redis backed user relationships on its simplest form.
- Host: GitHub
- URL: https://github.com/emre/relationships
- Owner: emre
- License: mit
- Archived: true
- Created: 2015-08-05T05:51:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-18T04:05:48.000Z (over 7 years ago)
- Last Synced: 2024-07-24T14:00:49.315Z (about 2 months ago)
- Language: Python
- Homepage:
- Size: 150 KB
- Stars: 76
- Watchers: 7
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
relationships
---
redis backed user relationships on its simplest form.####installation
```bash
$ [sudo] pip install relationships
```
or if you like 90s:
```bash
$ [sudo] easy_install relationships
```####usage
**getting the Relationship class**
```python
from relationships import Relationship
r = Relationship()
```**follow**
```python
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**
```python
r('Guido').unfollow("Rasmus")
```**block**
```python
r('Guido').block("Guido")
r('Rasmus').block("Guido")
```**unblock**
```python
r('Rasmus').unblock('Guido')
```**getting friends**
```python
r('Guido').friends()
``````bash
>>> {'Larry', 'Rasmus'}
```**getting mutual friends**
```python
r('Guido').mutual_friends('Rasmus')
```**getting followers**
```python
r("Guido").followers()
``````bash
>>> {'Dave', 'Larry', 'Rasmus'}
```
**getting followings**```python
r("Guido").following()
``````bash
>>> {'Larry', 'Rasmus'}
```
**getting a simple graph of spesific user**
```pythonr('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**
```python
# people blocked by guido
r('Guido').blocks()
``````bash
>>> {'Rasmus'}
```**getting blocked list by user**
```python
# people who blocked Guido
r('Guido').blocked()
``````bash
>>> {'Rasmus'}
```**counts**
```python
r('Guido').block_count() # count of people blocked by Guido
r('Guido').blocked_count() # count of people who blocked Guidor('Guido').follower_count() # count of people who follows Guido
r('Guido').following_count() # count of people following by Guido
```**checks**
```python
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?
```