From 580dccba8d997a229e8c02e0fbbc75771a5aa372 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 17 Oct 2016 16:43:48 +0800 Subject: configs/manager.py: Fix the bug that breaks specifications loading The "filter()" returns an iterator, that is consumed after the use, therefore, the "specfiles" is used by the print under "DEBUG_FG21SIM". Then "specfiles" is empty and thus prevents the reading of the specification files. --- fg21sim/configs/manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'fg21sim') diff --git a/fg21sim/configs/manager.py b/fg21sim/configs/manager.py index 5ee4ecf..3206c29 100644 --- a/fg21sim/configs/manager.py +++ b/fg21sim/configs/manager.py @@ -28,7 +28,10 @@ logger = logging.getLogger(__name__) def _get_configspec(): """Found and read all the configuration specifications""" files = sorted(pkg_resources.resource_listdir(__name__, "")) - specfiles = filter(lambda fn: fn.endswith(".conf.spec"), files) + # NOTE: + # Explicit convert the filter results to a list, since the returned + # iterator can ONLY be used ONCE. + specfiles = list(filter(lambda fn: fn.endswith(".conf.spec"), files)) if os.environ.get("DEBUG_FG21SIM"): print("DEBUG: Found config specifications: %s" % ", ".join(specfiles), file=sys.stderr) -- cgit v1.2.2