Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/distlib/_backport/misc.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 # | |
3 # Copyright (C) 2012 The Python Software Foundation. | |
4 # See LICENSE.txt and CONTRIBUTORS.txt. | |
5 # | |
6 """Backports for individual classes and functions.""" | |
7 | |
8 import os | |
9 import sys | |
10 | |
11 __all__ = ['cache_from_source', 'callable', 'fsencode'] | |
12 | |
13 | |
14 try: | |
15 from imp import cache_from_source | |
16 except ImportError: | |
17 def cache_from_source(py_file, debug=__debug__): | |
18 ext = debug and 'c' or 'o' | |
19 return py_file + ext | |
20 | |
21 | |
22 try: | |
23 callable = callable | |
24 except NameError: | |
25 from collections import Callable | |
26 | |
27 def callable(obj): | |
28 return isinstance(obj, Callable) | |
29 | |
30 | |
31 try: | |
32 fsencode = os.fsencode | |
33 except AttributeError: | |
34 def fsencode(filename): | |
35 if isinstance(filename, bytes): | |
36 return filename | |
37 elif isinstance(filename, str): | |
38 return filename.encode(sys.getfilesystemencoding()) | |
39 else: | |
40 raise TypeError("expect bytes or str, not %s" % | |
41 type(filename).__name__) |