0
|
1 Test fetch
|
22
|
2 ==========
|
0
|
3
|
21
|
4 The obligatory imports::
|
0
|
5
|
|
6 >>> import fetch
|
22
|
7 >>> import os
|
|
8 >>> import shutil
|
|
9 >>> import tempfile
|
|
10
|
|
11 Create a staging directory::
|
|
12
|
|
13 >>> stage = tempfile.mkdtemp()
|
0
|
14
|
21
|
15 Create a Fetch object::
|
0
|
16
|
22
|
17 >>> f = fetch.Fetch(relative_to=stage, strict=True)
|
|
18
|
|
19 Call Fetch directly::
|
0
|
20
|
22
|
21 >>> def url(*args):
|
|
22 ... return 'file://' + os.path.join(*([here] + list(args)))
|
|
23 >>> f(url=url('sample1.txt'), destination=stage, type='file')
|
|
24 >>> file(os.path.join(stage, 'sample1.txt')).read().strip()
|
|
25 'sample1'
|
|
26
|
|
27 Cleanup::
|
|
28
|
|
29 >>> shutil.rmtree(stage)
|