Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] repoman.config: Make yaml loader optional
Date: Thu, 16 Aug 2018 18:17:45
Message-Id: 03e13a39-9f7a-6dfd-ee0b-61d7ed5227a0@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] repoman.config: Make yaml loader optional by "Michał Górny"
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

Attachments

File name MIME type
signature.asc application/pgp-signature