Show More
@@ -1,23 +1,23 b'' | |||
|
1 | 1 | """Utilities for working with Python source files. |
|
2 | 2 | |
|
3 | 3 | Exposes various functions from recent Python standard libraries, along with |
|
4 | 4 | equivalents for older Python versions. |
|
5 | 5 | """ |
|
6 | 6 | import os.path |
|
7 | 7 | |
|
8 | 8 | try: # Python 3.2 |
|
9 | 9 | from imp import source_from_cache, cache_from_source |
|
10 | 10 | except ImportError: |
|
11 | 11 | # Python <= 3.1: .pyc files go next to .py |
|
12 | 12 | def source_from_cache(path): |
|
13 | 13 | basename, ext = os.path.splitext(path) |
|
14 |
if ext not in |
|
|
14 | if ext not in ('.pyc', '.pyo'): | |
|
15 | 15 | raise ValueError('Not a cached Python file extension', ext) |
|
16 | 16 | # Should we look for .pyw files? |
|
17 | 17 | return basename + '.py' |
|
18 | 18 | |
|
19 | 19 | def cache_from_source(path, debug_override=None): |
|
20 | 20 | if debug_override is None: |
|
21 | 21 | debug_override = __debug__ |
|
22 | 22 | basename, ext = os.path.splitext(path) |
|
23 | 23 | return basename + '.pyc' if debug_override else '.pyo' |
General Comments 0
You need to be logged in to leave comments.
Login now