From ea51600bada39045bd301aaae5ab0960dc070806 Mon Sep 17 00:00:00 2001 From: ryneeverett Date: Mon, 28 Dec 2015 15:23:25 -0500 Subject: [PATCH] Python<3.5 compatibility. Fix #1. --- mkcodes.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mkcodes.py b/mkcodes.py index d0d4d6e..eb237af 100644 --- a/mkcodes.py +++ b/mkcodes.py @@ -14,6 +14,14 @@ from markdown.treeprocessors import Treeprocessor +def iglob(input): + try: + return glob.iglob(input + '/**', recursive=True) + except TypeError: + warnings.warn('In python<3.5, inputs are not recursive.') + return glob.iglob(input + '/*') + + def default_state(): return [], True, False @@ -79,8 +87,7 @@ def is_markdown(f): def get_files(inputs): for i in inputs: if os.path.isdir(i): - yield from filter( - is_markdown, glob.iglob(i + '/**', recursive=True)) + yield from filter(is_markdown, iglob(i)) elif is_markdown(i): yield i