Skip to content

Commit

Permalink
Python<3.5 compatibility. Fix #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryneeverett committed Dec 28, 2015
1 parent b7655ff commit ea51600
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mkcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ea51600

Please sign in to comment.