Skip to content

Commit

Permalink
pyDKB/*/consumer: make FileConsumer._filenames_form_dir() generator.
Browse files Browse the repository at this point in the history
Not a big deal, but most of FileConsumer methods, related to input
files, are generators -- so why not. Now instead of checking all files
in the directory and creating a list of those with proper extension, it
yields first file name that fits requirements, and checks next file only
when asked about it.
  • Loading branch information
mgolosova committed Jul 11, 2018
1 parent 0074e5d commit 9155d2f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def _filenames_from_dir(self, dirname):
if os.path.isfile(os.path.join(dirname, f)) \
and f.lower().endswith(ext):
files.append(f)
yield f
except OSError, err:
raise Consumer.ConsumerException(err)
return files

def _adjusted_filenames(self):
""" Return iterable object, yielding filename and path to file. """
Expand Down

0 comments on commit 9155d2f

Please sign in to comment.