1 |
Make the yaml loader optional, delaying the failure until the user |
2 |
attempts to actually load a yaml file. Given that pyyaml is an external |
3 |
dependency, there is no real reason to fail as soon as repoman.config is |
4 |
loaded if YAML may not be used at all. |
5 |
--- |
6 |
repoman/lib/repoman/config.py | 8 +++++++- |
7 |
1 file changed, 7 insertions(+), 1 deletion(-) |
8 |
|
9 |
diff --git a/repoman/lib/repoman/config.py b/repoman/lib/repoman/config.py |
10 |
index 578bbccde..decf9b90a 100644 |
11 |
--- a/repoman/lib/repoman/config.py |
12 |
+++ b/repoman/lib/repoman/config.py |
13 |
@@ -6,7 +6,10 @@ import json |
14 |
import os |
15 |
import stat |
16 |
|
17 |
-import yaml |
18 |
+try: |
19 |
+ import yaml |
20 |
+except ImportError: |
21 |
+ yaml = None |
22 |
|
23 |
try: |
24 |
FileNotFoundError |
25 |
@@ -73,6 +76,9 @@ def _yaml_load(filename): |
26 |
Load filename as YAML and return a dict. Raise ConfigError if |
27 |
it fails to load. |
28 |
""" |
29 |
+ if yaml is None: |
30 |
+ raise ImportError('Please install pyyaml in order to read yaml files') |
31 |
+ |
32 |
with open(filename, 'rt') as f: |
33 |
try: |
34 |
return yaml.safe_load(f) |
35 |
-- |
36 |
2.18.0 |