##// END OF EJS Templates
opener: add read & write utility methods...
Dan Villiom Podlaski Christiansen -
r14097:ca3376f0 default
parent child Browse files
Show More
@@ -136,6 +136,20 b' class abstractopener(object):'
136 '''Prevent instantiation; don't call this from subclasses.'''
136 '''Prevent instantiation; don't call this from subclasses.'''
137 raise NotImplementedError('attempted instantiating ' + str(type(self)))
137 raise NotImplementedError('attempted instantiating ' + str(type(self)))
138
138
139 def read(self, *args, **kwargs):
140 fp = self(*args, **kwargs)
141 try:
142 return fp.read()
143 finally:
144 fp.close()
145
146 def write(self, data, *args, **kwargs):
147 fp = self(*args, **kwargs)
148 try:
149 return fp.write(data)
150 finally:
151 fp.close()
152
139 class opener(abstractopener):
153 class opener(abstractopener):
140 '''Open files relative to a base directory
154 '''Open files relative to a base directory
141
155
General Comments 0
You need to be logged in to leave comments. Login now