On 08/16/2018 10:47 AM, Michał Górny wrote: > Make the yaml loader optional, delaying the failure until the user > attempts to actually load a yaml file. Given that pyyaml is an external > dependency, there is no real reason to fail as soon as repoman.config is > loaded if YAML may not be used at all. > --- > repoman/lib/repoman/config.py | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/repoman/lib/repoman/config.py b/repoman/lib/repoman/config.py > index 578bbccde..decf9b90a 100644 > --- a/repoman/lib/repoman/config.py > +++ b/repoman/lib/repoman/config.py > @@ -6,7 +6,10 @@ import json > import os > import stat > > -import yaml > +try: > + import yaml > +except ImportError: > + yaml = None > > try: > FileNotFoundError > @@ -73,6 +76,9 @@ def _yaml_load(filename): > Load filename as YAML and return a dict. Raise ConfigError if > it fails to load. > """ > + if yaml is None: > + raise ImportError('Please install pyyaml in order to read yaml > files') > + > with open(filename, 'rt') as f: > try: > return yaml.safe_load(f) >
Looks good, please merge. -- Thanks, Zac
signature.asc
Description: OpenPGP digital signature