From 605b57a1ea0e8b4aa459385042fc128facae6cde Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Thu, 18 Feb 2016 09:17:25 -0800 Subject: [PATCH] sorted(), so dirs and docs are processed stably use sorted() on the sourcedirs and the contents of each directory so that the directories are always handled in order and the documents are also handled in order adjust logging also to refer to "Source collection dir" rather than just "dir" --- tldp/sources.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tldp/sources.py b/tldp/sources.py index d827958..83ce0e9 100644 --- a/tldp/sources.py +++ b/tldp/sources.py @@ -23,11 +23,12 @@ class SourceCollection(collections.MutableMapping): if not all(results): for result, sdir in zip(results, dirs): - logger.critical("Directory does not exist: " + sdir) + logger.critical("Source collection dir must already exist: %s", + sdir) raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), sdir) - for sdir in dirs: - for fname in os.listdir(sdir): + for sdir in sorted(dirs): + for fname in sorted(os.listdir(sdir)): candidates = list() possible = os.path.join(sdir, fname) if os.path.isfile(possible):