Show More
@@ -139,15 +139,22 b' class abstractopener(object):' | |||
|
139 | 139 | '''Prevent instantiation; don't call this from subclasses.''' |
|
140 | 140 | raise NotImplementedError('attempted instantiating ' + str(type(self))) |
|
141 | 141 | |
|
142 |
def read(self, |
|
|
143 |
fp = self( |
|
|
142 | def read(self, path): | |
|
143 | fp = self(path, 'rb') | |
|
144 | 144 | try: |
|
145 | 145 | return fp.read() |
|
146 | 146 | finally: |
|
147 | 147 | fp.close() |
|
148 | 148 | |
|
149 |
def write(self, |
|
|
150 |
fp = self( |
|
|
149 | def write(self, path, data): | |
|
150 | fp = self(path, 'wb') | |
|
151 | try: | |
|
152 | return fp.write(data) | |
|
153 | finally: | |
|
154 | fp.close() | |
|
155 | ||
|
156 | def append(self, path, data): | |
|
157 | fp = self(path, 'ab') | |
|
151 | 158 | try: |
|
152 | 159 | return fp.write(data) |
|
153 | 160 | finally: |
@@ -778,8 +778,15 b' def readfile(path):' | |||
|
778 | 778 | finally: |
|
779 | 779 | fp.close() |
|
780 | 780 | |
|
781 |
def writefile(path, |
|
|
782 |
fp = open(path, |
|
|
781 | def writefile(path, text): | |
|
782 | fp = open(path, 'wb') | |
|
783 | try: | |
|
784 | fp.write(text) | |
|
785 | finally: | |
|
786 | fp.close() | |
|
787 | ||
|
788 | def appendfile(path, text): | |
|
789 | fp = open(path, 'ab') | |
|
783 | 790 | try: |
|
784 | 791 | fp.write(text) |
|
785 | 792 | finally: |
General Comments 0
You need to be logged in to leave comments.
Login now