pipe21 1.22.0__tar.gz → 1.24.0__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.
- pipe21-1.24.0/LICENSE +21 -0
- {pipe21-1.22.0 → pipe21-1.24.0}/PKG-INFO +6 -7
- {pipe21-1.22.0 → pipe21-1.24.0}/pipe21.egg-info/PKG-INFO +6 -7
- {pipe21-1.22.0 → pipe21-1.24.0}/pipe21.egg-info/SOURCES.txt +1 -0
- {pipe21-1.22.0 → pipe21-1.24.0}/pipe21.egg-info/requires.txt +1 -4
- pipe21-1.24.0/pipe21.py +90 -0
- {pipe21-1.22.0 → pipe21-1.24.0}/pyproject.toml +17 -15
- pipe21-1.22.0/pipe21.py +0 -83
- {pipe21-1.22.0 → pipe21-1.24.0}/README.md +0 -0
- {pipe21-1.22.0 → pipe21-1.24.0}/pipe21.egg-info/dependency_links.txt +0 -0
- {pipe21-1.22.0 → pipe21-1.24.0}/pipe21.egg-info/top_level.txt +0 -0
- {pipe21-1.22.0 → pipe21-1.24.0}/setup.cfg +0 -0
pipe21-1.24.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Alexander Rodionov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pipe21
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.24.0
|
|
4
4
|
Summary: simple functional pipes
|
|
5
5
|
Author-email: Alexander Rodionov <tandav@tandav.me>
|
|
6
6
|
Project-URL: source, https://github.com/tandav/pipe21
|
|
7
7
|
Project-URL: docs, https://tandav.github.io/pipe21/
|
|
8
8
|
Project-URL: issues, https://github.com/tandav/pipe21/issues
|
|
9
9
|
Project-URL: release notes, https://github.com/tandav/pipe21/releases
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
12
13
|
Provides-Extra: dev
|
|
13
14
|
Requires-Dist: bumpver; extra == "dev"
|
|
14
|
-
Requires-Dist: black; extra == "dev"
|
|
15
|
-
Requires-Dist: autopep8; extra == "dev"
|
|
16
15
|
Requires-Dist: pre-commit; extra == "dev"
|
|
17
16
|
Requires-Dist: hypothesis; extra == "dev"
|
|
17
|
+
Requires-Dist: mypy; extra == "dev"
|
|
18
18
|
Requires-Dist: pytest; extra == "dev"
|
|
19
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
20
|
-
Requires-Dist: coveralls; extra == "dev"
|
|
21
19
|
Requires-Dist: mkdocs; extra == "dev"
|
|
22
20
|
Requires-Dist: mkdocs-material; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
23
22
|
|
|
24
23
|
[](https://pypi.org/project/pipe21/)
|
|
25
24
|
[](https://coveralls.io/github/tandav/pipe21?branch=coveralls-bage)
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: pipe21
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.24.0
|
|
4
4
|
Summary: simple functional pipes
|
|
5
5
|
Author-email: Alexander Rodionov <tandav@tandav.me>
|
|
6
6
|
Project-URL: source, https://github.com/tandav/pipe21
|
|
7
7
|
Project-URL: docs, https://tandav.github.io/pipe21/
|
|
8
8
|
Project-URL: issues, https://github.com/tandav/pipe21/issues
|
|
9
9
|
Project-URL: release notes, https://github.com/tandav/pipe21/releases
|
|
10
|
-
Requires-Python: >=3.
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
12
13
|
Provides-Extra: dev
|
|
13
14
|
Requires-Dist: bumpver; extra == "dev"
|
|
14
|
-
Requires-Dist: black; extra == "dev"
|
|
15
|
-
Requires-Dist: autopep8; extra == "dev"
|
|
16
15
|
Requires-Dist: pre-commit; extra == "dev"
|
|
17
16
|
Requires-Dist: hypothesis; extra == "dev"
|
|
17
|
+
Requires-Dist: mypy; extra == "dev"
|
|
18
18
|
Requires-Dist: pytest; extra == "dev"
|
|
19
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
20
|
-
Requires-Dist: coveralls; extra == "dev"
|
|
21
19
|
Requires-Dist: mkdocs; extra == "dev"
|
|
22
20
|
Requires-Dist: mkdocs-material; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
23
22
|
|
|
24
23
|
[](https://pypi.org/project/pipe21/)
|
|
25
24
|
[](https://coveralls.io/github/tandav/pipe21?branch=coveralls-bage)
|
pipe21-1.24.0/pipe21.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import itertools
|
|
3
|
+
import operator
|
|
4
|
+
import re
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
__version__ = '1.24.0'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class B:
|
|
11
|
+
def __init__(self, f=None, *args, **kw):
|
|
12
|
+
self.f = f
|
|
13
|
+
self.args = args
|
|
14
|
+
self.kw = kw
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Pipe (B): __ror__ = lambda self, x: self.f(x, *self.args, **self.kw)
|
|
18
|
+
class Map (B): __ror__ = lambda self, it: (self.f(x) for x in it)
|
|
19
|
+
class Filter (B): __ror__ = lambda self, it: (x for x in it if self.f(x))
|
|
20
|
+
class Reduce (B): __ror__ = lambda self, it: functools.reduce(self.f, it, *self.args)
|
|
21
|
+
class MapKeys (B): __ror__ = lambda self, it: ((self.f(k), v) for k, v in it)
|
|
22
|
+
class MapValues (B): __ror__ = lambda self, it: ((k, self.f(v)) for k, v in it)
|
|
23
|
+
class FilterFalse (B): __ror__ = lambda self, it: itertools.filterfalse(self.f, it)
|
|
24
|
+
class FilterKeys (B): __ror__ = lambda self, it: (kv for kv in it if (self.f or bool)(kv[0]))
|
|
25
|
+
class FilterValues (B): __ror__ = lambda self, it: (kv for kv in it if (self.f or bool)(kv[1]))
|
|
26
|
+
class FlatMap (B): __ror__ = lambda self, it: itertools.chain.from_iterable(self.f(x) for x in it)
|
|
27
|
+
class FlatMapValues(B): __ror__ = lambda self, it: ((k, v) for k, vs in it for v in self.f(vs))
|
|
28
|
+
class KeyBy (B): __ror__ = lambda self, it: ((self.f(x), x) for x in it)
|
|
29
|
+
class ValueBy (B): __ror__ = lambda self, it: ((x, self.f(x)) for x in it)
|
|
30
|
+
class Append (B): __ror__ = lambda self, it: ((*x, self.f(x)) for x in it)
|
|
31
|
+
class Keys (B): __ror__ = lambda self, it: (k for k, v in it)
|
|
32
|
+
class Values (B): __ror__ = lambda self, it: (v for k, v in it)
|
|
33
|
+
class SwapKV (B): __ror__ = lambda self, it: it | Map(operator.itemgetter(1, 0))
|
|
34
|
+
class Grep (B): __ror__ = lambda self, it: it | (FilterFalse if self.kw.get('v', False) else Filter)(re.compile(self.f, flags=re.IGNORECASE if self.kw.get('i', False) else 0).search)
|
|
35
|
+
class IterLines (B): __ror__ = lambda self, f: (x.strip() if self.kw.get('strip', True) else x for x in open(f))
|
|
36
|
+
class Count (B): __ror__ = lambda self, it: sum(1 for _ in it)
|
|
37
|
+
class Slice (B): __ror__ = lambda self, it: itertools.islice(it, self.f, *self.args)
|
|
38
|
+
class Take (B): __ror__ = lambda self, it: it | Slice(self.f) | Pipe(list)
|
|
39
|
+
class Sorted (B): __ror__ = lambda self, it: sorted(it, **self.kw)
|
|
40
|
+
class GroupBy (B): __ror__ = lambda self, it: itertools.groupby(sorted(it, key=self.f), key=self.f)
|
|
41
|
+
class ReduceByKey (B): __ror__ = lambda self, it: it | GroupBy(lambda kv: kv[0]) | MapValues(lambda kv: kv | Values() | Reduce(self.f)) | Pipe(list)
|
|
42
|
+
class Apply (B): __ror__ = lambda self, x: x | Exec(self.f, x)
|
|
43
|
+
class StarPipe (B): __ror__ = lambda self, x: self.f(*x)
|
|
44
|
+
class StarMap (B): __ror__ = lambda self, x: itertools.starmap(self.f, x)
|
|
45
|
+
class StarFlatMap (B): __ror__ = lambda self, x: itertools.starmap(self.f, x) | Pipe(itertools.chain.from_iterable)
|
|
46
|
+
class MapApply (B): __ror__ = lambda self, it: (x | Apply(self.f) for x in it)
|
|
47
|
+
class Switch (B): __ror__ = lambda self, x: next((v(x) for k, v in self.f if k(x)), x)
|
|
48
|
+
class MapSwitch (B): __ror__ = lambda self, it: (x | Switch(self.f) for x in it)
|
|
49
|
+
class YieldIf (B): __ror__ = lambda self, it: ((self.f or (lambda y: y))(x) for x in it if self.kw.get('key', bool)(x))
|
|
50
|
+
class Join (B): __ror__ = lambda self, it: it | FlatMap(lambda x: ((x, y) for y in self.f if self.kw.get('key', operator.eq)(x, y)))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class GetItem (B): __ror__ = lambda self, x: operator.getitem(x, self.f)
|
|
54
|
+
class SetItem (B): __ror__ = lambda self, x: x | Exec(operator.setitem, x, self.f, self.args[0])
|
|
55
|
+
class DelItem (B): __ror__ = lambda self, x: x | Exec(operator.delitem, x, self.f)
|
|
56
|
+
class GetAttr (B): __ror__ = lambda self, x: getattr(x, self.f)
|
|
57
|
+
class SetAttr (B): __ror__ = lambda self, x: x | Exec(setattr, x, self.f, self.args[0])
|
|
58
|
+
class DelAttr (B): __ror__ = lambda self, x: x | Exec(delattr, x, self.f)
|
|
59
|
+
class MapGetItem (B): __ror__ = lambda self, it: (kv | GetItem(self.f) for kv in it)
|
|
60
|
+
class MapSetItem (B): __ror__ = lambda self, it: (kv | SetItem(self.f, self.args[0]) for kv in it)
|
|
61
|
+
class MapDelItem (B): __ror__ = lambda self, it: (kv | DelItem(self.f) for kv in it)
|
|
62
|
+
class MapGetAttr (B): __ror__ = lambda self, it: (kv | GetAttr(self.f) for kv in it)
|
|
63
|
+
class MapSetAttr (B): __ror__ = lambda self, it: (kv | SetAttr(self.f, self.args[0]) for kv in it)
|
|
64
|
+
class MapDelAttr (B): __ror__ = lambda self, it: (kv | DelAttr(self.f) for kv in it)
|
|
65
|
+
class MethodCaller (B): __ror__ = lambda self, x: operator.methodcaller(self.f, *self.args, **self.kw)(x)
|
|
66
|
+
class MapMethodCaller(B): __ror__ = lambda self, it: (x | MethodCaller(self.f, *self.args, **self.kw) for x in it)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class Unique(B):
|
|
70
|
+
def __ror__(self, it):
|
|
71
|
+
key = self.f or (lambda x: x)
|
|
72
|
+
seen = set()
|
|
73
|
+
for item in it:
|
|
74
|
+
k = key(item)
|
|
75
|
+
if k in seen:
|
|
76
|
+
continue
|
|
77
|
+
seen.add(k)
|
|
78
|
+
yield item
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class Exec(B):
|
|
82
|
+
def __ror__(self, x):
|
|
83
|
+
self.f(*self.args, **self.kw)
|
|
84
|
+
return x
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if sys.version_info >= (3, 12): # pragma: no cover
|
|
88
|
+
class Chunked(B): __ror__ = lambda self, it: itertools.batched(it, self.f) # pylint: disable=no-member
|
|
89
|
+
else: # pragma: no cover
|
|
90
|
+
class Chunked(B): __ror__ = lambda self, it: iter(functools.partial(lambda n, i: tuple(i | Take(n)), self.f, iter(it)), ())
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pipe21"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.24.0"
|
|
4
4
|
authors = [
|
|
5
5
|
{name = "Alexander Rodionov", email = "tandav@tandav.me"},
|
|
6
6
|
]
|
|
7
7
|
description = "simple functional pipes"
|
|
8
8
|
readme = "README.md"
|
|
9
|
-
requires-python = ">=3.
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
10
|
dependencies = []
|
|
11
11
|
|
|
12
12
|
[project.optional-dependencies]
|
|
13
13
|
dev = [
|
|
14
14
|
"bumpver",
|
|
15
|
-
"black",
|
|
16
|
-
"autopep8",
|
|
17
15
|
"pre-commit",
|
|
18
16
|
"hypothesis",
|
|
17
|
+
"mypy",
|
|
19
18
|
"pytest",
|
|
20
|
-
"pytest-cov",
|
|
21
|
-
"coveralls",
|
|
22
19
|
"mkdocs",
|
|
23
20
|
"mkdocs-material",
|
|
24
21
|
]
|
|
@@ -38,7 +35,7 @@ build-backend = "setuptools.build_meta"
|
|
|
38
35
|
# ==============================================================================
|
|
39
36
|
|
|
40
37
|
[tool.bumpver]
|
|
41
|
-
current_version = "v1.
|
|
38
|
+
current_version = "v1.24.0"
|
|
42
39
|
version_pattern = "vMAJOR.MINOR.PATCH"
|
|
43
40
|
commit_message = "bump version {old_version} -> {new_version}"
|
|
44
41
|
commit = true
|
|
@@ -56,6 +53,8 @@ tag = true
|
|
|
56
53
|
# ==============================================================================
|
|
57
54
|
|
|
58
55
|
[tool.mypy]
|
|
56
|
+
# pipe21.py is intentionally untyped and dynamic, its public api is typed in pipe21.pyi
|
|
57
|
+
files = ["pipe21.pyi", "tests"]
|
|
59
58
|
# todo: review this
|
|
60
59
|
pretty = true
|
|
61
60
|
show_traceback = true
|
|
@@ -86,7 +85,7 @@ disallow_untyped_defs = false
|
|
|
86
85
|
|
|
87
86
|
# ==============================================================================
|
|
88
87
|
|
|
89
|
-
[tool.ruff]
|
|
88
|
+
[tool.ruff.lint]
|
|
90
89
|
select = ["ALL"]
|
|
91
90
|
ignore = [
|
|
92
91
|
"E501", # line too long
|
|
@@ -97,16 +96,18 @@ ignore = [
|
|
|
97
96
|
"F405", # star imports
|
|
98
97
|
"B008", # function-call-in-default-argument
|
|
99
98
|
"PLR0913", # too-many-arguments
|
|
100
|
-
"
|
|
99
|
+
"TC003", # typing-only-standard-library-import
|
|
101
100
|
"ANN", # type annotations
|
|
101
|
+
"CPY", # copyright notice
|
|
102
102
|
"D", #docstrings
|
|
103
103
|
"Q", # quotes
|
|
104
104
|
"ARG005", # Unused lambda argument
|
|
105
105
|
"PTH123", # `open()` should be replaced by `Path.open()`
|
|
106
106
|
"N812", # lowercase imported as non lowercase
|
|
107
|
+
"SIM115",
|
|
107
108
|
]
|
|
108
109
|
|
|
109
|
-
[tool.ruff.per-file-ignores]
|
|
110
|
+
[tool.ruff.lint.per-file-ignores]
|
|
110
111
|
"examples/*" = ["INP001"]
|
|
111
112
|
"tests/*" = [
|
|
112
113
|
"S101",
|
|
@@ -114,17 +115,20 @@ ignore = [
|
|
|
114
115
|
"PT001",
|
|
115
116
|
]
|
|
116
117
|
|
|
117
|
-
[tool.ruff.isort]
|
|
118
|
+
[tool.ruff.lint.isort]
|
|
118
119
|
force-single-line = true
|
|
119
120
|
|
|
120
121
|
# ==============================================================================
|
|
121
122
|
|
|
122
|
-
[tool.pylint.
|
|
123
|
+
[tool.pylint.main]
|
|
123
124
|
load-plugins=[
|
|
124
125
|
"pylint_per_file_ignores",
|
|
125
126
|
]
|
|
126
127
|
|
|
127
128
|
[tool.pylint.messages-control]
|
|
129
|
+
per-file-ignores = [
|
|
130
|
+
"tests/*:import-error,redefined-outer-name",
|
|
131
|
+
]
|
|
128
132
|
disable = [
|
|
129
133
|
"invalid-name",
|
|
130
134
|
"missing-function-docstring",
|
|
@@ -138,11 +142,9 @@ disable = [
|
|
|
138
142
|
"unused-wildcard-import",
|
|
139
143
|
"keyword-arg-before-vararg",
|
|
140
144
|
"too-few-public-methods",
|
|
145
|
+
"consider-using-with",
|
|
141
146
|
]
|
|
142
147
|
|
|
143
|
-
[tool.pylint-per-file-ignores]
|
|
144
|
-
"/tests/" = "import-error,redefined-outer-name"
|
|
145
|
-
|
|
146
148
|
# ==============================================================================
|
|
147
149
|
|
|
148
150
|
[tool.autopep8]
|
pipe21-1.22.0/pipe21.py
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import functools
|
|
2
|
-
import itertools
|
|
3
|
-
import operator
|
|
4
|
-
import re
|
|
5
|
-
|
|
6
|
-
__version__ = '1.22.0'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class B:
|
|
10
|
-
def __init__(self, f=None, *args, **kw):
|
|
11
|
-
self.f = f
|
|
12
|
-
self.args = args
|
|
13
|
-
self.kw = kw
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class Pipe (B): __ror__ = lambda self, x: self.f(x, *self.args, **self.kw)
|
|
17
|
-
class Map (B): __ror__ = lambda self, it: map(self.f, it)
|
|
18
|
-
class Filter (B): __ror__ = lambda self, it: filter(self.f, it)
|
|
19
|
-
class Reduce (B): __ror__ = lambda self, it: functools.reduce(self.f, it, *self.args)
|
|
20
|
-
class MapKeys (B): __ror__ = lambda self, it: it | Map(lambda kv: (self.f(kv[0]), kv[1]))
|
|
21
|
-
class MapValues (B): __ror__ = lambda self, it: it | Map(lambda kv: (kv[0], self.f(kv[1])))
|
|
22
|
-
class FilterFalse (B): __ror__ = lambda self, it: itertools.filterfalse(self.f, it)
|
|
23
|
-
class FilterKeys (B): __ror__ = lambda self, it: it | Filter(lambda kv: kv[0] | Pipe(self.f or bool))
|
|
24
|
-
class FilterValues (B): __ror__ = lambda self, it: it | Filter(lambda kv: kv[1] | Pipe(self.f or bool))
|
|
25
|
-
class FlatMap (B): __ror__ = lambda self, it: it | Map(self.f) | Pipe(itertools.chain.from_iterable)
|
|
26
|
-
class FlatMapValues(B): __ror__ = lambda self, it: it | FlatMap(lambda kv: ((kv[0], x) for x in self.f(kv[1])))
|
|
27
|
-
class KeyBy (B): __ror__ = lambda self, it: it | Map(lambda x: (self.f(x), x))
|
|
28
|
-
class ValueBy (B): __ror__ = lambda self, it: it | Map(lambda x: (x, self.f(x)))
|
|
29
|
-
class Append (B): __ror__ = lambda self, it: it | Map(lambda x: (*x, self.f(x)))
|
|
30
|
-
class Keys (B): __ror__ = lambda self, it: it | Map(lambda kv: kv[0])
|
|
31
|
-
class Values (B): __ror__ = lambda self, it: it | Map(lambda kv: kv[1])
|
|
32
|
-
class Grep (B): __ror__ = lambda self, it: it | (FilterFalse if self.kw.get('v', False) else Filter)(re.compile(self.f, flags=re.I if self.kw.get('i', False) else 0).search)
|
|
33
|
-
class IterLines (B): __ror__ = lambda self, p: p | Pipe(open) | Pipe(lambda t: t | Map(str.strip) if self.kw.get('strip', True) else t)
|
|
34
|
-
class Count (B): __ror__ = lambda self, it: sum(1 for _ in it)
|
|
35
|
-
class Slice (B): __ror__ = lambda self, it: itertools.islice(it, self.f, *self.args)
|
|
36
|
-
class Take (B): __ror__ = lambda self, it: it | Slice(self.f) | Pipe(tuple)
|
|
37
|
-
class Chunked (B): __ror__ = lambda self, it: iter(functools.partial(lambda n, i: i | Take(n), self.f, iter(it)), ())
|
|
38
|
-
class Sorted (B): __ror__ = lambda self, it: sorted(it, **self.kw)
|
|
39
|
-
class GroupBy (B): __ror__ = lambda self, it: it | Sorted(key=self.f) | Pipe(itertools.groupby, key=self.f)
|
|
40
|
-
class ReduceByKey (B): __ror__ = lambda self, it: it | GroupBy(lambda kv: kv[0]) | MapValues(lambda kv: kv | Values() | Reduce(self.f)) | Pipe(list)
|
|
41
|
-
class Apply (B): __ror__ = lambda self, x: x | Exec(self.f, x)
|
|
42
|
-
class StarPipe (B): __ror__ = lambda self, x: self.f(*x)
|
|
43
|
-
class StarMap (B): __ror__ = lambda self, x: itertools.starmap(self.f, x)
|
|
44
|
-
class StarFlatMap (B): __ror__ = lambda self, x: x | StarMap(self.f) | Pipe(itertools.chain.from_iterable)
|
|
45
|
-
class MapApply (B): __ror__ = lambda self, it: it | Map(lambda x: x | Apply(self.f))
|
|
46
|
-
class Switch (B): __ror__ = lambda self, x: self.f | FilterKeys(lambda p: p(x)) | Values() | Map(lambda f: f(x)) | Pipe(next, x)
|
|
47
|
-
class MapSwitch (B): __ror__ = lambda self, it: it | Map(lambda x: x | Switch(self.f))
|
|
48
|
-
class YieldIf (B): __ror__ = lambda self, it: ((self.f or (lambda y: y))(x) for x in it if self.kw.get('key', bool)(x))
|
|
49
|
-
class Join (B): __ror__ = lambda self, it: it | FlatMap(lambda x: ((x, y) for y in self.f if self.kw.get('key', operator.eq)(x, y)))
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class GetItem (B): __ror__ = lambda self, x: operator.getitem(x, self.f)
|
|
53
|
-
class SetItem (B): __ror__ = lambda self, x: x | Exec(operator.setitem, x, self.f, self.args[0])
|
|
54
|
-
class DelItem (B): __ror__ = lambda self, x: x | Exec(operator.delitem, x, self.f)
|
|
55
|
-
class GetAttr (B): __ror__ = lambda self, x: getattr(x, self.f)
|
|
56
|
-
class SetAttr (B): __ror__ = lambda self, x: x | Exec(setattr, x, self.f, self.args[0])
|
|
57
|
-
class DelAttr (B): __ror__ = lambda self, x: x | Exec(delattr, x, self.f)
|
|
58
|
-
class MapGetItem (B): __ror__ = lambda self, it: it | Map(lambda kv: kv | GetItem(self.f))
|
|
59
|
-
class MapSetItem (B): __ror__ = lambda self, it: it | Map(lambda kv: kv | SetItem(self.f, self.args[0]))
|
|
60
|
-
class MapDelItem (B): __ror__ = lambda self, it: it | Map(lambda kv: kv | DelItem(self.f))
|
|
61
|
-
class MapGetAttr (B): __ror__ = lambda self, it: it | Map(lambda kv: kv | GetAttr(self.f))
|
|
62
|
-
class MapSetAttr (B): __ror__ = lambda self, it: it | Map(lambda kv: kv | SetAttr(self.f, self.args[0]))
|
|
63
|
-
class MapDelAttr (B): __ror__ = lambda self, it: it | Map(lambda kv: kv | DelAttr(self.f))
|
|
64
|
-
class MethodCaller (B): __ror__ = lambda self, x: operator.methodcaller(self.f, *self.args, **self.kw)(x)
|
|
65
|
-
class MapMethodCaller(B): __ror__ = lambda self, it: it | Map(lambda x: x | MethodCaller(self.f, *self.args, **self.kw))
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class Unique(B):
|
|
69
|
-
def __ror__(self, it):
|
|
70
|
-
key = self.f or (lambda x: x)
|
|
71
|
-
seen = set()
|
|
72
|
-
for item in it:
|
|
73
|
-
k = key(item)
|
|
74
|
-
if k in seen:
|
|
75
|
-
continue
|
|
76
|
-
seen.add(k)
|
|
77
|
-
yield item
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class Exec(B):
|
|
81
|
-
def __ror__(self, x):
|
|
82
|
-
self.f(*self.args, **self.kw)
|
|
83
|
-
return x
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|