From: kaliko Date: Fri, 13 Dec 2013 13:08:50 +0000 (+0100) Subject: Some clean-up in track object X-Git-Tag: mpd-sima/0.12.0pr2~10 X-Git-Url: http://git.kaliko.me/?a=commitdiff_plain;h=ad6abade7a1da313f9ef36494d38a3a927a5aee2;p=mpd-sima.git Some clean-up in track object Removed redundant shutdown call in foreground mode --- diff --git a/launch b/launch index 43fc0bc..c7ff8e6 100755 --- 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(): diff --git a/sima/lib/daemon.py b/sima/lib/daemon.py index 1feb7e4..b0b1130 100644 --- a/sima/lib/daemon.py +++ b/sima/lib/daemon.py @@ -14,14 +14,14 @@ # 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 . +# along with MPD_sima. If not, see . import atexit import os diff --git a/sima/lib/simadb.py b/sima/lib/simadb.py index 4db498d..a3d9518 100644 --- a/sima/lib/simadb.py +++ b/sima/lib/simadb.py @@ -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: diff --git a/sima/lib/track.py b/sima/lib/track.py index 87c96fc..c88de6c 100644 --- a/sima/lib/track.py +++ b/sima/lib/track.py @@ -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):