equal
deleted
inserted
replaced
133 """Abstract base class; cannot be instantiated""" |
133 """Abstract base class; cannot be instantiated""" |
134 |
134 |
135 def __init__(self, *args, **kwargs): |
135 def __init__(self, *args, **kwargs): |
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 |
|
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() |
138 |
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 |
142 This class is used to hide the details of COW semantics and |
156 This class is used to hide the details of COW semantics and |