$OpenBSD: patch-directory_py,v 1.1.1.1 2011/07/20 07:54:58 dcoppa Exp $

Fall back gracefully when 'followlinks' arg is not supported
(upstream git commit e9e8033274102d34541f54d530b8e4dd5096b23e)

--- directory.py.orig	Tue Sep 21 08:13:42 2010
+++ directory.py	Mon Jul 11 10:58:20 2011
@@ -169,7 +169,14 @@ class DirectoryBackend(LibraryBackend):
             raise IOError("Error: directory %r doesn't exist." % (self._media_path,))
         print "Scanning for music in %r..." % (os.path.abspath(self._media_path),)
         # Iterate over all the files.
-        for path, dirs, files in os.walk(self._media_path, followlinks=True):
+        try:
+            all_files_recursively = os.walk(self._media_path, followlinks=True)
+        except TypeError:
+            # os.walk in Python 2.5 and earlier don't support the followlinks
+            # argument. Fall back to not including it (in this case, Zeya will
+            # not index music underneath symlinked directories).
+            all_files_recursively = os.walk(self._media_path)
+        for path, dirs, files in all_files_recursively:
             # Sort dirs so that subdirectories will subsequently be visited
             # alphabetically (see os.walk).
             dirs.sort(key=tokenize_filename)
