Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
c369adcd
Commit
c369adcd
authored
Mar 26, 2011
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
S3FS: some code layout cleanups
parent
30f051ef
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
fs/filelike.py
+23
-0
fs/s3fs.py
+0
-0
No files found.
fs/filelike.py
View file @
c369adcd
...
...
@@ -23,6 +23,10 @@ Other useful classes include:
class, patched to more closely preserve the
semantics of a standard file.
* LimitBytesFile: a filelike wrapper that limits the total bytes read
from a file; useful for turning a socket into a file
without reading past end-of-data.
"""
# Copyright (C) 2006-2009, Ryan Kelly
# All rights reserved; available under the terms of the MIT License.
...
...
@@ -743,3 +747,22 @@ class SpooledTemporaryFile(FileWrapper):
return
self
.
wrapped_file
.
fileno
()
class
LimitBytesFile
(
FileWrapper
):
"""Filelike wrapper to limit bytes read from a stream."""
def
__init__
(
self
,
size
,
fileobj
,
*
args
,
**
kwds
):
self
.
size
=
size
self
.
__remaining
=
size
super
(
LimitBytesFile
,
self
)
.
__init__
(
fileobj
,
*
args
,
**
kwds
)
def
_read
(
self
,
sizehint
=-
1
):
if
self
.
__remaining
<=
0
:
return
None
if
sizehint
is
None
or
sizehint
<
0
or
sizehint
>
self
.
__remaining
:
sizehint
=
self
.
__remaining
data
=
super
(
LimitBytesFile
,
self
)
.
_read
(
sizehint
)
if
data
is
not
None
:
self
.
__remaining
-=
len
(
data
)
return
data
fs/s3fs.py
View file @
c369adcd
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment