tinystream 0.1.13__tar.gz → 0.1.15__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tinystream
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary: Yet another python streams library
5
5
  Home-page: https://github.com/mreiche/python-streams
6
6
  Author: Mike Reiche
@@ -14,7 +14,7 @@ License-File: LICENSE
14
14
 
15
15
  This is a simple and lightweight Streams API inspired by Java Streams with support for type hinting.
16
16
 
17
- This package is release as `tinystream` at pypi.
17
+ This package is released as `tinystream` at pypi.
18
18
 
19
19
  ## Basic API
20
20
 
@@ -195,7 +195,8 @@ A given data structure like:
195
195
  ```python
196
196
  data = {
197
197
  "ranges": [
198
- timedelta(days=3),
198
+ {"days": 3},
199
+ {"weeks": 1},
199
200
  ]
200
201
  }
201
202
  ```
@@ -204,13 +205,13 @@ Without tinystream:
204
205
  ```python
205
206
  if "ranges" in data:
206
207
  range_data: timedelta
207
- for range_data in filter(lambda x: isinstance(x, timedelta), data["ranges"]):
208
+ for range_data in map(lambda x: timedelta(**x), data["ranges"]):
208
209
  pass
209
210
  ```
210
211
 
211
212
  With tinystream:
212
213
  ```python
213
- for range_data in Opt(data).map_key("ranges").stream().filter_type(timedelta):
214
+ for range_data in Opt(data).map_key("ranges").stream().map_kwargs(timedelta):
214
215
  pass
215
216
  ```
216
217
 
@@ -218,10 +219,11 @@ for range_data in Opt(data).map_key("ranges").stream().filter_type(timedelta):
218
219
 
219
220
  There are a couple of other implementation to fulfill similar requirements.
220
221
 
221
- - https://github.com/vxgmichel/aiostream (most professional)
222
- - https://github.com/alemazzo/Python-Java-Stream
223
- - https://github.com/ramsteak/streams
222
+ - https://github.com/vxgmichel/aiostream
223
+ - https://github.com/python-streamz/streamz
224
224
  - https://pypi.org/project/fluentpy
225
+ - https://github.com/ramsteak/streams
226
+ - https://github.com/alemazzo/Python-Java-Stream (*outdated*)
225
227
  - https://github.com/JaviOverflow/python-streams (*outdated*)
226
228
  - https://github.com/9seconds/streams/ (*outdated*)
227
229
  - https://github.com/tolsac/streampy (*outdated*)
@@ -5,7 +5,7 @@
5
5
 
6
6
  This is a simple and lightweight Streams API inspired by Java Streams with support for type hinting.
7
7
 
8
- This package is release as `tinystream` at pypi.
8
+ This package is released as `tinystream` at pypi.
9
9
 
10
10
  ## Basic API
11
11
 
@@ -186,7 +186,8 @@ A given data structure like:
186
186
  ```python
187
187
  data = {
188
188
  "ranges": [
189
- timedelta(days=3),
189
+ {"days": 3},
190
+ {"weeks": 1},
190
191
  ]
191
192
  }
192
193
  ```
@@ -195,13 +196,13 @@ Without tinystream:
195
196
  ```python
196
197
  if "ranges" in data:
197
198
  range_data: timedelta
198
- for range_data in filter(lambda x: isinstance(x, timedelta), data["ranges"]):
199
+ for range_data in map(lambda x: timedelta(**x), data["ranges"]):
199
200
  pass
200
201
  ```
201
202
 
202
203
  With tinystream:
203
204
  ```python
204
- for range_data in Opt(data).map_key("ranges").stream().filter_type(timedelta):
205
+ for range_data in Opt(data).map_key("ranges").stream().map_kwargs(timedelta):
205
206
  pass
206
207
  ```
207
208
 
@@ -209,10 +210,11 @@ for range_data in Opt(data).map_key("ranges").stream().filter_type(timedelta):
209
210
 
210
211
  There are a couple of other implementation to fulfill similar requirements.
211
212
 
212
- - https://github.com/vxgmichel/aiostream (most professional)
213
- - https://github.com/alemazzo/Python-Java-Stream
214
- - https://github.com/ramsteak/streams
213
+ - https://github.com/vxgmichel/aiostream
214
+ - https://github.com/python-streamz/streamz
215
215
  - https://pypi.org/project/fluentpy
216
+ - https://github.com/ramsteak/streams
217
+ - https://github.com/alemazzo/Python-Java-Stream (*outdated*)
216
218
  - https://github.com/JaviOverflow/python-streams (*outdated*)
217
219
  - https://github.com/9seconds/streams/ (*outdated*)
218
220
  - https://github.com/tolsac/streampy (*outdated*)
@@ -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",
13
+ version="0.1.15",
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.13
3
+ Version: 0.1.15
4
4
  Summary: Yet another python streams library
5
5
  Home-page: https://github.com/mreiche/python-streams
6
6
  Author: Mike Reiche
@@ -14,7 +14,7 @@ License-File: LICENSE
14
14
 
15
15
  This is a simple and lightweight Streams API inspired by Java Streams with support for type hinting.
16
16
 
17
- This package is release as `tinystream` at pypi.
17
+ This package is released as `tinystream` at pypi.
18
18
 
19
19
  ## Basic API
20
20
 
@@ -195,7 +195,8 @@ A given data structure like:
195
195
  ```python
196
196
  data = {
197
197
  "ranges": [
198
- timedelta(days=3),
198
+ {"days": 3},
199
+ {"weeks": 1},
199
200
  ]
200
201
  }
201
202
  ```
@@ -204,13 +205,13 @@ Without tinystream:
204
205
  ```python
205
206
  if "ranges" in data:
206
207
  range_data: timedelta
207
- for range_data in filter(lambda x: isinstance(x, timedelta), data["ranges"]):
208
+ for range_data in map(lambda x: timedelta(**x), data["ranges"]):
208
209
  pass
209
210
  ```
210
211
 
211
212
  With tinystream:
212
213
  ```python
213
- for range_data in Opt(data).map_key("ranges").stream().filter_type(timedelta):
214
+ for range_data in Opt(data).map_key("ranges").stream().map_kwargs(timedelta):
214
215
  pass
215
216
  ```
216
217
 
@@ -218,10 +219,11 @@ for range_data in Opt(data).map_key("ranges").stream().filter_type(timedelta):
218
219
 
219
220
  There are a couple of other implementation to fulfill similar requirements.
220
221
 
221
- - https://github.com/vxgmichel/aiostream (most professional)
222
- - https://github.com/alemazzo/Python-Java-Stream
223
- - https://github.com/ramsteak/streams
222
+ - https://github.com/vxgmichel/aiostream
223
+ - https://github.com/python-streamz/streamz
224
224
  - https://pypi.org/project/fluentpy
225
+ - https://github.com/ramsteak/streams
226
+ - https://github.com/alemazzo/Python-Java-Stream (*outdated*)
225
227
  - https://github.com/JaviOverflow/python-streams (*outdated*)
226
228
  - https://github.com/9seconds/streams/ (*outdated*)
227
229
  - https://github.com/tolsac/streampy (*outdated*)
@@ -8,7 +8,7 @@ R = TypeVar("R")
8
8
  K = TypeVar("K")
9
9
 
10
10
 
11
- Mapper = Callable[[T], R]
11
+ Mapper = Callable[[T], R] | Type[R]
12
12
  FlatMapper = Callable[[T], Iterable[R]]
13
13
  Consumer = Callable[[T], None]
14
14
  Comparator = Callable[[T, T], bool]
@@ -81,7 +81,7 @@ class Opt(Generic[T]):
81
81
  else:
82
82
  return EmptyOpt()
83
83
 
84
- def map(self, mapper: Mapper[T, R]):
84
+ def map(self, mapper: Mapper[T, R]) -> "Opt[R]":
85
85
  if self.absent:
86
86
  return EmptyOpt()
87
87
  else:
@@ -134,6 +134,9 @@ class Opt(Generic[T]):
134
134
  else:
135
135
  return len(self.__val)
136
136
 
137
+ def map_kwargs(self, mapper: Type[R]) -> "Opt[R]":
138
+ return self.map(lambda x: mapper(**x))
139
+
137
140
 
138
141
  class EmptyOpt(Opt[None]):
139
142
  def __init__(self):
File without changes
File without changes