MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/492214_dal6py/recipe-492214.py:160–182  ·  view source on GitHub ↗
(self, disk_object, path, mode)

Source from the content-addressed store, hash-verified

158
159 # File Accessor Object
160 def __init__(self, disk_object, path, mode):
161 assert disk_object.__class__ is DAL5
162 assert type(path) is str and path
163 assert mode == self.READ or mode == self.WRITE or mode == self.APPEND
164 self.__disk = disk_object
165 if self.__disk.exists(path):
166 assert self.__disk.is_file(path)
167 else:
168 assert mode == self.WRITE
169 self.__disk.make_file(path)
170 parts = path.split(self.__disk.PATH_SEPARATOR)
171 self.closed = self.__closed = False
172 self.mode = self.__mode = mode
173 self.name = self.__name = parts[-1]
174 self.path = self.__path = path
175 if mode == self.WRITE:
176 self.__stream = ''
177 else:
178 self.__stream = self.__disk.read_file(path)
179 if mode == self.APPEND:
180 self.__pointer = len(self.__stream)
181 else:
182 self.__pointer = 0
183
184 # Permanently Close File
185 def close(self, force):

Callers

nothing calls this directly

Calls 5

existsMethod · 0.45
is_fileMethod · 0.45
make_fileMethod · 0.45
splitMethod · 0.45
read_fileMethod · 0.45

Tested by

no test coverage detected