mmp

The mini music player, an alternative to MPD

git clone https://git.8pit.net/mmp.git

 1(import [enum [Enum]])
 2
 3;; From src/protocol/Ack.hxx in mpd source
 4(defclass ACKError [Enum]
 5  (setv NOT_LIST 1)
 6  (setv ARG 2)
 7  (setv PASSWORD 3)
 8  (setv PERMISSION 4)
 9  (setv UNKNOWN 5)
10  (setv NO_EXIST 50)
11  (setv PLAYLIST_MAX 51)
12  (setv SYSTEM 52)
13  (setv PLAYLIST_LOAD 53)
14  (setv UPDATE_ALREADY 54)
15  (setv PLAYER_SYNC 55)
16  (setv EXIST 56))
17
18(defclass MPDException [Exception]
19  (defn __init__ [self code msg &optional [lst-num 0] [cur-cmd ""]]
20    (if (not (isinstance code ACKError))
21      (raise (TypeError "Exception code must be an ACKError")))
22    (setv self.code code)
23    (setv self.msg msg)
24    (setv self.lst-num lst-num)
25    (setv self.cur-cmd cur-cmd))
26
27  ;; Format: ACK [error@command_listNum] {current_command} message_text
28  (defn __str__ [self]
29    (% "ACK [%d@%d] {%s} %s" (, self.code.value self.lst-num
30                                self.cur-cmd self.msg))))
31
32(defclass MPDNotFoundError [MPDException]
33  (defn __init__ [self]
34    (.__init__ (super) ACKError.NO_EXIST "no such file")))
35
36(defclass MPDBadIndexError [MPDException]
37  (defn __init__ [self]
38    (.__init__ (super) ACKError.ARG "Bad song index")))