From: kaliko Date: Wed, 26 Jan 2011 16:15:59 +0000 (+0000) Subject: * reorganized source folders X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=8c680f357953b22043895a3b49f9e58981504669;p=mpd-goodies.git * reorganized source folders * added a Makefile --- diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..824da57 --- /dev/null +++ b/INSTALL @@ -0,0 +1,14 @@ +Default installation in /usr/{bin,share/,share/man}. + +Makefile supports both DESTDIR and PREFIX GNU standards. + +Just call install target to have mpd-goodies installed within /usr + + make install + +If you need to install it somewhere else use PREFIX variable. +For instance installing in /usr/local directory: + + make PREFIX=/usr install + +Run uninstall target to remove. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6bf3dfc --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +SHELL = /bin/sh +PREFIX = /usr +#DESTDIR = /tmp/mpd-goodies +LIBDIR = $(DESTDIR)$(PREFIX)/lib +BIN = $(DESTDIR)$(PREFIX)/bin +ETC = $(DESTDIR)$(PREFIX)/etc +DATADIR = $(DESTDIR)$(PREFIX)/share +LOCALEDIR = $(DATADIR)/locale +MANDIR = $(DATADIR)/man +PKGNAME = mpd-goodies + +all: man bin +#clean: +# rm -f mpd-goodies.1.gz + +mpd-goodies.1.gz: + cat data/mpd-goodies.1 | gzip > mpd-goodies.1.gz + +bash_completion: + install -d $(ETC)/bash_completion.d + install -m644 data/mpd-goodies.sh $(ETC)/bash_completion.d/ + mv $(ETC)/bash_completion.d/mpd-goodies.sh $(ETC)/bash_completion.d/$(PKGNAME) + +man: mpd-goodies.1.gz + +install: + install -d $(BIN) $(DATADIR)/$(PKGNAME) #$(MANDIR)/man1 + + #install -m644 mpd-goodies.1.gz $(MANDIR)/man1 + + # listing all sub folder to install (prevent a remaining .svn directory to be install) + for sourcedir in `find src/ -name .svn -prune -o -type d -print | sed 's:src/::g'` ; do \ + install -d $(DATADIR)/$(PKGNAME)/$$sourcedir; \ + for sourcefile in `find src/$$sourcedir -maxdepth 1 -name *pyc -o -name .svn -prune -o -print` ; do \ + install -m644 $$sourcefile $(DATADIR)/$(PKGNAME)/$$sourcedir; \ + done \ + done + # listing all command in ./src + for command in `find src/ -maxdepth 1 -name .svn -prune -o -type f -print` ; do \ + install -m 755 $$command $(DATADIR)/$(PKGNAME)/ ;\ + done + for command in `find $(DATADIR)/$(PKGNAME)/ -maxdepth 1 -name .svn -prune -o -type f -print` ; do \ + ln -sf $$command $(BIN) ;\ + done + +uninstall: + for command in `find $(DATADIR)/$(PKGNAME)/ -maxdepth 1 -name .svn -prune -o -type f -print` ; do \ + rm -rf $(BIN)/$$(basename $$command) ;\ + done + rm -f $(MANDIR)/man1/mpd-goodies.1.gz + rm -f $(ETC)/bash_completion.d/$(PKGNAME) + rm -rf $(DATADIR)/$(PKGNAME) diff --git a/crop b/src/crop similarity index 95% rename from crop rename to src/crop index 944241a..5f7dde5 100755 --- a/crop +++ b/src/crop @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2009, 2010 Efrim {{{ +# Copyright (c) 2009, 2010 Efrim # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,8 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# }}} - import sys @@ -28,6 +26,7 @@ NAME = 'crop' VERSION = '0.1' USAGE = 'USAGE: %prog [--help] | [ ]' + class Crop(StartOpt, MPDClass): """ """ @@ -61,7 +60,7 @@ class Crop(StartOpt, MPDClass): print 'Keeping %i tracks' % self.nb_tracks self.mpdConnect() current_pos = int(self.client.currentsong().get('pos', 0)) - if current_pos <= self.nb_tracks: + if current_pos <= self.nb_tracks: self.client.disconnect() sys.exit(0) while current_pos > self.nb_tracks: diff --git a/lib/__init__.py b/src/lib/__init__.py similarity index 100% rename from lib/__init__.py rename to src/lib/__init__.py diff --git a/lib/mpdclass.py b/src/lib/mpdclass.py similarity index 79% rename from lib/mpdclass.py rename to src/lib/mpdclass.py index 63a2f06..b17943e 100755 --- a/lib/mpdclass.py +++ b/src/lib/mpdclass.py @@ -18,24 +18,25 @@ class MPDClass(object): def __init__(self): self.client = MPDClient() - def mpdConnect(self):#{{{ + def mpdConnect(self): """ Simple wrapper to connect MPD. """ - con_id = dict({'host':self.cli_options.host, 'port':self.cli_options.port}) + con_id = dict({'host': self.cli_options.host, + 'port': self.cli_options.port}) try: self.client.connect(**con_id) except SocketError: return False - return True#}}} + return True - def mpdAuth(self, secret):#{{{ + def mpdAuth(self, secret): """ Authenticate""" try: self.client.password(secret) except CommandError: return False - return True#}}} + return True def main(): @@ -47,4 +48,3 @@ if __name__ == '__main__': # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab - diff --git a/lib/mpdutils.py b/src/lib/mpdutils.py similarity index 100% rename from lib/mpdutils.py rename to src/lib/mpdutils.py diff --git a/lib/startop.py b/src/lib/startop.py similarity index 100% rename from lib/startop.py rename to src/lib/startop.py diff --git a/mfade b/src/mfade similarity index 92% rename from mfade rename to src/mfade index de84f14..0ffd9df 100755 --- a/mfade +++ b/src/mfade @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2009, 2010 Efrim {{{ +# Copyright (c) 2009, 2010 Efrim # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# }}} """ DOC: @@ -49,16 +48,16 @@ class Sleep(StartOpt, MPDClass): 'usage': USAGE, }) - def __init__(self):#{{{ + def __init__(self): """""" StartOpt.__init__(self, self.__class__.script_info, []) MPDClass.__init__(self) self.tempo = int(10) self.volum = None self._consume_args() - self._run()#}}} + self._run() - def _consume_args(self):#{{{ + def _consume_args(self): """""" if (len(self.cli_args) < 1 or len(self.cli_args) > 2): @@ -69,9 +68,9 @@ class Sleep(StartOpt, MPDClass): except IndexError: pass except ValueError, err: - self.parser.error('wrong option passed (%s)' % err)#}}} + self.parser.error('wrong option passed (%s)' % err) - def _run(self):#{{{ + def _run(self): """""" self.mpdConnect() self.mpd_state = str(self.client.status().get('state')) @@ -92,9 +91,9 @@ class Sleep(StartOpt, MPDClass): self.mpd_vol = 0 self.client.play() self.fade() - sleep(1)#}}} + sleep(1) - def fade(self):#{{{ + def fade(self): """""" # TODO: handle possible lost connections span = float(self.volum - self.mpd_vol) @@ -109,7 +108,7 @@ class Sleep(StartOpt, MPDClass): if abs(vol - self.volum) < 1: self.client.setvol(self.volum) return True - sleep(1)#}}} + sleep(1) # Script starts here diff --git a/mtopls b/src/mtopls similarity index 95% rename from mtopls rename to src/mtopls index 6d0c6ee..1210fd6 100755 --- a/mtopls +++ b/src/mtopls @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2009, 2010 Efrim {{{ +# Copyright (c) 2009, 2010 Efrim # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# }}} import sys @@ -31,6 +30,7 @@ NAME = 'mtopls' VERSION = '0.1' USAGE = 'USAGE: %prog [--help] | /path/to/the/playlist/file/' + class MtoPls(StartOpt, MPDClass): """ """ @@ -82,7 +82,8 @@ class MtoPls(StartOpt, MPDClass): def _run(self): """""" - print 'Connecting %s:%i' % (self.cli_options.host, self.cli_options.port) + print 'Connecting %s:%i' % (self.cli_options.host, + self.cli_options.port) self.mpdConnect() self.current_song = self.client.currentsong() self.client.disconnect() diff --git a/nalbum b/src/nalbum similarity index 96% rename from nalbum rename to src/nalbum index c2e3110..e48ad68 100755 --- a/nalbum +++ b/src/nalbum @@ -54,7 +54,7 @@ class Nalbum(StartOpt, MPDClass): MPDClass.__init__(self) self._run() - def _fade(self, io='out'):#{{{ + def _fade(self, io='out'): """ end_volum => End volume value mpd_vol => Start volume value @@ -74,9 +74,9 @@ class Nalbum(StartOpt, MPDClass): if abs(mpd_vol - end_volum) < 1: self.client.setvol(end_volum) return True - sleep(0.1)#}}} + sleep(0.1) - def _get_next(self):#{{{ + def _get_next(self): """Retrieve playlist from current song to the end.""" if 'song' not in self.client.status(): print "No current song set in MPD!" @@ -96,7 +96,7 @@ class Nalbum(StartOpt, MPDClass): sys.exit(0) album = self.client.playlistinfo(next_album_pos)[0].get('album', 'TAG MISSING') print 'Next album appears to be: "%s"' % album - return next_album_pos#}}} + return next_album_pos def _run(self): """""" diff --git a/wakeup b/src/wakeup similarity index 100% rename from wakeup rename to src/wakeup