UI/CompareDialog.py

changeset 2835
678978fe9ffd
parent 2580
7403bc14ea26
child 2836
289ad03f0e57
equal deleted inserted replaced
2832:2997bc65a48b 2835:678978fe9ffd
240 self.trUtf8("Compare Files"), 240 self.trUtf8("Compare Files"),
241 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""") 241 self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""")
242 .format(filename2)) 242 .format(filename2))
243 return 243 return
244 244
245 self.__compare(lines1, lines2)
246
247 def compare(self, lines1, lines2, name1="", name2=""):
248 """
249 Public method to compare two lists of text.
250
251 @param lines1 text to compare against (string or list of strings)
252 @param lines2 text to compare (string or list of strings)
253 @keyparam name1 name to be shown for the first text (string)
254 @keyparam name2 name to be shown for the second text (string)
255 """
256 if name1 == "" or name2 == "":
257 self.filesGroup.hide()
258 else:
259 self.file1Button.hide()
260 self.file2Button.hide()
261 self.file1Edit.setText(name1)
262 self.file1Edit.setReadOnly(True)
263 self.file2Edit.setText(name2)
264 self.file2Edit.setReadOnly(True)
265 self.diffButton.setEnabled(False)
266 self.diffButton.hide()
267
268 if type(lines1) == type(""):
269 lines1 = lines1.splitlines(True)
270 if type(lines2) == type(""):
271 lines2 = lines2.splitlines(True)
272
273 self.__compare(lines1, lines2)
274
275 def __compare(self, lines1, lines2):
276 """
277 Private method to compare two lists of text.
278
279 @param lines1 text to compare against (list of strings)
280 @param lines2 text to compare (list of strings)
281 """
245 self.contents_1.clear() 282 self.contents_1.clear()
246 self.contents_2.clear() 283 self.contents_2.clear()
247 284
248 # counters for changes 285 # counters for changes
249 added = 0 286 added = 0

eric ide

mercurial