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