Example #1
0
 def to_file(self, filename, use_free=True):
     """Save group as a separate WAD file.
     
     If use_free is true, existing free space in the WAD will
     be used, if possible."""
     w = WadIO(filename)
     self.save_wadio(w, use_free=use_free)
Example #2
0
 def to_file(self, filename):
     """Save contents to a WAD file. Caution: if a file with the given name
     already exists, it will be overwritten. However, the existing file will
     be kept as <filename>.tmp until the operation has finished, to stay safe
     in case of failure."""
     use_backup = os.path.exists(filename)
     tmpfilename = filename + ".tmp"
     if use_backup:
         if os.path.exists(tmpfilename):
             os.remove(tmpfilename)
         os.rename(filename, tmpfilename)
     w = WadIO(filename)
     for group in write_order:
         self.__dict__[group].save_wadio(w)
     w.save()
     if use_backup:
         os.remove(tmpfilename)
Example #3
0
 def from_file(self, source):
     """Load contents from a file. `source` may be a string
     specifying a path to a file or a WadIO object."""
     if isinstance(source, WadIO):
         w = source
     elif isinstance(source, str):
         assert os.path.exists(source)
         w = WadIO(source)
     else:
         raise TypeError, "Expected WadIO or file path string"
     for group in self.groups:
         group.load_wadio(w)
Example #4
0
 def to_file(self, filename):
     """Save group as a separate WAD file."""
     w = WadIO(filename)
     self.save_wadio(w)