tinystream 0.1.12__tar.gz → 0.1.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tinystream-0.1.12/tinystream.egg-info → tinystream-0.1.13}/PKG-INFO +15 -5
- {tinystream-0.1.12 → tinystream-0.1.13}/README.md +14 -4
- {tinystream-0.1.12 → tinystream-0.1.13}/setup.py +1 -1
- {tinystream-0.1.12 → tinystream-0.1.13/tinystream.egg-info}/PKG-INFO +15 -5
- {tinystream-0.1.12 → tinystream-0.1.13}/tinystream.py +4 -1
- {tinystream-0.1.12 → tinystream-0.1.13}/LICENSE +0 -0
- {tinystream-0.1.12 → tinystream-0.1.13}/setup.cfg +0 -0
- {tinystream-0.1.12 → tinystream-0.1.13}/tinystream.egg-info/SOURCES.txt +0 -0
- {tinystream-0.1.12 → tinystream-0.1.13}/tinystream.egg-info/dependency_links.txt +0 -0
- {tinystream-0.1.12 → tinystream-0.1.13}/tinystream.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tinystream
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.13
|
|
4
4
|
Summary: Yet another python streams library
|
|
5
5
|
Home-page: https://github.com/mreiche/python-streams
|
|
6
6
|
Author: Mike Reiche
|
|
@@ -24,9 +24,9 @@ from tinystream import Stream
|
|
|
24
24
|
stream = Stream([1, 2, 3, 4, 5]) # Stream.of_many(*), Stream.of_dict()
|
|
25
25
|
|
|
26
26
|
stream \
|
|
27
|
-
.map(lambda x: x + 1) \ # flatmap(), peek(), map_key()
|
|
27
|
+
.map(lambda x: x + 1) \ # flatmap(), peek(), map_key(), map_kwargs(), map_keys()
|
|
28
28
|
.filter(lambda x: x > 2) \ # filter_key(), filter_type()
|
|
29
|
-
.sorted(
|
|
29
|
+
.sorted(reverse=True) \ # sort()
|
|
30
30
|
.reverse() \
|
|
31
31
|
.limit(2) \
|
|
32
32
|
.concat([4]) \
|
|
@@ -61,7 +61,7 @@ assert Opt(None).absent
|
|
|
61
61
|
|
|
62
62
|
Map *optional*:
|
|
63
63
|
```python
|
|
64
|
-
assert Opt("String").len == 6
|
|
64
|
+
assert Opt("String").map(str.lower).len == 6
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Get default value:
|
|
@@ -155,7 +155,7 @@ list = [
|
|
|
155
155
|
{"node": Node(name="Node C")},
|
|
156
156
|
{"node": Node(name="Node D")},
|
|
157
157
|
]
|
|
158
|
-
Stream(list).map_keys("node", "name")
|
|
158
|
+
names = Stream(list).map_keys("node", "name")
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
### Collected join
|
|
@@ -164,6 +164,16 @@ Stream(list).map_keys("node", "name")
|
|
|
164
164
|
all_names = Stream([child]).map_key("name").join(", ")
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
+
### Map kwargs
|
|
168
|
+
```python
|
|
169
|
+
list = [
|
|
170
|
+
{"name": "Node A"},
|
|
171
|
+
{"name": "Node B"},
|
|
172
|
+
]
|
|
173
|
+
# Short cut for map(lambda x: Node(**x))
|
|
174
|
+
nodes = Stream(list).map_kwargs(Node)
|
|
175
|
+
```
|
|
176
|
+
|
|
167
177
|
### Stream many
|
|
168
178
|
|
|
169
179
|
```python
|
|
@@ -15,9 +15,9 @@ from tinystream import Stream
|
|
|
15
15
|
stream = Stream([1, 2, 3, 4, 5]) # Stream.of_many(*), Stream.of_dict()
|
|
16
16
|
|
|
17
17
|
stream \
|
|
18
|
-
.map(lambda x: x + 1) \ # flatmap(), peek(), map_key()
|
|
18
|
+
.map(lambda x: x + 1) \ # flatmap(), peek(), map_key(), map_kwargs(), map_keys()
|
|
19
19
|
.filter(lambda x: x > 2) \ # filter_key(), filter_type()
|
|
20
|
-
.sorted(
|
|
20
|
+
.sorted(reverse=True) \ # sort()
|
|
21
21
|
.reverse() \
|
|
22
22
|
.limit(2) \
|
|
23
23
|
.concat([4]) \
|
|
@@ -52,7 +52,7 @@ assert Opt(None).absent
|
|
|
52
52
|
|
|
53
53
|
Map *optional*:
|
|
54
54
|
```python
|
|
55
|
-
assert Opt("String").len == 6
|
|
55
|
+
assert Opt("String").map(str.lower).len == 6
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Get default value:
|
|
@@ -146,7 +146,7 @@ list = [
|
|
|
146
146
|
{"node": Node(name="Node C")},
|
|
147
147
|
{"node": Node(name="Node D")},
|
|
148
148
|
]
|
|
149
|
-
Stream(list).map_keys("node", "name")
|
|
149
|
+
names = Stream(list).map_keys("node", "name")
|
|
150
150
|
```
|
|
151
151
|
|
|
152
152
|
### Collected join
|
|
@@ -155,6 +155,16 @@ Stream(list).map_keys("node", "name")
|
|
|
155
155
|
all_names = Stream([child]).map_key("name").join(", ")
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
+
### Map kwargs
|
|
159
|
+
```python
|
|
160
|
+
list = [
|
|
161
|
+
{"name": "Node A"},
|
|
162
|
+
{"name": "Node B"},
|
|
163
|
+
]
|
|
164
|
+
# Short cut for map(lambda x: Node(**x))
|
|
165
|
+
nodes = Stream(list).map_kwargs(Node)
|
|
166
|
+
```
|
|
167
|
+
|
|
158
168
|
### Stream many
|
|
159
169
|
|
|
160
170
|
```python
|
|
@@ -10,7 +10,7 @@ setup(
|
|
|
10
10
|
description="Yet another python streams library",
|
|
11
11
|
long_description=long_description,
|
|
12
12
|
long_description_content_type="text/markdown",
|
|
13
|
-
version="0.1.
|
|
13
|
+
version="0.1.13",
|
|
14
14
|
url="https://github.com/mreiche/python-streams",
|
|
15
15
|
author="Mike Reiche",
|
|
16
16
|
py_modules=['tinystream'],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tinystream
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.13
|
|
4
4
|
Summary: Yet another python streams library
|
|
5
5
|
Home-page: https://github.com/mreiche/python-streams
|
|
6
6
|
Author: Mike Reiche
|
|
@@ -24,9 +24,9 @@ from tinystream import Stream
|
|
|
24
24
|
stream = Stream([1, 2, 3, 4, 5]) # Stream.of_many(*), Stream.of_dict()
|
|
25
25
|
|
|
26
26
|
stream \
|
|
27
|
-
.map(lambda x: x + 1) \ # flatmap(), peek(), map_key()
|
|
27
|
+
.map(lambda x: x + 1) \ # flatmap(), peek(), map_key(), map_kwargs(), map_keys()
|
|
28
28
|
.filter(lambda x: x > 2) \ # filter_key(), filter_type()
|
|
29
|
-
.sorted(
|
|
29
|
+
.sorted(reverse=True) \ # sort()
|
|
30
30
|
.reverse() \
|
|
31
31
|
.limit(2) \
|
|
32
32
|
.concat([4]) \
|
|
@@ -61,7 +61,7 @@ assert Opt(None).absent
|
|
|
61
61
|
|
|
62
62
|
Map *optional*:
|
|
63
63
|
```python
|
|
64
|
-
assert Opt("String").len == 6
|
|
64
|
+
assert Opt("String").map(str.lower).len == 6
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Get default value:
|
|
@@ -155,7 +155,7 @@ list = [
|
|
|
155
155
|
{"node": Node(name="Node C")},
|
|
156
156
|
{"node": Node(name="Node D")},
|
|
157
157
|
]
|
|
158
|
-
Stream(list).map_keys("node", "name")
|
|
158
|
+
names = Stream(list).map_keys("node", "name")
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
### Collected join
|
|
@@ -164,6 +164,16 @@ Stream(list).map_keys("node", "name")
|
|
|
164
164
|
all_names = Stream([child]).map_key("name").join(", ")
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
+
### Map kwargs
|
|
168
|
+
```python
|
|
169
|
+
list = [
|
|
170
|
+
{"name": "Node A"},
|
|
171
|
+
{"name": "Node B"},
|
|
172
|
+
]
|
|
173
|
+
# Short cut for map(lambda x: Node(**x))
|
|
174
|
+
nodes = Stream(list).map_kwargs(Node)
|
|
175
|
+
```
|
|
176
|
+
|
|
167
177
|
### Stream many
|
|
168
178
|
|
|
169
179
|
```python
|
|
@@ -218,6 +218,9 @@ class Stream(Iterator[T]):
|
|
|
218
218
|
def map(self, mapper: Mapper[T, R]):
|
|
219
219
|
return Stream[R](map(mapper, self))
|
|
220
220
|
|
|
221
|
+
def map_kwargs(self, mapper: Type[R]) -> "Stream[R]":
|
|
222
|
+
return self.map(lambda x: mapper(**x))
|
|
223
|
+
|
|
221
224
|
def map_key(self, key: str | int):
|
|
222
225
|
return self.filter_key(key).map(lambda x: _map_key(x, key))
|
|
223
226
|
|
|
@@ -264,7 +267,7 @@ class Stream(Iterator[T]):
|
|
|
264
267
|
sort = sorted(self.__iterable, key=key, reverse=reverse)
|
|
265
268
|
return Stream[T](sort)
|
|
266
269
|
|
|
267
|
-
def sorted(self, key, reverse: bool = False):
|
|
270
|
+
def sorted(self, key: any = None, reverse: bool = False):
|
|
268
271
|
sort = sorted(self.__iterable, key=key, reverse=reverse)
|
|
269
272
|
return Stream[T](sort)
|
|
270
273
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|