tinystream 0.1.10__tar.gz → 0.1.12__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.10/tinystream.egg-info → tinystream-0.1.12}/PKG-INFO +2 -2
- {tinystream-0.1.10 → tinystream-0.1.12}/README.md +1 -1
- {tinystream-0.1.10 → tinystream-0.1.12}/setup.py +1 -1
- {tinystream-0.1.10 → tinystream-0.1.12/tinystream.egg-info}/PKG-INFO +2 -2
- {tinystream-0.1.10 → tinystream-0.1.12}/tinystream.py +20 -3
- {tinystream-0.1.10 → tinystream-0.1.12}/LICENSE +0 -0
- {tinystream-0.1.10 → tinystream-0.1.12}/setup.cfg +0 -0
- {tinystream-0.1.10 → tinystream-0.1.12}/tinystream.egg-info/SOURCES.txt +0 -0
- {tinystream-0.1.10 → tinystream-0.1.12}/tinystream.egg-info/dependency_links.txt +0 -0
- {tinystream-0.1.10 → tinystream-0.1.12}/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.12
|
|
4
4
|
Summary: Yet another python streams library
|
|
5
5
|
Home-page: https://github.com/mreiche/python-streams
|
|
6
6
|
Author: Mike Reiche
|
|
@@ -61,7 +61,7 @@ assert Opt(None).absent
|
|
|
61
61
|
|
|
62
62
|
Map *optional*:
|
|
63
63
|
```python
|
|
64
|
-
assert Opt("String").
|
|
64
|
+
assert Opt("String").len == 6
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Get default value:
|
|
@@ -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.12",
|
|
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.12
|
|
4
4
|
Summary: Yet another python streams library
|
|
5
5
|
Home-page: https://github.com/mreiche/python-streams
|
|
6
6
|
Author: Mike Reiche
|
|
@@ -61,7 +61,7 @@ assert Opt(None).absent
|
|
|
61
61
|
|
|
62
62
|
Map *optional*:
|
|
63
63
|
```python
|
|
64
|
-
assert Opt("String").
|
|
64
|
+
assert Opt("String").len == 6
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
Get default value:
|
|
@@ -82,13 +82,16 @@ class Opt(Generic[T]):
|
|
|
82
82
|
return EmptyOpt()
|
|
83
83
|
|
|
84
84
|
def map(self, mapper: Mapper[T, R]):
|
|
85
|
-
|
|
85
|
+
if self.absent:
|
|
86
|
+
return EmptyOpt()
|
|
87
|
+
else:
|
|
88
|
+
return Opt[R](mapper(self.__val))
|
|
86
89
|
|
|
87
|
-
def if_empty(self, supplier:
|
|
90
|
+
def if_empty(self, supplier: Supplier[R] | any):
|
|
88
91
|
warn("Please use if_absent() method instead", DeprecationWarning)
|
|
89
92
|
return self.if_absent(supplier)
|
|
90
93
|
|
|
91
|
-
def if_absent(self, supplier:
|
|
94
|
+
def if_absent(self, supplier: Supplier[R] | any):
|
|
92
95
|
if self.absent:
|
|
93
96
|
if isinstance(supplier, Callable):
|
|
94
97
|
return Opt[R](supplier())
|
|
@@ -124,11 +127,21 @@ class Opt(Generic[T]):
|
|
|
124
127
|
def stream(self):
|
|
125
128
|
return Stream(self.__val)
|
|
126
129
|
|
|
130
|
+
@property
|
|
131
|
+
def len(self):
|
|
132
|
+
if self.absent:
|
|
133
|
+
return 0
|
|
134
|
+
else:
|
|
135
|
+
return len(self.__val)
|
|
136
|
+
|
|
127
137
|
|
|
128
138
|
class EmptyOpt(Opt[None]):
|
|
129
139
|
def __init__(self):
|
|
130
140
|
super().__init__(None)
|
|
131
141
|
|
|
142
|
+
def map(self, mapper: Mapper[T, R]):
|
|
143
|
+
return self
|
|
144
|
+
|
|
132
145
|
def filter(self, predicate: Predicate[T]):
|
|
133
146
|
return self
|
|
134
147
|
|
|
@@ -145,6 +158,10 @@ class EmptyOpt(Opt[None]):
|
|
|
145
158
|
def stream(self):
|
|
146
159
|
return Stream([])
|
|
147
160
|
|
|
161
|
+
@property
|
|
162
|
+
def len(self):
|
|
163
|
+
return 0
|
|
164
|
+
|
|
148
165
|
|
|
149
166
|
class Stream(Iterator[T]):
|
|
150
167
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|