Advertisement
SPEL

Untitled

Aug 27th, 2011
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1.     def save_patch(self, event=None):
  2.         if os.path.isfile(self.file2patch.GetValue()):
  3.             dialog = wx.FileDialog(self.file2patch_dialog, _("Save patch"), style=wx.SAVE|wx.OVERWRITE_PROMPT)
  4.             if dialog.ShowModal() == wx.ID_OK:
  5.                 content = codecs.open(self.file2patch.GetValue(), mode="r").readlines()
  6.                 diff = difflib.unified_diff(content, self.content.GetText().split("\n"), fromfile=self.file2patch.GetValue(), tofile=self.path, lineterm="\n")
  7.                 patch_path = dialog.GetPath()
  8.                 patch = codecs.open(patch_path, mode="w", encoding="utf-8")
  9.                 patch.writelines(diff)
  10.                 patch.close()
  11.         else:
  12.             dialog = wx.MesageDialog(self.file2patch_dialog,
  13.                                      _("File to patch"),
  14.                                      _("File selected to patch doesn't exists!"),
  15.                                      style=wx.OK|wx.ICON_ERROR)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement