OLD | NEW |
1 # Copyright 2014 Altera Corporation. All Rights Reserved. | 1 # Copyright 2014 Altera Corporation. All Rights Reserved. |
2 # Author: John McGehee | 2 # Author: John McGehee |
3 # | 3 # |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
7 # | 7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # | 9 # |
10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 >>> os #doctest: +ELLIPSIS | 23 >>> os #doctest: +ELLIPSIS |
24 <fake_filesystem.FakeOsModule object...> | 24 <fake_filesystem.FakeOsModule object...> |
25 >>> os.path #doctest: +ELLIPSIS | 25 >>> os.path #doctest: +ELLIPSIS |
26 <fake_filesystem.FakePathModule object...> | 26 <fake_filesystem.FakePathModule object...> |
27 >>> glob #doctest: +ELLIPSIS | 27 >>> glob #doctest: +ELLIPSIS |
28 <fake_filesystem_glob.FakeGlobModule object...> | 28 <fake_filesystem_glob.FakeGlobModule object...> |
29 >>> shutil #doctest: +ELLIPSIS | 29 >>> shutil #doctest: +ELLIPSIS |
30 <fake_filesystem_shutil.FakeShutilModule object...> | 30 <fake_filesystem_shutil.FakeShutilModule object...> |
31 | 31 |
32 The `file()` and `open()` built-ins are bound to the fake `open()`: | 32 The `open()` built-in is bound to the fake `open()`: |
33 | 33 |
34 >>> file #doctest: +ELLIPSIS | |
35 <fake_filesystem.FakeFileOpen object...> | |
36 >>> open #doctest: +ELLIPSIS | 34 >>> open #doctest: +ELLIPSIS |
37 <fake_filesystem.FakeFileOpen object...> | 35 <fake_filesystem.FakeFileOpen object...> |
| 36 |
| 37 In Python 2 the `file()` built-in is also bound to the fake `open()`. `file()` |
| 38 was eliminated in Python 3. |
38 """ | 39 """ |
39 | 40 |
40 import os | 41 import os |
41 import glob | 42 import glob |
42 import shutil | 43 import shutil |
43 | 44 |
44 def create_file(path): | 45 def create_file(path): |
45 '''Create the specified file and add some content to it. Use the `open()` | 46 '''Create the specified file and add some content to it. Use the `open()` |
46 built in function. | 47 built in function. |
47 | 48 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 >>> create_file('/test/file1.txt') | 112 >>> create_file('/test/file1.txt') |
112 >>> create_file('/test/file2.txt') | 113 >>> create_file('/test/file2.txt') |
113 >>> get_glob('/test/file*.txt') | 114 >>> get_glob('/test/file*.txt') |
114 ['/test/file1.txt', '/test/file2.txt'] | 115 ['/test/file1.txt', '/test/file2.txt'] |
115 ''' | 116 ''' |
116 return glob.glob(glob_path) | 117 return glob.glob(glob_path) |
117 | 118 |
118 def rm_tree(path): | 119 def rm_tree(path): |
119 '''Delete the specified file hierarchy.''' | 120 '''Delete the specified file hierarchy.''' |
120 shutil.rmtree(path) | 121 shutil.rmtree(path) |
OLD | NEW |