Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 88.89% |
Changes | 0 |
1 | #!/usr/bin/env python3 |
||
2 | 4 | """This module is used for backwards compatibility for older Python 3.""" |
|
3 | |||
4 | 5 | __author__ = "Thurask" |
|
5 | 5 | __license__ = "WTFPL v2" |
|
6 | 5 | __copyright__ = "2015-2018 Thurask" |
|
7 | |||
8 | |||
9 | 5 | def enum_cpus(): |
|
10 | """ |
||
11 | Backwards compatibility wrapper for CPU count. |
||
12 | """ |
||
13 | 5 | try: |
|
14 | 5 | from os import cpu_count |
|
15 | 1 | except ImportError: |
|
16 | 1 | from multiprocessing import cpu_count |
|
17 | finally: |
||
18 | 5 | cpus = cpu_count() |
|
19 | 5 | return cpus |
|
20 | |||
21 | |||
22 | 5 | def where_which(path): |
|
23 | """ |
||
24 | Backwards compatibility wrapper for approximating which/where. |
||
25 | |||
26 | :param path: Path to a file. |
||
27 | :type path: str |
||
28 | """ |
||
29 | 5 | try: |
|
30 | 5 | from shutil import which |
|
31 | except ImportError: |
||
32 | from shutilwhich import which |
||
33 | finally: |
||
34 | 5 | thepath = which(path) |
|
35 | return thepath |
||
36 |