Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
05272a5b
Commit
05272a5b
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
minor fixes
parent
6ab4153c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/coding/iterators.py
+9
-9
9 additions, 9 deletions
satella/coding/iterators.py
with
9 additions
and
9 deletions
satella/coding/iterators.py
+
9
−
9
View file @
05272a5b
import
typing
as
tp
import
typing
as
tp
def
chain
(
*
args
):
def
chain
(
*
args
)
->
tp
.
Iterator
:
"""
"""
Construct an iterator out of provided elements.
Construct an iterator out of provided elements.
...
@@ -17,7 +17,7 @@ def chain(*args):
...
@@ -17,7 +17,7 @@ def chain(*args):
yield
elem
yield
elem
def
exhaust
(
iterator
:
tp
.
Iterator
):
def
exhaust
(
iterator
:
tp
.
Iterator
)
->
None
:
"""
"""
Iterate till the end of the iterator, discarding values as they go
Iterate till the end of the iterator, discarding values as they go
...
@@ -46,15 +46,15 @@ class SelfClosingGenerator:
...
@@ -46,15 +46,15 @@ class SelfClosingGenerator:
def
__init__
(
self
,
generator
:
tp
.
Generator
):
def
__init__
(
self
,
generator
:
tp
.
Generator
):
self
.
generator
=
generator
self
.
generator
=
generator
self
.
stopped
=
False
self
.
stopped
=
False
# type: bool
def
__iter__
(
self
):
def
__iter__
(
self
)
->
'
SelfClosingGenerator
'
:
return
self
return
self
def
__call__
(
self
,
*
args
,
**
kwargs
):
def
__call__
(
self
,
*
args
,
**
kwargs
):
return
SelfClosingGenerator
(
self
.
generator
(
*
args
,
**
kwargs
))
return
SelfClosingGenerator
(
self
.
generator
(
*
args
,
**
kwargs
))
def
send
(
self
,
obj
:
tp
.
Any
):
def
send
(
self
,
obj
:
tp
.
Any
)
->
None
:
self
.
generator
.
send
(
obj
)
self
.
generator
.
send
(
obj
)
def
__next__
(
self
):
def
__next__
(
self
):
...
@@ -64,14 +64,14 @@ class SelfClosingGenerator:
...
@@ -64,14 +64,14 @@ class SelfClosingGenerator:
self
.
stopped
=
True
self
.
stopped
=
True
raise
raise
def
__enter__
(
self
):
def
__enter__
(
self
)
->
'
SelfClosingGenerator
'
:
return
self
return
self
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
)
->
bool
:
self
.
close
()
self
.
close
()
return
False
return
False
def
close
(
self
):
def
close
(
self
)
->
None
:
if
not
self
.
stopped
:
if
not
self
.
stopped
:
try
:
try
:
exhaust
(
self
.
generator
)
exhaust
(
self
.
generator
)
...
@@ -109,7 +109,7 @@ class hint_with_length:
...
@@ -109,7 +109,7 @@ class hint_with_length:
def
send
(
self
,
obj
):
def
send
(
self
,
obj
):
return
self
.
generator
.
send
(
obj
)
return
self
.
generator
.
send
(
obj
)
def
__iter__
(
self
):
def
__iter__
(
self
)
->
tp
.
Generator
:
return
self
.
generator
return
self
.
generator
def
__next__
(
self
):
def
__next__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment