Save project files backup

master
Yevgen Muntyan 2006-09-27 19:37:20 -05:00
parent 3c471df7a3
commit d50d5c57ef
2 changed files with 15 additions and 1 deletions

View File

@ -37,6 +37,10 @@ class Config(Group):
def load_xml(self, xml):
Group.load(self, xml)
def format(self):
return '<?xml version="1.0" encoding="UTF-8"?>\n' + \
self.get_xml().get_string()
def dump_xml(self):
return self.get_xml().get_string()

View File

@ -1,5 +1,6 @@
import moo
import os.path
import shutil
from moo.utils import _
from mprj.project import Project
@ -67,7 +68,16 @@ class SimpleProject(Project):
print_error()
def save_config(self):
print self.config.get_xml()
try:
tmpname = os.path.join(os.path.dirname(self.filename), '.' + os.path.basename(self.filename) + '.tmp')
tmp = open(tmpname, "w")
tmp.write(self.config.format())
tmp.close()
shutil.copymode(self.filename, tmpname)
shutil.move(self.filename, self.filename + '.bak')
shutil.move(tmpname, self.filename)
except:
print_error()
def options_dialog(self, window):
dialog = self.create_options_dialog()