eric6/Documentation/Source/eric6.UI.DiffDialog.html

changeset 6942
2602857055c5
parent 4602
48cc4820e2c2
child 7273
391d6b7b1eff
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric6.UI.DiffDialog</title>
4 <meta charset="UTF-8">
5 <style>
6 body {
7 background: #EDECE6;
8 margin: 0em 1em 10em 1em;
9 color: black;
10 }
11
12 h1 { color: white; background: #85774A; }
13 h2 { color: white; background: #85774A; }
14 h3 { color: white; background: #9D936E; }
15 h4 { color: white; background: #9D936E; }
16
17 a { color: #BA6D36; }
18
19 </style>
20 </head>
21 <body><a NAME="top" ID="top"></a>
22 <h1>eric6.UI.DiffDialog</h1>
23 <p>
24 Module implementing a dialog to compare two files.
25 </p>
26 <h3>Global Attributes</h3>
27 <table>
28 <tr><td>None</td></tr>
29 </table>
30 <h3>Classes</h3>
31 <table>
32 <tr>
33 <td><a href="#DiffDialog">DiffDialog</a></td>
34 <td>Class implementing a dialog to compare two files.</td>
35 </tr><tr>
36 <td><a href="#DiffWindow">DiffWindow</a></td>
37 <td>Main window class for the standalone dialog.</td>
38 </tr>
39 </table>
40 <h3>Functions</h3>
41 <table>
42 <tr>
43 <td><a href="#context_diff">context_diff</a></td>
44 <td>Compare two sequences of lines; generate the delta as a context diff.</td>
45 </tr><tr>
46 <td><a href="#unified_diff">unified_diff</a></td>
47 <td>Compare two sequences of lines; generate the delta as a unified diff.</td>
48 </tr>
49 </table>
50 <hr /><hr />
51 <a NAME="DiffDialog" ID="DiffDialog"></a>
52 <h2>DiffDialog</h2>
53 <p>
54 Class implementing a dialog to compare two files.
55 </p>
56 <h3>Derived from</h3>
57 QWidget, Ui_DiffDialog
58 <h3>Class Attributes</h3>
59 <table>
60 <tr><td>None</td></tr>
61 </table>
62 <h3>Class Methods</h3>
63 <table>
64 <tr><td>None</td></tr>
65 </table>
66 <h3>Methods</h3>
67 <table>
68 <tr>
69 <td><a href="#DiffDialog.__init__">DiffDialog</a></td>
70 <td>Constructor</td>
71 </tr><tr>
72 <td><a href="#DiffDialog.__appendText">__appendText</a></td>
73 <td>Private method to append text to the end of the contents pane.</td>
74 </tr><tr>
75 <td><a href="#DiffDialog.__fileChanged">__fileChanged</a></td>
76 <td>Private slot to enable/disable the Compare button.</td>
77 </tr><tr>
78 <td><a href="#DiffDialog.__generateContextDiff">__generateContextDiff</a></td>
79 <td>Private slot to generate a context diff output.</td>
80 </tr><tr>
81 <td><a href="#DiffDialog.__generateUnifiedDiff">__generateUnifiedDiff</a></td>
82 <td>Private slot to generate a unified diff output.</td>
83 </tr><tr>
84 <td><a href="#DiffDialog.on_buttonBox_clicked">on_buttonBox_clicked</a></td>
85 <td>Private slot called by a button of the button box clicked.</td>
86 </tr><tr>
87 <td><a href="#DiffDialog.on_diffButton_clicked">on_diffButton_clicked</a></td>
88 <td>Private slot to handle the Compare button press.</td>
89 </tr><tr>
90 <td><a href="#DiffDialog.on_saveButton_clicked">on_saveButton_clicked</a></td>
91 <td>Private slot to handle the Save button press.</td>
92 </tr><tr>
93 <td><a href="#DiffDialog.show">show</a></td>
94 <td>Public slot to show the dialog.</td>
95 </tr>
96 </table>
97 <h3>Static Methods</h3>
98 <table>
99 <tr><td>None</td></tr>
100 </table>
101 <a NAME="DiffDialog.__init__" ID="DiffDialog.__init__"></a>
102 <h4>DiffDialog (Constructor)</h4>
103 <b>DiffDialog</b>(<i>parent=None</i>)
104 <p>
105 Constructor
106 </p><dl>
107 <dt><i>parent</i></dt>
108 <dd>
109 reference to the parent widget (QWidget)
110 </dd>
111 </dl><a NAME="DiffDialog.__appendText" ID="DiffDialog.__appendText"></a>
112 <h4>DiffDialog.__appendText</h4>
113 <b>__appendText</b>(<i>txt</i>)
114 <p>
115 Private method to append text to the end of the contents pane.
116 </p><dl>
117 <dt><i>txt</i></dt>
118 <dd>
119 text to insert (string)
120 </dd>
121 </dl><a NAME="DiffDialog.__fileChanged" ID="DiffDialog.__fileChanged"></a>
122 <h4>DiffDialog.__fileChanged</h4>
123 <b>__fileChanged</b>(<i></i>)
124 <p>
125 Private slot to enable/disable the Compare button.
126 </p><a NAME="DiffDialog.__generateContextDiff" ID="DiffDialog.__generateContextDiff"></a>
127 <h4>DiffDialog.__generateContextDiff</h4>
128 <b>__generateContextDiff</b>(<i>a, b, fromfile, tofile, fromfiledate, tofiledate</i>)
129 <p>
130 Private slot to generate a context diff output.
131 </p><dl>
132 <dt><i>a</i></dt>
133 <dd>
134 first sequence of lines (list of strings)
135 </dd><dt><i>b</i></dt>
136 <dd>
137 second sequence of lines (list of strings)
138 </dd><dt><i>fromfile</i></dt>
139 <dd>
140 filename of the first file (string)
141 </dd><dt><i>tofile</i></dt>
142 <dd>
143 filename of the second file (string)
144 </dd><dt><i>fromfiledate</i></dt>
145 <dd>
146 modification time of the first file (string)
147 </dd><dt><i>tofiledate</i></dt>
148 <dd>
149 modification time of the second file (string)
150 </dd>
151 </dl><a NAME="DiffDialog.__generateUnifiedDiff" ID="DiffDialog.__generateUnifiedDiff"></a>
152 <h4>DiffDialog.__generateUnifiedDiff</h4>
153 <b>__generateUnifiedDiff</b>(<i>a, b, fromfile, tofile, fromfiledate, tofiledate</i>)
154 <p>
155 Private slot to generate a unified diff output.
156 </p><dl>
157 <dt><i>a</i></dt>
158 <dd>
159 first sequence of lines (list of strings)
160 </dd><dt><i>b</i></dt>
161 <dd>
162 second sequence of lines (list of strings)
163 </dd><dt><i>fromfile</i></dt>
164 <dd>
165 filename of the first file (string)
166 </dd><dt><i>tofile</i></dt>
167 <dd>
168 filename of the second file (string)
169 </dd><dt><i>fromfiledate</i></dt>
170 <dd>
171 modification time of the first file (string)
172 </dd><dt><i>tofiledate</i></dt>
173 <dd>
174 modification time of the second file (string)
175 </dd>
176 </dl><a NAME="DiffDialog.on_buttonBox_clicked" ID="DiffDialog.on_buttonBox_clicked"></a>
177 <h4>DiffDialog.on_buttonBox_clicked</h4>
178 <b>on_buttonBox_clicked</b>(<i>button</i>)
179 <p>
180 Private slot called by a button of the button box clicked.
181 </p><dl>
182 <dt><i>button</i></dt>
183 <dd>
184 button that was clicked (QAbstractButton)
185 </dd>
186 </dl><a NAME="DiffDialog.on_diffButton_clicked" ID="DiffDialog.on_diffButton_clicked"></a>
187 <h4>DiffDialog.on_diffButton_clicked</h4>
188 <b>on_diffButton_clicked</b>(<i></i>)
189 <p>
190 Private slot to handle the Compare button press.
191 </p><a NAME="DiffDialog.on_saveButton_clicked" ID="DiffDialog.on_saveButton_clicked"></a>
192 <h4>DiffDialog.on_saveButton_clicked</h4>
193 <b>on_saveButton_clicked</b>(<i></i>)
194 <p>
195 Private slot to handle the Save button press.
196 </p><p>
197 It saves the diff shown in the dialog to a file in the local
198 filesystem.
199 </p><a NAME="DiffDialog.show" ID="DiffDialog.show"></a>
200 <h4>DiffDialog.show</h4>
201 <b>show</b>(<i>filename=None</i>)
202 <p>
203 Public slot to show the dialog.
204 </p><dl>
205 <dt><i>filename</i></dt>
206 <dd>
207 name of a file to use as the first file (string)
208 </dd>
209 </dl>
210 <div align="right"><a href="#top">Up</a></div>
211 <hr /><hr />
212 <a NAME="DiffWindow" ID="DiffWindow"></a>
213 <h2>DiffWindow</h2>
214 <p>
215 Main window class for the standalone dialog.
216 </p>
217 <h3>Derived from</h3>
218 E5MainWindow
219 <h3>Class Attributes</h3>
220 <table>
221 <tr><td>None</td></tr>
222 </table>
223 <h3>Class Methods</h3>
224 <table>
225 <tr><td>None</td></tr>
226 </table>
227 <h3>Methods</h3>
228 <table>
229 <tr>
230 <td><a href="#DiffWindow.__init__">DiffWindow</a></td>
231 <td>Constructor</td>
232 </tr><tr>
233 <td><a href="#DiffWindow.eventFilter">eventFilter</a></td>
234 <td>Public method to filter events.</td>
235 </tr>
236 </table>
237 <h3>Static Methods</h3>
238 <table>
239 <tr><td>None</td></tr>
240 </table>
241 <a NAME="DiffWindow.__init__" ID="DiffWindow.__init__"></a>
242 <h4>DiffWindow (Constructor)</h4>
243 <b>DiffWindow</b>(<i>parent=None</i>)
244 <p>
245 Constructor
246 </p><dl>
247 <dt><i>parent</i></dt>
248 <dd>
249 reference to the parent widget (QWidget)
250 </dd>
251 </dl><a NAME="DiffWindow.eventFilter" ID="DiffWindow.eventFilter"></a>
252 <h4>DiffWindow.eventFilter</h4>
253 <b>eventFilter</b>(<i>obj, event</i>)
254 <p>
255 Public method to filter events.
256 </p><dl>
257 <dt><i>obj</i></dt>
258 <dd>
259 reference to the object the event is meant for (QObject)
260 </dd><dt><i>event</i></dt>
261 <dd>
262 reference to the event object (QEvent)
263 </dd>
264 </dl><dl>
265 <dt>Returns:</dt>
266 <dd>
267 flag indicating, whether the event was handled (boolean)
268 </dd>
269 </dl>
270 <div align="right"><a href="#top">Up</a></div>
271 <hr /><hr />
272 <a NAME="context_diff" ID="context_diff"></a>
273 <h2>context_diff</h2>
274 <b>context_diff</b>(<i>a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'</i>)
275 <p>
276 Compare two sequences of lines; generate the delta as a context diff.
277 </p><p>
278 Context diffs are a compact way of showing line changes and a few
279 lines of context. The number of context lines is set by 'n' which
280 defaults to three.
281 </p><p>
282 By default, the diff control lines (those with *** or ---) are
283 created with a trailing newline. This is helpful so that inputs
284 created from file.readlines() result in diffs that are suitable for
285 file.writelines() since both the inputs and outputs have trailing
286 newlines.
287 </p><p>
288 For inputs that do not have trailing newlines, set the lineterm
289 argument to "" so that the output will be uniformly newline free.
290 </p><p>
291 The context diff format normally has a header for filenames and
292 modification times. Any or all of these may be specified using
293 strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
294 The modification times are normally expressed in the format returned
295 by time.ctime(). If not specified, the strings default to blanks.
296 </p><p>
297 Example:
298 </p><p>
299 <pre>
300 &gt;&gt;&gt; print ''.join(
301 ... context_diff('one\ntwo\nthree\nfour\n'.splitlines(1),
302 ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current',
303 ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:22:46 2003')),
304 *** Original Sat Jan 26 23:30:50 1991
305 --- Current Fri Jun 06 10:22:46 2003
306 ***************
307 *** 1,4 ****
308 one
309 ! two
310 ! three
311 four
312 --- 1,4 ----
313 + zero
314 one
315 ! tree
316 four
317 </pre>
318 </p><dl>
319 <dt><i>a</i></dt>
320 <dd>
321 first sequence of lines (list of strings)
322 </dd><dt><i>b</i></dt>
323 <dd>
324 second sequence of lines (list of strings)
325 </dd><dt><i>fromfile</i></dt>
326 <dd>
327 filename of the first file (string)
328 </dd><dt><i>tofile</i></dt>
329 <dd>
330 filename of the second file (string)
331 </dd><dt><i>fromfiledate</i></dt>
332 <dd>
333 modification time of the first file (string)
334 </dd><dt><i>tofiledate</i></dt>
335 <dd>
336 modification time of the second file (string)
337 </dd><dt><i>n</i></dt>
338 <dd>
339 number of lines of context (integer)
340 </dd><dt><i>lineterm</i></dt>
341 <dd>
342 line termination string (string)
343 </dd>
344 </dl><dl>
345 <dt>Returns:</dt>
346 <dd>
347 a generator yielding lines of differences
348 </dd>
349 </dl>
350 <div align="right"><a href="#top">Up</a></div>
351 <hr /><hr />
352 <a NAME="unified_diff" ID="unified_diff"></a>
353 <h2>unified_diff</h2>
354 <b>unified_diff</b>(<i>a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'</i>)
355 <p>
356 Compare two sequences of lines; generate the delta as a unified diff.
357 </p><p>
358 Unified diffs are a compact way of showing line changes and a few
359 lines of context. The number of context lines is set by 'n' which
360 defaults to three.
361 </p><p>
362 By default, the diff control lines (those with ---, +++, or @@) are
363 created with a trailing newline. This is helpful so that inputs
364 created from file.readlines() result in diffs that are suitable for
365 file.writelines() since both the inputs and outputs have trailing
366 newlines.
367 </p><p>
368 For inputs that do not have trailing newlines, set the lineterm
369 argument to "" so that the output will be uniformly newline free.
370 </p><p>
371 The unidiff format normally has a header for filenames and modification
372 times. Any or all of these may be specified using strings for
373 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification
374 times are normally expressed in the format returned by time.ctime().
375 </p><p>
376 Example:
377 </p><p>
378 <pre>
379 &gt;&gt;&gt; for line in unified_diff('one two three four'.split(),
380 ... 'zero one tree four'.split(), 'Original', 'Current',
381 ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003',
382 ... lineterm=''):
383 ... print line
384 --- Original Sat Jan 26 23:30:50 1991
385 +++ Current Fri Jun 06 10:20:52 2003
386 @ -1,4 +1,4 @@
387 +zero
388 one
389 -two
390 -three
391 +tree
392 four
393 </pre>
394 </p><dl>
395 <dt><i>a</i></dt>
396 <dd>
397 first sequence of lines (list of strings)
398 </dd><dt><i>b</i></dt>
399 <dd>
400 second sequence of lines (list of strings)
401 </dd><dt><i>fromfile</i></dt>
402 <dd>
403 filename of the first file (string)
404 </dd><dt><i>tofile</i></dt>
405 <dd>
406 filename of the second file (string)
407 </dd><dt><i>fromfiledate</i></dt>
408 <dd>
409 modification time of the first file (string)
410 </dd><dt><i>tofiledate</i></dt>
411 <dd>
412 modification time of the second file (string)
413 </dd><dt><i>n</i></dt>
414 <dd>
415 number of lines of context (integer)
416 </dd><dt><i>lineterm</i></dt>
417 <dd>
418 line termination string (string)
419 </dd>
420 </dl><dl>
421 <dt>Returns:</dt>
422 <dd>
423 a generator yielding lines of differences
424 </dd>
425 </dl>
426 <div align="right"><a href="#top">Up</a></div>
427 <hr />
428 </body></html>

eric ide

mercurial