# Options list
# pop out 'sw' value before creating OptionParser object.
-##{{{
OPTS = list([
{
'sw': ['-S', '--hostname'],
'dest': 'port',
'help': 'Port MPD in listening on (default: 6600 or MPD_PORT if set)'},
])
-#}}}
USAGE = u"""USAGE: %prog [--help] [options]"""
-def get_mpd_environ():#{{{
+def get_mpd_environ():
"""
Retrieve MPD env. var.
"""
if len(mpd_host_env) > 1:
print 'passwd set in MPD_HOST'
passwd = mpd_host_env[1]
+ con_id.update({'passwd': passwd})
if mpd_port:
con_id.update({'port': int(mpd_port)})
- return (con_id, passwd)#}}}
+ return (con_id, passwd)
class StartOpt(object):
"""
"""
- def __init__(self, script_info, child_options):#{{{
+ def __init__(self, script_info, child_options):
# Strong assumption?
self.localencoding = 'utf8'
self.parser = None
# options allows to add new cli options within child objects calling
# parent __init__()
self.options = list(child_options + OPTS)
- self.main()#}}}
+ self.main()
- def _get_encoding(self):#{{{
+ def _get_encoding(self):
"""Get local encoding"""
- self.localencoding = getpreferredencoding()#}}}
+ self.localencoding = getpreferredencoding()
def _u8_convert(self, string):
"""Convert CLI input string to UTF8 (mpd standart)"""
return unicode(string, self.localencoding).encode('UTF-8')
- def declare_opts(self):#{{{
+ def declare_opts(self):
"""
Declare options in OptionParser object.
"""
if dest in ['host']:
self.parser.set_defaults(host=con_id.get('host'))
if dest in ['port']:
- self.parser.set_defaults(port=con_id.get('port'))#}}}
+ self.parser.set_defaults(port=con_id.get('port'))
def main(self):
"""declare options, parse command line"""
# VIM MODLINE
# vim: ai ts=4 sw=4 sts=4 expandtab
-