]> kaliko git repositories - mpd-goodies.git/blobdiff - src/lib/startop.py
* add Goodie class (wraps mpdclass and startop together)
[mpd-goodies.git] / src / lib / startop.py
index b73160b3aaf742656d8985efa96ccafce3b28611..c44159f8586a975544915b6019d2339322f35206 100644 (file)
@@ -6,7 +6,6 @@ from os import environ
 
 # Options list
 # pop out 'sw' value before creating OptionParser object.
-##{{{
 OPTS = list([
     {
         'sw': ['-S', '--hostname'],
@@ -19,12 +18,11 @@ OPTS = list([
         '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.
     """
@@ -43,16 +41,17 @@ def get_mpd_environ():#{{{
         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
@@ -63,17 +62,17 @@ class StartOpt(object):
         # 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.
         """
@@ -98,7 +97,7 @@ class StartOpt(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"""
@@ -116,4 +115,3 @@ if __name__ == '__main__':
 
 # VIM MODLINE
 # vim: ai ts=4 sw=4 sts=4 expandtab
-