Skip to content

Commit eed2f2b

Browse files
fix reading of files
1 parent a3308d3 commit eed2f2b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

slkspec/core.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,29 @@ def ls(
440440
if detail:
441441
return detail_list
442442
return filelist.filename.tolist()
443+
444+
def cat_file(self, path, start=None, end=None):
445+
"""Get file content
446+
447+
Inputs
448+
------
449+
path : str
450+
file to open
451+
start : int
452+
seek position within file, optional
453+
end : int
454+
end position of file read, optional
455+
456+
Returns
457+
-------
458+
- bytes if start and end are given
459+
- file object otherwise
460+
"""
461+
slk_file = self._open(path, mode="rb")
462+
if isinstance(start, int) and isinstance(end, int):
463+
slk_file.seek(start)
464+
return slk_file.read(end - start)
465+
return slk_file
443466

444467
def _open(
445468
self,

0 commit comments

Comments
 (0)