This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
StringIO.py
126 lines (92 loc) · 2.67 KB
/
StringIO.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
"""Skeleton for 'StringIO' stdlib module."""
import StringIO as _StringIO
class StringIO(object):
"""Reads and writes a string buffer (also known as memory files)."""
def __init__(self, buffer=None):
"""When a StringIO object is created, it can be initialized to an existing
string by passing the string to the constructor.
:type buffer: T <= bytes | unicode
:rtype: _StringIO.StringIO[T]
"""
self.closed = False
def getvalue(self):
"""Retrieve the entire contents of the "file" at any time before the
StringIO object's close() method is called.
:rtype: T
"""
pass
def close(self):
"""Free the memory buffer.
:rtype: None
"""
pass
def flush(self):
"""Flush the internal buffer.
:rtype: None
"""
pass
def isatty(self):
"""Return True if the file is connected to a tty(-like) device,
else False.
:rtype: bool
"""
return False
def __iter__(self):
"""Return an iterator over lines.
:rtype: _StringIO.StringIO[T]
"""
return self
def next(self):
"""Returns the next input line.
:rtype: T
"""
pass
def read(self, size=-1):
"""Read at most size bytes or characters from the buffer.
:type size: numbers.Integral
:rtype: T
"""
pass
def readline(self, size=-1):
"""Read one entire line from the buffer.
:type size: numbers.Integral
:rtype: T
"""
pass
def readlines(self, sizehint=-1):
"""Read until EOF using readline() and return a list containing the
lines thus read.
:type sizehint: numbers.Integral
:rtype: list[T]
"""
pass
def seek(self, offset, whence=0):
"""Set the buffer's current position, like stdio's fseek().
:type offset: numbers.Integral
:type whence: numbers.Integral
:rtype: None
"""
pass
def tell(self):
"""Return the buffer's current position, like stdio's ftell().
:rtype: int
"""
pass
def truncate(self, size=-1):
"""Truncate the buffer's size.
:type size: numbers.Integral
:rtype: None
"""
pass
def write(self, str):
""""Write bytes or a string to the buffer.
:type str: T
:rtype: None
"""
pass
def writelines(self, sequence):
"""Write a sequence of bytes or strings to the buffer.
:type sequence: collections.Iterable[T]
:rtype: None
"""
pass