]> kaliko git repositories - mpd-sima.git/commitdiff
Some clean-up in track object
authorkaliko <efrim@azylum.org>
Fri, 13 Dec 2013 13:08:50 +0000 (14:08 +0100)
committerkaliko <efrim@azylum.org>
Fri, 13 Dec 2013 13:08:50 +0000 (14:08 +0100)
Removed redundant shutdown call in foreground mode

launch
sima/lib/daemon.py
sima/lib/simadb.py
sima/lib/track.py

diff --git a/launch b/launch
index 43fc0bc797dfc2cb84ab9cb38436432bf12a2ec7..c7ff8e69825fbe50e2ede515b18ed7e22e429988 100755 (executable)
--- a/launch
+++ b/launch
@@ -104,7 +104,7 @@ def main():
         sima.foreground()
     except KeyboardInterrupt:
         logger.info('Caught KeyboardInterrupt, stopping')
-        sima.shutdown()
+        sys.exit(0)
 
 
 def run():
index 1feb7e42927fa3aeff8998419086a6e9a5b9a7db..b0b1130172450ac21c0196a4ec05a801f58d4d7e 100644 (file)
 #  it under the terms of the GNU General Public License as published by
 #  the Free Software Foundation, either version 3 of the License, or
 #  (at your option) any later version.
-#  
+#
 #  MPD_sima is distributed in the hope that it will be useful,
 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #  GNU General Public License for more details.
-#  
+#
 #  You should have received a copy of the GNU General Public License
-#  along with MPD_sima.  If not, see <http://www.gnu.org/licenses/>. 
+#  along with MPD_sima.  If not, see <http://www.gnu.org/licenses/>.
 
 import atexit
 import os
index 4db498dad354b870357674c15ff2f6c2888da41c..a3d9518ac5df5534063cb8c11feb6cda0b6d8bc2 100644 (file)
@@ -147,7 +147,7 @@ class SimaDB(object):
         if not in database insert new entry."""
         art = track.artist
         nam = track.title
-        fil = track.get_filename()
+        fil = track.file
         if with_connection:
             connection = with_connection
         else:
index 87c96fc144fac9ca2b6ae0316d8e288fccc52d97..c88de6c1b3b9f511691a073c65553c8e2d2afd40 100644 (file)
@@ -30,17 +30,17 @@ class Track(object):
     Instanciate with Player replies.
     """
 
-    def __init__(self, file=None, time=0, pos=0, **kwargs):
+    def __init__(self, file=None, time=0, pos=-1, **kwargs):
         self.title = self.artist = self.album = self.albumartist = ''
-        self._pos = pos
-        self.empty = False
+        self.pos = pos
+        self._empty = False
         self._file = file
         if not kwargs:
-            self.empty = True
+            self._empty = True
         self.time = time
         self.__dict__.update(**kwargs)
-        self.tags_to_collapse = list(['artist', 'album', 'title', 'date',
-            'genre', 'albumartist'])
+        self.tags_to_collapse = ['artist', 'album', 'title', 'date',
+                                 'genre', 'albumartist']
         #  have tags been collapsed?
         self.collapse_tags_bool = False
         self.collapsed_tags = list()
@@ -60,12 +60,6 @@ class Track(object):
                 self.collapsed_tags.append(tag)
                 self.__dict__.update({tag: ', '.join(set(value))})
 
-    def get_filename(self):
-        """return filename"""
-        if not self.file:
-            return None
-        return self.file
-
     def __repr__(self):
         return '%s(artist="%s", album="%s", title="%s", filename="%s")' % (
             self.__class__.__name__,
@@ -103,12 +97,7 @@ class Track(object):
         return hash(self) != hash(other)
 
     def __bool__(self):
-        return not self.empty
-
-    @property
-    def pos(self):
-        """return position of track in the playlist"""
-        return int(self._pos)
+        return not self._empty
 
     @property
     def file(self):