Logo Search packages:      
Sourcecode: sabayon version File versions  Download package

def lib::userdb::UserDatabase::__save_as (   self,
  filename = None 
) [private]

Save the current version to the given filename

Definition at line 315 of file userdb.py.

00315                                         :
        """Save the current version to the given filename"""
      if filename == None:
          filename = self.file

      dprint("Saving UserDatabase to %s\n", filename)
      try:
          os.rename(filename, filename + ".bak")
          backup = 1
      except:
          backup = 0
          pass

      try:
          f = open(filename, 'w')
      except:
          if backup == 1:
              try:
                os.rename(filename + ".bak", filename)
                dprint("Restore from %s.bak\n", filename)
            except:
                dprint("Failed to restore from %s.bak\n", filename)

          raise UserDatabaseException(
                    _("Could not open %s for writing") % filename)
      try:
          f.write(self.doc.serialize("UTF-8", format=1))
          f.close()
      except:
          if backup == 1:
              try:
                os.rename(filename + ".bak", filename)
                dprint("Restore from %s.bak\n", filename)
            except:
                dprint("Failed to restore from %s.bak\n", filename)

          raise UserDatabaseException(
                    _("Failed to save UserDatabase to %s") % filename)
      
      self.modified = 0

    def set_default_profile (self, profile):


Generated by  Doxygen 1.6.0   Back to index