Commit | Line | Data |
---|---|---|
7a31b4aa MM |
1 | #### `Stream()` object |
2 | ||
3 | This object is used to represent user's stream on D\*. | |
cc8bef9e | 4 | It is basically a list of posts. |
7a31b4aa MM |
5 | |
6 | ---- | |
7 | ||
8 | ##### Getting stream | |
9 | ||
10 | To get basic stream you have to have working `Connection()` as | |
11 | this is required by `Stream()`'s constructor. | |
12 | ||
13 | c = diaspy.connection.Connection(pod='https://pod.example.com', | |
14 | username='foo', | |
15 | password='bar') | |
16 | c.login() | |
cc8bef9e | 17 | stream = diaspy.streams.Stream(c) |
7a31b4aa | 18 | |
cc8bef9e C |
19 | Now you have a stream filled with posts (if any can be found on user's |
20 | stream). | |
21 | ||
22 | Other streams you can use are `Activity()`, `Aspects()`, `Commented()`, | |
23 | `Liked()`, `Mentions()`, `FollowedTags()` and `Tag()`. | |
24 | ||
25 | Example: `stream = diaspy.streams.Activity(c)` | |
7a31b4aa MM |
26 | |
27 | ---- | |
28 | ||
6d8d47ce | 29 | ##### `fill()`, `update()` and `more()` |
cdbe5f4e | 30 | |
cc8bef9e C |
31 | When you want to refresh stream call it's `fill()` method. It will |
32 | overwrite old stream contents. | |
cdbe5f4e | 33 | |
cc8bef9e C |
34 | On the contrary, `update()` will get a new stream but will not overwrite |
35 | old stream saved in the object memory. It will append every new post to | |
36 | the old stream. | |
cdbe5f4e | 37 | |
cc8bef9e C |
38 | `more()` complements `update()` it will fetch you older posts instead of |
39 | newer ones. | |
6d8d47ce | 40 | |
cdbe5f4e MM |
41 | ---- |
42 | ||
43 | ##### Length of and iterating over a stream | |
7a31b4aa MM |
44 | |
45 | Stream's length can be checked by calling `len()` on it. | |
46 | ||
47 | len(stream) | |
48 | 10 | |
cdbe5f4e | 49 | |
cc8bef9e C |
50 | When you want to iterate over a stream (e.g. when you want to print |
51 | first *n* posts on the stream) you can do it in two ways. | |
cdbe5f4e MM |
52 | |
53 | First, using `len()` and `range()` functions. | |
54 | ||
55 | for i in range(len(stream)): | |
56 | # do stuff... | |
57 | ||
58 | Second, iterating directly over the stream contents: | |
59 | ||
60 | for post in stream: | |
61 | # do stuff... | |
62 | ||
63 | ||
8b013ef4 MM |
64 | ---- |
65 | ||
66 | ##### Posting data to stream | |
67 | ||
cc8bef9e C |
68 | This is described in [`posting`](./posting.markdown) document in this |
69 | manual. | |
8b013ef4 | 70 | |
6d8d47ce MM |
71 | |
72 | ---- | |
73 | ||
74 | ##### Clearing stream | |
75 | ||
76 | ##### `clear()` | |
77 | ||
78 | This will remove all posts from visible stream. | |
79 | ||
80 | ##### `purge()` | |
81 | ||
cc8bef9e C |
82 | This will scan stream for nonexistent posts (eg. deleted) and remove |
83 | them. | |
6d8d47ce | 84 | |
cdbe5f4e MM |
85 | ---- |
86 | ||
87 | ###### Manual for `diaspy`, written by Marek Marecki |