Richard Lawrence committed 3907ef5

* schoolutils/grading/ BUGFIX: file_path: check for empty string

Comments (0)

Files changed (1)


     def initial_database_setup(self):
         "Set db_file and db_connection from user config and CLI options"
         self.db_file = self.get_config_option('gradedb_file', file_path)
         if self.db_file and os.path.exists(self.db_file):
             self.db_connection = sqlite3.connect(self.db_file)
     """Convert a string to a file path.
        The passed string may contain '~' and will be expanded to an absolute
-    return os.path.abspath(os.path.expanduser(s))
+    fp = s.strip()
+    if not fp:
+        raise ValueError("File path may not be empty")
+    return os.path.abspath(os.path.expanduser(fp))
 def yn_bool(s):
     """Convert a yes/no string to a boolean.