From ab60700e46e2eab0663ad5ff52337b198ce081e9 Mon Sep 17 00:00:00 2001 From: Davide Laezza Date: Mon, 22 Apr 2019 18:05:22 +0200 Subject: [PATCH] Reporting unsupported recursive globs in import_configs --- dotdrop/config.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dotdrop/config.py b/dotdrop/config.py index 5f03db4..4791c8c 100644 --- a/dotdrop/config.py +++ b/dotdrop/config.py @@ -9,6 +9,7 @@ import inspect import itertools import os import shlex +from functools import partial from glob import iglob import yaml @@ -267,11 +268,29 @@ class Cfg: except KeyError: pass - # parse external profiles + # parse external configs try: ext_configs = self.lnk_settings[self.key_import_configs] or () + + try: + iglob('./*', recursive=True) + find_glob = partial(iglob, recursive=True) + except TypeError: + from platform import python_version + + msg = ('Recursive globbing is not available on Python {}: ' + .format(python_version())) + if any('**' in config for config in ext_configs): + msg += "import_configs won't work" + self.log.err(msg) + return False + + msg = 'upgrade to version >3.5 if you want to use this feature' + self.log.warn(msg) + find_glob = iglob + ext_configs = itertools.chain.from_iterable( - iglob(self._abs_path(config), recursive=True) + find_glob(self._abs_path(config)) for config in ext_configs ) for config in ext_configs: