aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-08-16 19:06:12 +0200
committerMichał Górny <mgorny@gentoo.org>2018-08-16 22:05:10 +0200
commita0d10b164038c4ef172039f5d281240c48d3611f (patch)
tree3df174aad95724ee6ba0e5792ae6571009340cc6 /repoman
parentbin/ebuild: fix --debug to work during manifest generation (diff)
downloadportage-a0d10b164038c4ef172039f5d281240c48d3611f.tar.gz
portage-a0d10b164038c4ef172039f5d281240c48d3611f.tar.bz2
portage-a0d10b164038c4ef172039f5d281240c48d3611f.zip
repoman.config: Make yaml loader optional
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. Reviewed-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'repoman')
-rw-r--r--repoman/lib/repoman/config.py8
1 files changed, 7 insertions, 1 deletions
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)