Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="module-subprocess.html" /> | |
13 | <link rel="prev" href="module-statvfs.html" /> | |
14 | <link rel="parent" href="allos.html" /> | |
15 | <link rel="next" href="dircmp-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>6.7 filecmp -- File and Directory Comparisons</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="6.6 statvfs " | |
25 | href="module-statvfs.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="6. Generic Operating System" | |
28 | href="allos.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="6.7.1 The dircmp class" | |
31 | href="dircmp-objects.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="module-statvfs.html">6.6 statvfs </A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="allos.html">6. Generic Operating System</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="dircmp-objects.html">6.7.1 The dircmp class</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION008700000000000000000"> | |
56 | 6.7 <tt class="module">filecmp</tt> -- | |
57 | File and Directory Comparisons</A> | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | <A NAME="module-filecmp"></A> | |
62 | ||
63 | <P> | |
64 | The <tt class="module">filecmp</tt> module defines functions to compare files and | |
65 | directories, with various optional time/correctness trade-offs. | |
66 | ||
67 | <P> | |
68 | The <tt class="module">filecmp</tt> module defines the following functions: | |
69 | ||
70 | <P> | |
71 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
72 | <td><nobr><b><tt id='l2h-1814' xml:id='l2h-1814' class="function">cmp</tt></b>(</nobr></td> | |
73 | <td><var>f1, f2</var><big>[</big><var>, shallow</var><big>[</big><var>, use_statcache</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
74 | <dd> | |
75 | Compare the files named <var>f1</var> and <var>f2</var>, returning <code>True</code> if | |
76 | they seem equal, <code>False</code> otherwise. | |
77 | ||
78 | <P> | |
79 | Unless <var>shallow</var> is given and is false, files with identical | |
80 | <tt class="function">os.stat()</tt> signatures are taken to be equal. | |
81 | ||
82 | <span class="versionnote">Changed in version 2.3: | |
83 | <var>use_statcache</var> is obsolete and ignored..</span> | |
84 | ||
85 | <P> | |
86 | Files that were compared using this function will not be compared again | |
87 | unless their <tt class="function">os.stat()</tt> signature changes. | |
88 | ||
89 | <P> | |
90 | Note that no external programs are called from this function, giving it | |
91 | portability and efficiency. | |
92 | </dl> | |
93 | ||
94 | <P> | |
95 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
96 | <td><nobr><b><tt id='l2h-1815' xml:id='l2h-1815' class="function">cmpfiles</tt></b>(</nobr></td> | |
97 | <td><var>dir1, dir2, common</var><big>[</big><var>, | |
98 | shallow</var><big>[</big><var>, use_statcache</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
99 | <dd> | |
100 | Returns three lists of file names: <var>match</var>, <var>mismatch</var>, | |
101 | <var>errors</var>. <var>match</var> contains the list of files match in both | |
102 | directories, <var>mismatch</var> includes the names of those that don't, | |
103 | and <var>errros</var> lists the names of files which could not be | |
104 | compared. Files may be listed in <var>errors</var> because the user may | |
105 | lack permission to read them or many other reasons, but always that | |
106 | the comparison could not be done for some reason. | |
107 | ||
108 | <P> | |
109 | The <var>common</var> parameter is a list of file names found in both directories. | |
110 | The <var>shallow</var> and <var>use_statcache</var> parameters have the same | |
111 | meanings and default values as for <tt class="function">filecmp.cmp()</tt>. | |
112 | </dl> | |
113 | ||
114 | <P> | |
115 | Example: | |
116 | ||
117 | <P> | |
118 | <div class="verbatim"><pre> | |
119 | >>> import filecmp | |
120 | >>> filecmp.cmp('libundoc.tex', 'libundoc.tex') | |
121 | True | |
122 | >>> filecmp.cmp('libundoc.tex', 'lib.tex') | |
123 | False | |
124 | </pre></div> | |
125 | ||
126 | <P> | |
127 | ||
128 | <p><br /></p><hr class='online-navigation' /> | |
129 | <div class='online-navigation'> | |
130 | <!--Table of Child-Links--> | |
131 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
132 | ||
133 | <UL CLASS="ChildLinks"> | |
134 | <LI><A href="dircmp-objects.html">6.7.1 The <tt class="class">dircmp</tt> class</a> | |
135 | </ul> | |
136 | <!--End of Table of Child-Links--> | |
137 | </div> | |
138 | ||
139 | <DIV CLASS="navigation"> | |
140 | <div class='online-navigation'> | |
141 | <p></p><hr /> | |
142 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
143 | <tr> | |
144 | <td class='online-navigation'><a rel="prev" title="6.6 statvfs " | |
145 | href="module-statvfs.html"><img src='../icons/previous.png' | |
146 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
147 | <td class='online-navigation'><a rel="parent" title="6. Generic Operating System" | |
148 | href="allos.html"><img src='../icons/up.png' | |
149 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
150 | <td class='online-navigation'><a rel="next" title="6.7.1 The dircmp class" | |
151 | href="dircmp-objects.html"><img src='../icons/next.png' | |
152 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
153 | <td align="center" width="100%">Python Library Reference</td> | |
154 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
155 | href="contents.html"><img src='../icons/contents.png' | |
156 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
157 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
158 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
159 | <td class='online-navigation'><a rel="index" title="Index" | |
160 | href="genindex.html"><img src='../icons/index.png' | |
161 | border='0' height='32' alt='Index' width='32' /></A></td> | |
162 | </tr></table> | |
163 | <div class='online-navigation'> | |
164 | <b class="navlabel">Previous:</b> | |
165 | <a class="sectref" rel="prev" href="module-statvfs.html">6.6 statvfs </A> | |
166 | <b class="navlabel">Up:</b> | |
167 | <a class="sectref" rel="parent" href="allos.html">6. Generic Operating System</A> | |
168 | <b class="navlabel">Next:</b> | |
169 | <a class="sectref" rel="next" href="dircmp-objects.html">6.7.1 The dircmp class</A> | |
170 | </div> | |
171 | </div> | |
172 | <hr /> | |
173 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
174 | </DIV> | |
175 | <!--End of Navigation Panel--> | |
176 | <ADDRESS> | |
177 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
178 | </ADDRESS> | |
179 | </BODY> | |
180 | </HTML> |