summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2010-02-07 15:05:56 +0100
committerLaurent Bachelier <laurent@bachelier.name>2010-02-07 15:05:56 +0100
commit8397fcb503d184455b7c55a68592622b819f8963 (patch)
tree346fcb0df26df2a54a55cad32d2b067e1c25df7e
parentFixes indentation (diff)
downloadmpdat-8397fcb503d184455b7c55a68592622b819f8963.tar.xz
No need for a class
-rwxr-xr-xmpdrast/client.py7
-rw-r--r--mpdrast/process.py49
2 files changed, 26 insertions, 30 deletions
diff --git a/mpdrast/client.py b/mpdrast/client.py
index e23a8e3..1e352c6 100755
--- a/mpdrast/client.py
+++ b/mpdrast/client.py
@@ -3,7 +3,7 @@ import mpd
import time
import random
-from process import MPDrastProcess
+import process
class MPDrastClient(mpd.MPDClient):
def __init__(self):
@@ -30,7 +30,7 @@ class MPDrastClient(mpd.MPDClient):
if first and not items:
raise Exception("database is empty")
- files, dirs = MPDrastProcess.get_files_and_dirs_from_db(items)
+ files, dirs = process.get_files_and_dirs_from_db(items)
if len(files) and len(dirs) == 0:
self.final_dirs.append(path)
else:
@@ -45,7 +45,6 @@ class MPDrastClient(mpd.MPDClient):
def get_random_dir(self):
return random.choice(self.final_dirs)
- # Om Nom Nom Nom
def is_playlist_hungry(self, hungriness=100):
return int(self.status()["playlistlength"]) < hungriness
@@ -53,7 +52,7 @@ class MPDrastClient(mpd.MPDClient):
return int(self.status()["playlistlength"]) == 0
def _find_changing_pos(self, number, type):
- pl = (MPDrastProcess.process_song(item) for item in self.playlistinfo())
+ pl = (process.process_song(item) for item in self.playlistinfo())
value = None
count = -1
for song in pl:
diff --git a/mpdrast/process.py b/mpdrast/process.py
index fabcd58..c546270 100644
--- a/mpdrast/process.py
+++ b/mpdrast/process.py
@@ -1,34 +1,31 @@
import posixpath
-class MPDrastProcess:
+"""
+Process MPDrastClient responses
+"""
+
+def get_files_and_dirs_from_db(items):
"""
- Process MPDrastClient responses
+ Returns (files, directories) from a source with files and directories mixed.
"""
+ files = []
+ dirs = []
+ for item in items:
+ if item.has_key("directory"):
+ dirs.append(item["directory"])
+ elif item.has_key("file"):
+ files.append(item["file"])
- @staticmethod
- def get_files_and_dirs_from_db(items):
- """
- Returns (files, directories) from a source with files and directories mixed.
- """
- files = []
- dirs = []
- for item in items:
- if item.has_key("directory"):
- dirs.append(item["directory"])
- elif item.has_key("file"):
- files.append(item["file"])
-
- return (files, dirs)
+ return (files, dirs)
- @staticmethod
- def process_song(item):
- """
- Adds a "dir" attribute to songs, change "pos" to int
- """
- if item.has_key("file"):
- item["dir"] = posixpath.dirname(item["file"])
+def process_song(item):
+ """
+ Adds a "dir" attribute to songs, change "pos" to int
+ """
+ if item.has_key("file"):
+ item["dir"] = posixpath.dirname(item["file"])
- if item.has_key("pos"):
- item["pos"] = int(item["pos"])
+ if item.has_key("pos"):
+ item["pos"] = int(item["pos"])
- return item
+ return item