• Home
  • Raw
  • Download

Lines Matching refs:self

121   def __init__(self, output_path, base_dir, archive_size, enable_compression):  argument
133 self.output_dir = output_path
134 self.current_archive = '0.zip'
135 self.base_path = base_dir
136 self.max_size = archive_size
137 self.compress = enable_compression
140 self.index_fp = None
142 def StartCompress(self): argument
149 self.index_fp = open(os.path.join(self.output_dir, 'main.py'), 'w')
150 self.index_fp.write(divide_and_compress_constants.file_preamble)
151 os.path.walk(self.base_path, self.CompressDirectory, 1)
152 self.index_fp.write(divide_and_compress_constants.file_endpiece)
153 self.index_fp.close()
155 def RemoveLastFile(self, archive_path=None): argument
170 archive_path = os.path.join(self.output_dir, self.current_archive)
176 old_fp = self.OpenZipFileAtPath(old_archive, mode='r')
180 if self.compress:
182 new_fp = self.OpenZipFileAtPath(archive_path,
195 def OpenZipFileAtPath(self, path, mode=None, compress=zipfile.ZIP_DEFLATED): argument
208 def CompressDirectory(self, unused_id, dir_path, dir_contents): argument
230 if not self.compress:
238 self.AddFileToArchive(target_file, compress_bit)
241 if not self.ArchiveIsValid():
246 if not self.FixArchive('SIZE'):
249 self.current_archive = '%i.zip' % (
250 int(self.current_archive[
251 0:self.current_archive.rfind('.zip')]) + 1)
255 self.WriteIndexRecord()
260 def WriteIndexRecord(self): argument
268 archive = self.OpenZipFileAtPath(
269 os.path.join(self.output_dir, self.current_archive), 'r')
272 self.index_fp.write(
273 '[\'%s\', \'%s\'],\n' % (self.current_archive,
281 def FixArchive(self, problem): argument
291 archive_path = os.path.join(self.output_dir, self.current_archive)
295 archive_obj = self.OpenZipFileAtPath(archive_path, mode='r')
303 self.base_path, archive_obj.infolist()[0].filename))
309 self.RemoveLastFile(
310 os.path.join(self.output_dir, self.current_archive))
312 self.current_archive, os.path.getsize(archive_path))
316 def AddFileToArchive(self, filepath, compress_bit): argument
328 curr_archive_path = os.path.join(self.output_dir, self.current_archive)
332 archive = self.OpenZipFileAtPath(curr_archive_path,
335 archive.write(filepath, filepath[len(self.base_path):])
341 def ArchiveIsValid(self): argument
350 archive_path = os.path.join(self.output_dir, self.current_archive)
351 return os.path.getsize(archive_path) <= self.max_size