Add method read_generator.
This commit is contained in:
parent
25fd738a35
commit
ed3e91b5fa
1 changed files with 8 additions and 0 deletions
|
@ -437,6 +437,14 @@ class Path:
|
||||||
with self.open(mode, **kwargs) as handle:
|
with self.open(mode, **kwargs) as handle:
|
||||||
return handle.read()
|
return handle.read()
|
||||||
|
|
||||||
|
def read_generator(self, mode, chunk_size, **kwargs):
|
||||||
|
with self.open(mode, **kwargs) as handle:
|
||||||
|
while True:
|
||||||
|
chunk = handle.read(chunk_size)
|
||||||
|
if not chunk:
|
||||||
|
break
|
||||||
|
yield chunk
|
||||||
|
|
||||||
def readlines(self, mode, **kwargs):
|
def readlines(self, mode, **kwargs):
|
||||||
'''
|
'''
|
||||||
Shortcut function for opening the file handle and reading lines from it.
|
Shortcut function for opening the file handle and reading lines from it.
|
||||||
|
|
Loading…
Reference in a new issue