summary refs log tree commit diff stats
path: root/doc/pydoc/ranger.ext.shutil_generatorized.html
blob: 432e43399a83b92d58cc81eb7ea268ca39f39ac9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module ranger.ext.shutil_generatorized</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="ranger.html"><font color="#ffffff">ranger</font></a>.<a href="ranger.ext.html"><font color="#ffffff">ext</font></a>.shutil_generatorized</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/ranger/ext/shutil_generatorized.py">/home/hut/ranger/ranger/ext/shutil_generatorized.py</a></font></td></tr></table>
    <p><tt>Utility&nbsp;functions&nbsp;for&nbsp;copying&nbsp;files&nbsp;and&nbsp;directory&nbsp;trees.<br>
&nbsp;<br>
XXX&nbsp;The&nbsp;functions&nbsp;here&nbsp;don't&nbsp;copy&nbsp;the&nbsp;resource&nbsp;fork&nbsp;or&nbsp;other&nbsp;metadata&nbsp;on&nbsp;Mac.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="fnmatch.html">fnmatch</a><br>
</td><td width="25%" valign=top><a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="stat.html">stat</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>(<a href="exceptions.html#StandardError">exceptions.StandardError</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="ranger.ext.shutil_generatorized.html#Error">Error</a>
</font></dt><dt><font face="helvetica, arial"><a href="ranger.ext.shutil_generatorized.html#SpecialFileError">SpecialFileError</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Error">class <strong>Error</strong></a>(<a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>)</font></td></tr>
    
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.ext.shutil_generatorized.html#Error">Error</a></dd>
<dd><a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a></dd>
<dd><a href="exceptions.html#StandardError">exceptions.StandardError</a></dd>
<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd>
<dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>:<br>
<dl><dt><a name="Error-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__init__">__init__</a>(...)&nbsp;initializes&nbsp;x;&nbsp;see&nbsp;x.__class__.__doc__&nbsp;for&nbsp;signature</tt></dd></dl>

<dl><dt><a name="Error-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>

<dl><dt><a name="Error-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__str__">__str__</a>()&nbsp;&lt;==&gt;&nbsp;str(x)</tt></dd></dl>

<hr>
Data descriptors inherited from <a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>:<br>
<dl><dt><strong>errno</strong></dt>
<dd><tt>exception&nbsp;errno</tt></dd>
</dl>
<dl><dt><strong>filename</strong></dt>
<dd><tt>exception&nbsp;filename</tt></dd>
</dl>
<dl><dt><strong>strerror</strong></dt>
<dd><tt>exception&nbsp;strerror</tt></dd>
</dl>
<hr>
Data and other attributes inherited from <a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>:<br>
<dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object at 0x2ab5dfa26d00&gt;<dd><tt>T.<a href="#Error-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;object&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>

<hr>
Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><a name="Error-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__delattr__">__delattr__</a>('name')&nbsp;&lt;==&gt;&nbsp;del&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="Error-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__getattribute__">__getattribute__</a>('name')&nbsp;&lt;==&gt;&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="Error-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__getitem__">__getitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;x[y]</tt></dd></dl>

<dl><dt><a name="Error-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__getslice__">__getslice__</a>(i,&nbsp;j)&nbsp;&lt;==&gt;&nbsp;x[i:j]<br>
&nbsp;<br>
Use&nbsp;of&nbsp;negative&nbsp;indices&nbsp;is&nbsp;not&nbsp;supported.</tt></dd></dl>

<dl><dt><a name="Error-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__repr__">__repr__</a>()&nbsp;&lt;==&gt;&nbsp;repr(x)</tt></dd></dl>

<dl><dt><a name="Error-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Error-__setattr__">__setattr__</a>('name',&nbsp;value)&nbsp;&lt;==&gt;&nbsp;x.name&nbsp;=&nbsp;value</tt></dd></dl>

<dl><dt><a name="Error-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>

<dl><dt><a name="Error-__unicode__"><strong>__unicode__</strong></a>(...)</dt></dl>

<hr>
Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
</dl>
<dl><dt><strong>args</strong></dt>
</dl>
<dl><dt><strong>message</strong></dt>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="SpecialFileError">class <strong>SpecialFileError</strong></a>(<a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Raised&nbsp;when&nbsp;trying&nbsp;to&nbsp;do&nbsp;a&nbsp;kind&nbsp;of&nbsp;operation&nbsp;(e.g.&nbsp;copying)&nbsp;which&nbsp;is<br>
not&nbsp;supported&nbsp;on&nbsp;a&nbsp;special&nbsp;file&nbsp;(e.g.&nbsp;a&nbsp;named&nbsp;pipe)<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="ranger.ext.shutil_generatorized.html#SpecialFileError">SpecialFileError</a></dd>
<dd><a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a></dd>
<dd><a href="exceptions.html#StandardError">exceptions.StandardError</a></dd>
<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd>
<dd><a href="exceptions.html#BaseException">exceptions.BaseException</a></dd>
<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
</dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Methods inherited from <a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>:<br>
<dl><dt><a name="SpecialFileError-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__init__">__init__</a>(...)&nbsp;initializes&nbsp;x;&nbsp;see&nbsp;x.__class__.__doc__&nbsp;for&nbsp;signature</tt></dd></dl>

<dl><dt><a name="SpecialFileError-__reduce__"><strong>__reduce__</strong></a>(...)</dt></dl>

<dl><dt><a name="SpecialFileError-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__str__">__str__</a>()&nbsp;&lt;==&gt;&nbsp;str(x)</tt></dd></dl>

<hr>
Data descriptors inherited from <a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>:<br>
<dl><dt><strong>errno</strong></dt>
<dd><tt>exception&nbsp;errno</tt></dd>
</dl>
<dl><dt><strong>filename</strong></dt>
<dd><tt>exception&nbsp;filename</tt></dd>
</dl>
<dl><dt><strong>strerror</strong></dt>
<dd><tt>exception&nbsp;strerror</tt></dd>
</dl>
<hr>
Data and other attributes inherited from <a href="exceptions.html#EnvironmentError">exceptions.EnvironmentError</a>:<br>
<dl><dt><strong>__new__</strong> = &lt;built-in method __new__ of type object at 0x2ab5dfa26d00&gt;<dd><tt>T.<a href="#SpecialFileError-__new__">__new__</a>(S,&nbsp;...)&nbsp;-&gt;&nbsp;a&nbsp;new&nbsp;object&nbsp;with&nbsp;type&nbsp;S,&nbsp;a&nbsp;subtype&nbsp;of&nbsp;T</tt></dl>

<hr>
Methods inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><a name="SpecialFileError-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__delattr__">__delattr__</a>('name')&nbsp;&lt;==&gt;&nbsp;del&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="SpecialFileError-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__getattribute__">__getattribute__</a>('name')&nbsp;&lt;==&gt;&nbsp;x.name</tt></dd></dl>

<dl><dt><a name="SpecialFileError-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__getitem__">__getitem__</a>(y)&nbsp;&lt;==&gt;&nbsp;x[y]</tt></dd></dl>

<dl><dt><a name="SpecialFileError-__getslice__"><strong>__getslice__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__getslice__">__getslice__</a>(i,&nbsp;j)&nbsp;&lt;==&gt;&nbsp;x[i:j]<br>
&nbsp;<br>
Use&nbsp;of&nbsp;negative&nbsp;indices&nbsp;is&nbsp;not&nbsp;supported.</tt></dd></dl>

<dl><dt><a name="SpecialFileError-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__repr__">__repr__</a>()&nbsp;&lt;==&gt;&nbsp;repr(x)</tt></dd></dl>

<dl><dt><a name="SpecialFileError-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#SpecialFileError-__setattr__">__setattr__</a>('name',&nbsp;value)&nbsp;&lt;==&gt;&nbsp;x.name&nbsp;=&nbsp;value</tt></dd></dl>

<dl><dt><a name="SpecialFileError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>

<dl><dt><a name="SpecialFileError-__unicode__"><strong>__unicode__</strong></a>(...)</dt></dl>

<hr>
Data descriptors inherited from <a href="exceptions.html#BaseException">exceptions.BaseException</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
</dl>
<dl><dt><strong>args</strong></dt>
</dl>
<dl><dt><strong>message</strong></dt>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    
<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl><dt><a name="-copy"><strong>copy</strong></a>(src, dst, overwrite<font color="#909090">=False</font>)</dt><dd><tt>Copy&nbsp;data&nbsp;and&nbsp;mode&nbsp;bits&nbsp;("cp&nbsp;src&nbsp;dst").<br>
&nbsp;<br>
The&nbsp;destination&nbsp;may&nbsp;be&nbsp;a&nbsp;directory.</tt></dd></dl>
 <dl><dt><a name="-copy2"><strong>copy2</strong></a>(src, dst, overwrite<font color="#909090">=False</font>, symlinks<font color="#909090">=False</font>)</dt><dd><tt>Copy&nbsp;data&nbsp;and&nbsp;all&nbsp;stat&nbsp;info&nbsp;("cp&nbsp;-p&nbsp;src&nbsp;dst").<br>
&nbsp;<br>
The&nbsp;destination&nbsp;may&nbsp;be&nbsp;a&nbsp;directory.</tt></dd></dl>
 <dl><dt><a name="-copyfile"><strong>copyfile</strong></a>(src, dst)</dt><dd><tt>Copy&nbsp;data&nbsp;from&nbsp;src&nbsp;to&nbsp;dst</tt></dd></dl>
 <dl><dt><a name="-copyfileobj"><strong>copyfileobj</strong></a>(fsrc, fdst, length<font color="#909090">=16384</font>)</dt><dd><tt>copy&nbsp;data&nbsp;from&nbsp;file-like&nbsp;object&nbsp;fsrc&nbsp;to&nbsp;file-like&nbsp;object&nbsp;fdst</tt></dd></dl>
 <dl><dt><a name="-copymode"><strong>copymode</strong></a>(src, dst)</dt><dd><tt>Copy&nbsp;mode&nbsp;bits&nbsp;from&nbsp;src&nbsp;to&nbsp;dst</tt></dd></dl>
 <dl><dt><a name="-copystat"><strong>copystat</strong></a>(src, dst)</dt><dd><tt>Copy&nbsp;all&nbsp;stat&nbsp;info&nbsp;(mode&nbsp;bits,&nbsp;atime,&nbsp;mtime,&nbsp;flags)&nbsp;from&nbsp;src&nbsp;to&nbsp;dst</tt></dd></dl>
 <dl><dt><a name="-copytree"><strong>copytree</strong></a>(src, dst, symlinks<font color="#909090">=False</font>, ignore<font color="#909090">=None</font>, overwrite<font color="#909090">=False</font>)</dt><dd><tt>Recursively&nbsp;copy&nbsp;a&nbsp;directory&nbsp;tree&nbsp;using&nbsp;<a href="#-copy2">copy2</a>().<br>
&nbsp;<br>
The&nbsp;destination&nbsp;directory&nbsp;must&nbsp;not&nbsp;already&nbsp;exist.<br>
If&nbsp;exception(s)&nbsp;occur,&nbsp;an&nbsp;<a href="#Error">Error</a>&nbsp;is&nbsp;raised&nbsp;with&nbsp;a&nbsp;list&nbsp;of&nbsp;reasons.<br>
&nbsp;<br>
If&nbsp;the&nbsp;optional&nbsp;symlinks&nbsp;flag&nbsp;is&nbsp;true,&nbsp;symbolic&nbsp;links&nbsp;in&nbsp;the<br>
source&nbsp;tree&nbsp;result&nbsp;in&nbsp;symbolic&nbsp;links&nbsp;in&nbsp;the&nbsp;destination&nbsp;tree;&nbsp;if<br>
it&nbsp;is&nbsp;false,&nbsp;the&nbsp;contents&nbsp;of&nbsp;the&nbsp;files&nbsp;pointed&nbsp;to&nbsp;by&nbsp;symbolic<br>
links&nbsp;are&nbsp;copied.<br>
&nbsp;<br>
The&nbsp;optional&nbsp;ignore&nbsp;argument&nbsp;is&nbsp;a&nbsp;callable.&nbsp;If&nbsp;given,&nbsp;it<br>
is&nbsp;called&nbsp;with&nbsp;the&nbsp;`src`&nbsp;parameter,&nbsp;which&nbsp;is&nbsp;the&nbsp;directory<br>
being&nbsp;visited&nbsp;by&nbsp;<a href="#-copytree">copytree</a>(),&nbsp;and&nbsp;`names`&nbsp;which&nbsp;is&nbsp;the&nbsp;list&nbsp;of<br>
`src`&nbsp;contents,&nbsp;as&nbsp;returned&nbsp;by&nbsp;os.listdir():<br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;callable(src,&nbsp;names)&nbsp;-&gt;&nbsp;ignored_names<br>
&nbsp;<br>
Since&nbsp;<a href="#-copytree">copytree</a>()&nbsp;is&nbsp;called&nbsp;recursively,&nbsp;the&nbsp;callable&nbsp;will&nbsp;be<br>
called&nbsp;once&nbsp;for&nbsp;each&nbsp;directory&nbsp;that&nbsp;is&nbsp;copied.&nbsp;It&nbsp;returns&nbsp;a<br>
list&nbsp;of&nbsp;names&nbsp;relative&nbsp;to&nbsp;the&nbsp;`src`&nbsp;directory&nbsp;that&nbsp;should<br>
not&nbsp;be&nbsp;copied.<br>
&nbsp;<br>
XXX&nbsp;Consider&nbsp;this&nbsp;example&nbsp;code&nbsp;rather&nbsp;than&nbsp;the&nbsp;ultimate&nbsp;tool.</tt></dd></dl>
 <dl><dt><a name="-move"><strong>move</strong></a>(src, dst, overwrite<font color="#909090">=False</font>)</dt><dd><tt>Recursively&nbsp;move&nbsp;a&nbsp;file&nbsp;or&nbsp;directory&nbsp;to&nbsp;another&nbsp;location.&nbsp;This&nbsp;is<br>
similar&nbsp;to&nbsp;the&nbsp;Unix&nbsp;"mv"&nbsp;command.<br>
&nbsp;<br>
If&nbsp;the&nbsp;destination&nbsp;is&nbsp;a&nbsp;directory&nbsp;or&nbsp;a&nbsp;symlink&nbsp;to&nbsp;a&nbsp;directory,&nbsp;the&nbsp;source<br>
is&nbsp;moved&nbsp;inside&nbsp;the&nbsp;directory.&nbsp;The&nbsp;destination&nbsp;path&nbsp;must&nbsp;not&nbsp;already<br>
exist.<br>
&nbsp;<br>
If&nbsp;the&nbsp;destination&nbsp;already&nbsp;exists&nbsp;but&nbsp;is&nbsp;not&nbsp;a&nbsp;directory,&nbsp;it&nbsp;may&nbsp;be<br>
overwritten&nbsp;depending&nbsp;on&nbsp;os.rename()&nbsp;semantics.<br>
&nbsp;<br>
If&nbsp;the&nbsp;destination&nbsp;is&nbsp;on&nbsp;our&nbsp;current&nbsp;filesystem,&nbsp;then&nbsp;rename()&nbsp;is&nbsp;used.<br>
Otherwise,&nbsp;src&nbsp;is&nbsp;copied&nbsp;to&nbsp;the&nbsp;destination&nbsp;and&nbsp;then&nbsp;removed.<br>
A&nbsp;lot&nbsp;more&nbsp;could&nbsp;be&nbsp;done&nbsp;here...&nbsp;&nbsp;A&nbsp;look&nbsp;at&nbsp;a&nbsp;mv.c&nbsp;shows&nbsp;a&nbsp;lot&nbsp;of<br>
the&nbsp;issues&nbsp;this&nbsp;implementation&nbsp;glosses&nbsp;over.</tt></dd></dl>
 <dl><dt><a name="-rmtree"><strong>rmtree</strong></a>(path, ignore_errors<font color="#909090">=False</font>, onerror<font color="#909090">=None</font>)</dt><dd><tt>Recursively&nbsp;delete&nbsp;a&nbsp;directory&nbsp;tree.<br>
&nbsp;<br>
If&nbsp;ignore_errors&nbsp;is&nbsp;set,&nbsp;errors&nbsp;are&nbsp;ignored;&nbsp;otherwise,&nbsp;if&nbsp;onerror<br>
is&nbsp;set,&nbsp;it&nbsp;is&nbsp;called&nbsp;to&nbsp;handle&nbsp;the&nbsp;error&nbsp;with&nbsp;arguments&nbsp;(func,<br>
path,&nbsp;exc_info)&nbsp;where&nbsp;func&nbsp;is&nbsp;os.listdir,&nbsp;os.remove,&nbsp;or&nbsp;os.rmdir;<br>
path&nbsp;is&nbsp;the&nbsp;argument&nbsp;to&nbsp;that&nbsp;function&nbsp;that&nbsp;caused&nbsp;it&nbsp;to&nbsp;fail;&nbsp;and<br>
exc_info&nbsp;is&nbsp;a&nbsp;tuple&nbsp;returned&nbsp;by&nbsp;sys.exc_info().&nbsp;&nbsp;If&nbsp;ignore_errors<br>
is&nbsp;false&nbsp;and&nbsp;onerror&nbsp;is&nbsp;None,&nbsp;an&nbsp;exception&nbsp;is&nbsp;raised.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__all__</strong> = ['copyfileobj', 'copyfile', 'copymode', 'copystat', 'copy', 'copy2', 'copytree', 'move', 'rmtree', 'Error', 'SpecialFileError']</td></tr></table>
</body></html>
mp;& gen_delims == 0) { char *colon; *at_sign = '\0'; if ((colon = StrChr(my_info, ':')) != 0) { *colon++ = '\0'; } if (non_empty(my_info)) { char *msg; BOOL prior = non_empty(realm->username); if (prior && strcmp(realm->username, my_info)) { msg = 0; HTSprintf0(&msg, gettext("username for realm %s changed from %s to %s"), realm->realmname, realm->username, my_info); HTAlert(msg); free(msg); FREE(realm->username); StrAllocCopy(realm->username, my_info); } else if (!prior) { StrAllocCopy(realm->username, my_info); } if (non_empty(colon)) { prior = non_empty(realm->password); if (prior && strcmp(realm->password, colon)) { msg = 0; HTSprintf0(&msg, gettext("password for realm %s user %s changed"), realm->realmname, realm->username); HTAlert(msg); free(msg); FREE(realm->password); StrAllocCopy(realm->password, colon); } else if (!prior) { StrAllocCopy(realm->password, colon); } } } } free(my_info); } /***************** Basic and Pubkey Authentication ************************/ /* static compose_auth_string() * * COMPOSE Basic OR Pubkey AUTHENTICATION STRING; * PROMPTS FOR USERNAME AND PASSWORD IF NEEDED * * ON ENTRY: * hostname may include user- and password information * scheme is either HTAA_BASIC or HTAA_PUBKEY. * setup is the current server setup. * IsProxy should be TRUE if this is a proxy. * * ON EXIT: * returns a newly composed authorization string, * (with, of course, a newly generated secret * key and fresh timestamp, if Pubkey-scheme * is being used). * NULL, if something fails. * NOTE: * Like throughout the entire AA package, no string or structure * returned by AA package needs to (or should) be freed. * */ static char *compose_auth_string(const char *hostname, HTAAScheme scheme, HTAASetup * setup, int IsProxy) { char *cleartext = NULL; /* Cleartext presentation */ char *ciphertext = NULL; /* Encrypted presentation */ size_t len; char *msg = NULL; char *username = NULL; char *password = NULL; char *realmname = NULL; char *theHost = NULL; char *proxiedHost = NULL; char *thePort = NULL; HTAARealm *realm; const char *i_net_addr = "0.0.0.0"; /* Change... @@@@ */ const char *timestamp = "42"; /* ... these @@@@ */ FREE(compose_auth_stringResult); /* From previous call */ if ((scheme != HTAA_BASIC && scheme != HTAA_PUBKEY) || !(setup && setup->scheme_specifics && setup->scheme_specifics[scheme] && setup->server && setup->server->realms)) return NULL; realmname = HTAssocList_lookup(setup->scheme_specifics[scheme], "realm"); if (!realmname) return NULL; realm = HTAARealm_lookup(setup->server->realms, realmname); setup->retry |= HTAA_HaveUserinfo(hostname); if (!(realm && non_empty(realm->username) && non_empty(realm->password)) || setup->retry) { if (!realm) { CTRACE((tfp, "%s `%s' %s\n", "compose_auth_string: realm:", realmname, "not found -- creating")); realm = HTAARealm_new(setup->server->realms, realmname, NULL, NULL); } fill_in_userinfo(realm, hostname); /* * The template should be either the '*' global for everything on the * server (always true for proxy authorization setups), or a path for * the start of a protected limb, with no host field, but we'll check * for a host anyway in case a WWW-Protection-Template header set an * absolute URL instead of a path. If we do get a host from this, it * will include the port. - FM */ if ((!IsProxy) && using_proxy && setup->ctemplate) { proxiedHost = HTParse(setup->ctemplate, "", PARSE_HOST); if (proxiedHost && *proxiedHost != '\0') { theHost = proxiedHost; } } /* * If we didn't get a host field from the template, set up the host * name and port from the setup->server elements. - FM */ if (!theHost) theHost = setup->server->hostname; if (setup->server->portnumber > 0 && setup->server->portnumber != 80) { HTSprintf0(&thePort, ":%d", setup->server->portnumber); } HTSprintf0(&msg, gettext("Username for '%s' at %s '%s%s':"), realm->realmname, (IsProxy ? "proxy" : "server"), (theHost ? theHost : "??"), NonNull(thePort)); FREE(proxiedHost); FREE(thePort); if (non_empty(realm->username)) { StrAllocCopy(username, realm->username); } if (non_empty(realm->password)) { StrAllocCopy(password, realm->password); } HTPromptUsernameAndPassword(msg, &username, &password, IsProxy); FREE(msg); FREE(realm->username); FREE(realm->password); realm->username = username; realm->password = password; if (!realm->username || !realm->password) { /* * Signals to retry. - FM */ return NULL; } else if (*realm->username == '\0') { /* * Signals to abort. - FM */ StrAllocCopy(compose_auth_stringResult, ""); return compose_auth_stringResult; } } len = (strlen(NonNull(realm->username)) + strlen(NonNull(realm->password)) + 3); if (scheme == HTAA_PUBKEY) { #ifdef PUBKEY /* Generate new secret key */ StrAllocCopy(secret_key, HTAA_generateRandomKey()); #endif /* PUBKEY */ /* Room for secret key, timestamp and inet address */ len += strlen(NonNull(secret_key)) + 30; } else { FREE(secret_key); } if ((cleartext = typecallocn(char, len)) == 0) outofmem(__FILE__, "compose_auth_string"); if (realm->username) strcpy(cleartext, realm->username); else *cleartext = '\0'; strcat(cleartext, ":"); if (realm->password) strcat(cleartext, realm->password); if (scheme == HTAA_PUBKEY) { strcat(cleartext, ":"); strcat(cleartext, i_net_addr); strcat(cleartext, ":"); strcat(cleartext, timestamp); strcat(cleartext, ":"); if (secret_key) strcat(cleartext, secret_key); if (!((ciphertext = typecallocn(char, 2 * len)) && (compose_auth_stringResult = typecallocn(char, 3 * len)))) outofmem(__FILE__, "compose_auth_string"); #ifdef PUBKEY HTPK_encrypt(cleartext, ciphertext, server->public_key); HTUU_encode((unsigned char *) ciphertext, strlen(ciphertext), compose_auth_stringResult); #endif /* PUBKEY */ FREE(cleartext); FREE(ciphertext); } else { /* scheme == HTAA_BASIC */ if (!(compose_auth_stringResult = typecallocn(char, (4 * ((len + 2) / 3)) + 1))) outofmem(__FILE__, "compose_auth_string"); HTUU_encode((unsigned char *) cleartext, strlen(cleartext), compose_auth_stringResult); FREE(cleartext); } return compose_auth_stringResult; } /* BROWSER static HTAA_selectScheme() * SELECT THE AUTHENTICATION SCHEME TO USE * ON ENTRY: * setup is the server setup structure which can * be used to make the decision about the * used scheme. * * When new authentication methods are added to library * this function makes the decision about which one to * use at a given time. This can be done by inspecting * environment variables etc. * * Currently only searches for the first valid scheme, * and if nothing found suggests Basic scheme; * * ON EXIT: * returns the authentication scheme to use. */ static HTAAScheme HTAA_selectScheme(HTAASetup * setup) { int scheme; if (setup && setup->valid_schemes) { for (scheme = HTAA_BASIC; scheme < HTAA_MAX_SCHEMES; scheme++) { void *object = (void *) (intptr_t) scheme; if (-1 < HTList_indexOf(setup->valid_schemes, object)) return (HTAAScheme) scheme; } } return HTAA_BASIC; } /* * Purpose: Free off all module globals. * Arguments: void * Return Value: void * Remarks/Portability/Dependencies/Restrictions: * To be used at program exit. * Revision History: * 06-19-96 created - FM */ static void free_HTAAGlobals(void) { HTAAServer *server; int n, i; if (server_table != NULL) { n = HTList_count(server_table); for (i = (n - 1); i >= 0; i--) { if ((server = (HTAAServer *) HTList_objectAt(server_table, i)) != NULL) { HTAAServer_delete(server); server = NULL; } } HTList_delete(server_table); server_table = NULL; } HTAAForwardAuth_reset(); FREE(HTAA_composeAuthResult); FREE(current_hostname); FREE(current_docname); FREE(proxy_hostname); FREE(proxy_docname); FREE(compose_auth_stringResult); FREE(secret_key); } /* BROWSER PUBLIC HTAA_composeAuth() * * SELECT THE AUTHENTICATION SCHEME AND * COMPOSE THE ENTIRE AUTHORIZATION HEADER LINE * IF WE ALREADY KNOW THAT THE HOST REQUIRES AUTHENTICATION * * ON ENTRY: * hostname is the hostname of the server. * portnumber is the portnumber in which the server runs. * docname is the pathname of the document (as in URL) * IsProxy should be TRUE if this is a proxy. * * ON EXIT: * returns NULL, if no authorization seems to be needed, or * if it is the entire Authorization: line, e.g. * * "Authorization: Basic username:password" * * As usual, this string is automatically freed. */ char *HTAA_composeAuth(const char *hostname, const int portnumber, const char *docname, int IsProxy) { char *auth_string; BOOL retry; HTAAScheme scheme; size_t len; /* * Setup atexit() freeing if not done already. - FM */ if (!free_HTAAGlobalsSet) { #ifdef LY_FIND_LEAKS atexit(free_HTAAGlobals); #endif free_HTAAGlobalsSet = TRUE; } /* * Make gateway httpds pass authorization field as it was received. (This * still doesn't really work because Authenticate: headers from remote * server are not forwarded to client yet so it cannot really know that it * should send authorization; I will not implement it yet because I feel we * will soon change radically the way requests are represented to allow * multithreading on server-side. Life is hard.) */ if (HTAAForwardAuth) { CTRACE((tfp, "HTAA_composeAuth: %s\n", "Forwarding received authorization")); StrAllocCopy(HTAA_composeAuthResult, HTAAForwardAuth); HTAAForwardAuth_reset(); /* Just a precaution */ return HTAA_composeAuthResult; } FREE(HTAA_composeAuthResult); /* From previous call */ if (IsProxy) { /* * Proxy Authorization required. - AJL */ CTRACE((tfp, "Composing Proxy Authorization for %s:%d/%s\n", hostname, portnumber, docname)); if (proxy_portnumber != portnumber || !proxy_hostname || !proxy_docname || !hostname || !docname || 0 != strcmp(proxy_hostname, hostname) || 0 != strcmp(proxy_docname, docname)) { retry = NO; proxy_portnumber = portnumber; if (hostname) StrAllocCopy(proxy_hostname, hostname); else FREE(proxy_hostname); if (docname) StrAllocCopy(proxy_docname, docname); else FREE(proxy_docname); } else { retry = YES; } if (!proxy_setup || !retry) proxy_setup = HTAASetup_lookup(hostname, portnumber, docname, IsProxy); if (!proxy_setup) return NULL; switch (scheme = HTAA_selectScheme(proxy_setup)) { case HTAA_BASIC: case HTAA_PUBKEY: auth_string = compose_auth_string(hostname, scheme, proxy_setup, IsProxy); break; case HTAA_KERBEROS_V4: /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */ default: { char *msg = NULL; HTSprintf0(&msg, "%s `%s'", gettext("This client doesn't know how to compose proxy authorization information for scheme"), HTAAScheme_name(scheme)); HTAlert(msg); FREE(msg); auth_string = NULL; } } /* switch scheme */ proxy_setup->retry = NO; if (!auth_string) /* * Signal a failure. - FM */ return NULL; /* Added by marca. */ if (*auth_string == '\0') { /* * Signal an abort. - FM */ StrAllocCopy(HTAA_composeAuthResult, ""); return (HTAA_composeAuthResult); } len = strlen(auth_string) + strlen(HTAAScheme_name(scheme)) + 26; if ((HTAA_composeAuthResult = typecallocn(char, len)) == 0) outofmem(__FILE__, "HTAA_composeAuth"); strcpy(HTAA_composeAuthResult, "Proxy-Authorization: "); } else { /* * Normal WWW authorization. */ CTRACE((tfp, "Composing Authorization for %s:%d/%s\n", hostname, portnumber, docname)); if (current_portnumber != portnumber || !current_hostname || !current_docname || !hostname || !docname || 0 != strcmp(current_hostname, hostname) || 0 != strcmp(current_docname, docname)) { retry = NO; current_portnumber = portnumber; if (hostname) StrAllocCopy(current_hostname, hostname); else FREE(current_hostname); if (docname) StrAllocCopy(current_docname, docname); else FREE(current_docname); } else { retry = YES; } if (!current_setup || !retry) current_setup = HTAASetup_lookup(hostname, portnumber, docname, IsProxy); if (!current_setup) return NULL; switch (scheme = HTAA_selectScheme(current_setup)) { case HTAA_BASIC: case HTAA_PUBKEY: auth_string = compose_auth_string(hostname, scheme, current_setup, IsProxy); break; case HTAA_KERBEROS_V4: /* OTHER AUTHENTICATION ROUTINES ARE CALLED HERE */ default: { char *msg = 0; HTSprintf0(&msg, "%s `%s'", gettext("This client doesn't know how to compose authorization information for scheme"), HTAAScheme_name(scheme)); HTAlert(msg); FREE(msg); auth_string = NULL; } } /* switch scheme */ current_setup->retry = NO; if (!auth_string) /* * Signal a failure. - FM */ return NULL; /* Added by marca. */ if (*auth_string == '\0') { /* * Signal an abort. - FM */ StrAllocCopy(HTAA_composeAuthResult, ""); return (HTAA_composeAuthResult); } len = strlen(auth_string) + strlen(HTAAScheme_name(scheme)) + 20; if ((HTAA_composeAuthResult = typecallocn(char, len)) == 0) outofmem(__FILE__, "HTAA_composeAuth"); strcpy(HTAA_composeAuthResult, "Authorization: "); } strcat(HTAA_composeAuthResult, HTAAScheme_name(scheme)); strcat(HTAA_composeAuthResult, " "); strcat(HTAA_composeAuthResult, auth_string); return HTAA_composeAuthResult; } /* BROWSER PUBLIC HTAA_shouldRetryWithAuth() * * DETERMINES IF WE SHOULD RETRY THE SERVER * WITH AUTHORIZATION * (OR IF ALREADY RETRIED, WITH A DIFFERENT * USERNAME AND/OR PASSWORD (IF MISSPELLED)) * ON ENTRY: * start_of_headers is the first block already read from socket, * but status line skipped; i.e., points to the * start of the header section. * length is the remaining length of the first block. * soc is the socket to read the rest of server reply. * IsProxy should be TRUE if this is a proxy. * * This function should only be called when * server has replied with a 401 (Unauthorized) * status code. * ON EXIT: * returns YES, if connection should be retried. * The node containing all the necessary * information is * * either constructed if it does not exist * * or password is reset to NULL to indicate * that username and password should be * reprompted when composing Authorization: * field (in function HTAA_composeAuth()). * NO, otherwise. */ BOOL HTAA_shouldRetryWithAuth(char *start_of_headers, size_t length, int soc, int IsProxy) { HTAAScheme scheme; char *line = NULL; int num_schemes = 0; HTList *valid_schemes = HTList_new(); HTAssocList **scheme_specifics = NULL; char *ctemplate = NULL; char *temp = NULL; BOOL result = NO; /* * Setup atexit() freeing if not done already. - FM */ if (!free_HTAAGlobalsSet) { #ifdef LY_FIND_LEAKS atexit(free_HTAAGlobals); #endif free_HTAAGlobalsSet = TRUE; } /* * Read server reply header lines */ CTRACE((tfp, "Server reply header lines:\n")); HTAA_setupReader(start_of_headers, length, soc); while (NULL != (line = HTAA_getUnfoldedLine()) && *line != '\0') { CTRACE((tfp, "%s\n", line)); if (StrChr(line, ':')) { /* Valid header line */ char *p = line; char *fieldname = HTNextField(&p); char *arg1 = HTNextField(&p); char *args = p; if ((IsProxy && 0 == strcasecomp(fieldname, "Proxy-Authenticate:")) || (!IsProxy && 0 == strcasecomp(fieldname, "WWW-Authenticate:"))) { if (isEmpty(arg1) || isEmpty(args)) { HTSprintf0(&temp, gettext("Invalid header '%s%s%s%s%s'"), line, (non_empty(arg1) ? " " : ""), NonNull(arg1), (non_empty(args) ? " " : ""), NonNull(args)); HTAlert(temp); FREE(temp); } else if (HTAA_UNKNOWN != (scheme = HTAAScheme_enum(arg1))) { HTList_addObject(valid_schemes, (void *) scheme); if (!scheme_specifics) { int i; scheme_specifics = typecallocn(HTAssocList *, HTAA_MAX_SCHEMES); if (!scheme_specifics) outofmem(__FILE__, "HTAA_shouldRetryWithAuth"); for (i = 0; i < HTAA_MAX_SCHEMES; i++) scheme_specifics[i] = NULL; } scheme_specifics[scheme] = HTAA_parseArgList(args); num_schemes++; } else { CTRACE((tfp, "Unknown scheme `%s' %s\n", NONNULL(arg1), (IsProxy ? "in Proxy-Authenticate: field" : "in WWW-Authenticate: field"))); } } else if (!IsProxy && 0 == strcasecomp(fieldname, "WWW-Protection-Template:")) { CTRACE((tfp, "Protection template set to `%s'\n", arg1)); StrAllocCopy(ctemplate, arg1); } } else { CTRACE((tfp, "Invalid header line `%s' ignored\n", line)); } FREE(line); } /* while header lines remain */ FREE(line); /* * So should we retry with authorization? */ if (IsProxy) { if (num_schemes == 0) { /* * No proxy authorization valid */ proxy_setup = NULL; result = NO; } /* * Doing it for proxy. -AJL */ else if (proxy_setup && proxy_setup->server) { /* * We have already tried with proxy authorization. Either we don't * have access or username or password was misspelled. * * Update scheme-specific parameters (in case they have expired by * chance). */ HTAASetup_updateSpecifics(proxy_setup, scheme_specifics); if (NO == HTConfirm(AUTH_FAILED_PROMPT)) { proxy_setup = NULL; result = NO; } else { /* * Re-ask username+password (if misspelled). */ HTList_delete(valid_schemes); proxy_setup->retry = YES; result = YES; } } else { /* * proxy_setup == NULL, i.e., we have a first connection to a * protected server or the server serves a wider set of documents * than we expected so far. */ HTAAServer *server = HTAAServer_lookup(proxy_hostname, proxy_portnumber, IsProxy); if (!server) { server = HTAAServer_new(proxy_hostname, proxy_portnumber, IsProxy); } if (!ctemplate) /* Proxy matches everything -AJL */ StrAllocCopy(ctemplate, "*"); proxy_setup = HTAASetup_new(server, ctemplate, valid_schemes, scheme_specifics); FREE(ctemplate); HTAlert(gettext("Proxy authorization required -- retrying")); result = YES; } } /* * Normal WWW authorization. */ else if (num_schemes == 0) { /* * No authorization valid. */ current_setup = NULL; result = NO; } else if (current_setup && current_setup->server) { /* * So we have already tried with WWW authorization. Either we don't * have access or username or password was misspelled. * * Update scheme-specific parameters (in case they have expired by * chance). */ HTAASetup_updateSpecifics(current_setup, scheme_specifics); if (NO == HTConfirm(AUTH_FAILED_PROMPT)) { current_setup = NULL; result = NO; } else { /* * Re-ask username+password (if misspelled). */ current_setup->retry = YES; result = YES; } } else { /* * current_setup == NULL, i.e., we have a first connection to a * protected server or the server serves a wider set of documents than * we expected so far. */ HTAAServer *server = HTAAServer_lookup(current_hostname, current_portnumber, IsProxy); if (!server) { server = HTAAServer_new(current_hostname, current_portnumber, IsProxy); } if (!ctemplate) ctemplate = HTAA_makeProtectionTemplate(current_docname); current_setup = HTAASetup_new(server, ctemplate, valid_schemes, scheme_specifics); FREE(ctemplate); HTAlert(gettext("Access without authorization denied -- retrying")); result = YES; } if (result == NO) { HTList_delete(valid_schemes); } return result; } /* * This function clears all authorization information by * invoking the free_HTAAGlobals() function, which normally * is invoked at exit. It allows a browser command to do * this at any time, for example, if the user is leaving * the terminal for a period of time, but does not want * to end the current session. - FM */ void HTClearHTTPAuthInfo(void) { /* * Need code to check cached documents against the protection templates, * and do something to ensure that any protected documents no longer can be * accessed without a new retrieval. - FM */ /* * Now free all of the authorization info, and reset the * free_HTAAGlobalsSet flag. - FM */ free_HTAAGlobals(); free_HTAAGlobalsSet = FALSE; }