Add "or '.'" after dirname() calls in hooke.command_stack and .playlist.
authorW. Trevor King <wking@drexel.edu>
Sun, 15 Aug 2010 11:48:46 +0000 (07:48 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 15 Aug 2010 11:48:46 +0000 (07:48 -0400)
Because
  >>> import os.path
  >>> os.path.dirname('some-file')
  ''
  >>> os.path.dirname('some-file') or '.'
  '.'
and
  >>> import os
  >>> os.makedirs('')
  Traceback (most recent call last):
    ...
  OSError: [Errno 2] No such file or directory: ''

hooke/command_stack.py
hooke/playlist.py

index 9b2dcd7ca9eae50d0bbeaac25db1e064393555a3..c1164732f687ebad51374afb0be99d97fbaa6836 100644 (file)
@@ -154,7 +154,7 @@ class FileCommandStack (CommandStack):
         """Saves the command stack to `path`.
         """
         self.set_path(path)
-        dirname = os.path.dirname(self.path)
+        dirname = os.path.dirname(self.path) or '.'
         if makedirs == True and not os.path.isdir(dirname):
             os.makedirs(dirname)
         with open(self.path, 'w') as f:
index 352617ce90120c7c2afd6698300d61293535096d..ee586095e4a5795144f9fe1ec886ae23b939bda8 100644 (file)
@@ -370,7 +370,7 @@ class FilePlaylist (Playlist):
         """Saves the playlist in a XML file.
         """
         self.set_path(path)
-        dirname = os.path.dirname(self.path)
+        dirname = os.path.dirname(self.path) or '.'
         if makedirs == True and not os.path.isdir(dirname):
             os.makedirs(dirname)
         with open(self.path, 'w') as f: