MCPcopy Index your code
hub / github.com/aws/aws-cli / seekable

Function seekable

awscli/s3transfer/compat.py:49–70  ·  view source on GitHub ↗

Backwards compat function to determine if a fileobj is seekable :param fileobj: The file-like object to determine if seekable :returns: True, if seekable. False, otherwise.

(fileobj)

Source from the content-addressed store, hash-verified

47
48
49def seekable(fileobj):
50 """Backwards compat function to determine if a fileobj is seekable
51
52 :param fileobj: The file-like object to determine if seekable
53
54 :returns: True, if seekable. False, otherwise.
55 """
56 # If the fileobj has a seekable attr, try calling the seekable()
57 # method on it.
58 if hasattr(fileobj, 'seekable'):
59 return fileobj.seekable()
60 # If there is no seekable attr, check if the object can be seeked
61 # or telled. If it can, try to seek to the current position.
62 elif hasattr(fileobj, 'seek') and hasattr(fileobj, 'tell'):
63 try:
64 fileobj.seek(0, 1)
65 return True
66 except OSError:
67 # If an io related error was thrown then it is not seekable.
68 return False
69 # Else, the fileobj is not seekable
70 return False
71
72
73def readable(fileobj):

Callers 7

test_seekable_fileobjMethod · 0.90
is_compatibleMethod · 0.90
is_compatibleMethod · 0.90

Calls 2

seekableMethod · 0.45
seekMethod · 0.45