Conditions | 3 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3.0987 |
1 | 1 | from plugin.core.libraries.helpers.storage import StorageHelper |
|
11 | 1 | @classmethod |
|
12 | def insert(cls, base, system, architecture, *args): |
||
13 | """Insert a new path into `sys.path` if it passes basic validation |
||
14 | |||
15 | :type base: str |
||
16 | :type system: str |
||
17 | :type architecture: str |
||
18 | """ |
||
19 | |||
20 | 1 | path = os.path.join(base, system, architecture, *args) |
|
21 | |||
22 | 1 | if path in sys.path: |
|
23 | return False |
||
24 | |||
25 | 1 | if not os.path.exists(path): |
|
26 | return False |
||
27 | |||
28 | 1 | sys.path.insert(0, path) |
|
29 | |||
30 | 1 | log.debug('Inserted path: %r', StorageHelper.to_relative_path(path)) |
|
31 | 1 | return True |
|
32 | |||
47 |