Implemented better "valid files not found" behavior.

Used an exception so show error state.
Used a bool flag to make sure the error is only shown once PER error.
Updated tests to check for the correct Exception raised
This commit is contained in:
tBunnyMan 2012-08-23 12:44:22 -07:00
commit a37ba369ef
3 changed files with 14 additions and 5 deletions

View file

@ -14,6 +14,9 @@ from operator import attrgetter
logger = logging.getLogger(__name__)
class NoFilesError(Exception):
pass
def get_date(string):
"""Return a datetime object from a string.
@ -247,8 +250,7 @@ def files_changed(path, extensions):
LAST_MTIME = mtime
return True
except ValueError:
logger.info("No files found in path")
return False
raise NoFilesError("No files with the given extension(s) found.")
return False