[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [oonib/master] clearer check_paths()



commit 562649ffe895025bc579314b4f19a8f31c944464
Author: Darius Bacon <darius@xxxxxx>
Date:   Tue Apr 15 16:11:03 2014 -0700

    clearer check_paths()
---
 oonib/config.py |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/oonib/config.py b/oonib/config.py
index 956fcc1..6fea660 100644
--- a/oonib/config.py
+++ b/oonib/config.py
@@ -39,15 +39,13 @@ class Config(object):
         self.check_paths()
     
     def check_paths(self):
-        if not self.main.report_dir or not os.path.isdir(self.main.report_dir):
-            raise e.InvalidReportDirectory(self.main.report_dir)
-        if not self.main.archive_dir or not os.path.isdir(self.main.archive_dir):
-            raise e.InvalidArchiveDirectory(self.main.archive_dir)
-
-        if self.main.input_dir and not os.path.isdir(self.main.input_dir):
-            raise e.InvalidInputDirectory(self.main.input_dir)
-        if self.main.deck_dir and not os.path.isdir(self.main.deck_dir):
-            raise e.InvalidDeckDirectory(self.main.deck_dir)
+        def check_path(directory, complaint):
+            if not (directory and os.path.isdir(directory)):
+                raise complaint(directory)
+        check_path(self.main.report_dir,  e.InvalidReportDirectory)
+        check_path(self.main.archive_dir, e.InvalidArchiveDirectory)
+        check_path(self.main.input_dir,   e.InvalidInputDirectory)
+        check_path(self.main.deck_dir,    e.InvalidDeckDirectory)
 
 backend_version = __version__
 reports = {}



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits