]> git.parisson.com Git - deefuzzer.git/commitdiff
Additional coding style cleanup
authorachbed <github@achbed.org>
Mon, 26 Jan 2015 22:44:26 +0000 (16:44 -0600)
committerachbed <github@achbed.org>
Mon, 26 Jan 2015 22:44:26 +0000 (16:44 -0600)
Signed-off-by: achbed <github@achbed.org>
deefuzzer/core.py
deefuzzer/station.py
deefuzzer/tools/PyRSS2Gen.py
deefuzzer/tools/ogg.py
deefuzzer/tools/xmltodict2.py

index 7fbaf07461fa354a6994387285f3796fb6ea51f4..ee82fd5fbe6e17615ecbdc70c934b4c61e2ac837 100644 (file)
@@ -46,7 +46,7 @@ from threading import Thread
 from deefuzzer.station import *
 from deefuzzer.tools import *
 
-mimetypes.add_type('application/x-yaml','.yaml')
+mimetypes.add_type('application/x-yaml', '.yaml')
 
 
 class DeeFuzzer(Thread):
@@ -115,7 +115,6 @@ class DeeFuzzer(Thread):
         self._info('Using libshout version %s' % shout.version())
         self._info('Number of stations : ' + str(len(self.station_settings)))
 
-
     def _log(self, level, msg):
         try:
             obj = {'msg': 'Core: ' + str(msg), 'level': level}
@@ -137,7 +136,7 @@ class DeeFuzzer(Thread):
         m3u.write('#EXTM3U\n')
         for k in self.station_instances.keys():
             s = self.station_instances[k]
-            m3u.write('#EXTINF:%s,%s - %s\n' % ('-1',s.short_name, s.channel.name))
+            m3u.write('#EXTINF:%s,%s - %s\n' % ('-1', s.short_name, s.channel.name))
             m3u.write('http://' + s.channel.host + ':' + str(s.channel.port) + s.channel.mount + '\n')
         m3u.close()
         self._info('Writing M3U file to : ' + self.m3u)
@@ -146,12 +145,12 @@ class DeeFuzzer(Thread):
         """Scan a folder for subfolders containing media, and make stations from them all."""
 
         options = self.watchfolder
-        if not 'folder' in options.keys():
+        if 'folder' not in options.keys():
             # We have no folder specified.  Bail.
             return
 
         if self.mainLoop:
-            if not 'livecreation' in options.keys():
+            if 'livecreation' not in options.keys():
                 # We have no folder specified.  Bail.
                 return
 
@@ -167,9 +166,9 @@ class DeeFuzzer(Thread):
         # This makes the log file a lot more verbose.  Commented out since we report on new stations anyway.
         # self._info('Scanning folder ' + folder + ' for stations')
 
-        if not 'infos' in options.keys():
+        if 'infos' not in options.keys():
             options['infos'] = {}
-        if not 'short_name' in options['infos'].keys():
+        if 'short_name' not in options['infos'].keys():
             options['infos']['short_name'] = '[name]'
 
         files = os.listdir(folder)
@@ -182,9 +181,9 @@ class DeeFuzzer(Thread):
     def station_exists(self, name):
         try:
             for s in self.station_settings:
-                if not 'infos' in s.keys():
+                if 'infos' not in s.keys():
                     continue
-                if not 'short_name' in s['infos'].keys():
+                if 'short_name' not in s['infos'].keys():
                     continue
                 if s['infos']['short_name'] == name:
                     return True
@@ -201,11 +200,11 @@ class DeeFuzzer(Thread):
         if self.station_exists(name):
             return
         self._info('Creating station for folder ' + folder)
-        d = dict(path=folder,name=name)
+        d = dict(path=folder, name=name)
         for i in options.keys():
-            if not 'folder' in i:
+            if 'folder' not in i:
                 s[i] = replace_all(options[i], d)
-        if not 'media' in s.keys():
+        if 'media' not in s.keys():
             s['media'] = {}
         s['media']['source'] = folder
         
@@ -276,7 +275,7 @@ class DeeFuzzer(Thread):
                     if 'station_name' in self.station_settings[i].keys():
                         name = self.station_settings[i]['station_name']
                     
-                    if not 'retries' in self.station_settings[i].keys():
+                    if 'retries' not in self.station_settings[i].keys():
                         self.station_settings[i]['retries'] = 0
                         
                     try:
@@ -289,7 +288,7 @@ class DeeFuzzer(Thread):
                             
                             if self.maxretry >= 0 and self.station_settings[i]['retries'] <= self.maxretry:
                                 # Station passed the max retries count is will not be reloaded
-                                if not 'station_stop_logged' in self.station_settings[i].keys():
+                                if 'station_stop_logged' not in self.station_settings[i].keys():
                                     self._err('Station ' + name + ' is stopped and will not be restarted.')
                                     self.station_settings[i]['station_stop_logged'] = True
                                 continue
index 36124ddb8adf6bd779c4525cc740d35342ea2e95..59eeb15684eac15264c71d65e3842f8fb97d6c20 100644 (file)
@@ -806,7 +806,6 @@ class Station(Thread):
             return False
         return True
 
-
     def icecastloop_metadata(self):
         try:
             self.update_twitter_current()
index a2122f7789618b0056ad6813a2ab5ca090a07bd2..eb4edc323155f8ff3fcaf2afbb0ba381f83c28a8 100644 (file)
@@ -8,6 +8,7 @@ _generator_name = __name__ + "-" + ".".join(map(str, __version__))
 
 import datetime
 
+
 # Could make this the base class; will need to add 'publish'
 class WriteXmlMixin:
     def __init__(self):
index 3c196a1c3e5691a377d6f5f58afbd9730ac2dd0d..bca591d8f3ebe70cd003d418f98abab42c64f6c9 100644 (file)
@@ -128,7 +128,7 @@ class Ogg:
     def get_args(self, options=None):
         """Get process options and return arguments for the encoder"""
         args = []
-        if not options is None:
+        if options is not None:
             self.options = options
             if not ('verbose' in self.options and self.options['verbose'] != '0'):
                 args.append('-Q ')
index 90b2ac8d1f5efe1bac03194d5c99b0fe43138baa..1724ec370fa021b7f7b2102105fe0a41477f07d0 100644 (file)
@@ -10,18 +10,18 @@ import locale
 from xml.parsers import expat
 
 # If we're in Dabo, get the default encoding.
-#import dabo
-#import dabo.lib.DesignerUtils as desUtil
-#from dabo.dLocalize import _
-#from dabo.lib.utils import resolvePath
-#app = dabo.dAppRef
-#if app is not None:
-    #default_encoding = app.Encoding
-#else:
-        #enc = locale.getlocale()[1]
-        #if enc is None:
-            #enc = dabo.defaultEncoding
-        #default_encoding = enc
+# import dabo
+# import dabo.lib.DesignerUtils as desUtil
+# from dabo.dLocalize import _
+# from dabo.lib.utils import resolvePath
+# app = dabo.dAppRef
+# if app is not None:
+    # default_encoding = app.Encoding
+# else:
+        # enc = locale.getlocale()[1]
+        # if enc is None:
+            # enc = dabo.defaultEncoding
+        # default_encoding = enc
 
 # Python seems to need to compile code with \n linesep:
 code_linesep = "\n"
@@ -45,7 +45,6 @@ class Xml2Obj:
         self._currPropAtt = ""
         self._currPropDict = None
 
-
     def StartElement(self, name, attributes):
         """SAX start element even handler"""
         if name == "code":
@@ -95,7 +94,6 @@ class Xml2Obj:
                     self.root = element
                 self.nodeStack.append(element)
 
-
     def EndElement(self, name):
         """SAX end element event handler"""
         if self._inCode:
@@ -156,7 +154,6 @@ class Xml2Obj:
         ParserStatus = Parser.Parse(xml, 1)
         return self.root
 
-
     def ParseFromFile(self, filename):
         return self.Parse(open(filename,"r").read())
 
@@ -274,7 +271,7 @@ def dicttoxml(dct, level=0, header=None, linesep=None):
                     ret += "%s<%s><![CDATA[%s%s]]>%s%s</%s>%s" % (methodTab,
                             mthd, eol, cd, eol,
                             methodTab, mthd, eol)
-                ret += "%s</code>%s"    % ("\t" * (level+1), eol)
+                ret += "%s</code>%s" % ("\t" * (level+1), eol)
 
         if dct.has_key("properties"):
             if len(dct["properties"].keys()):
@@ -287,7 +284,7 @@ def dicttoxml(dct, level=0, header=None, linesep=None):
                         ret += "%s<%s>%s</%s>%s" % (itmTab, propItm, itmVal,
                                 propItm, eol)
                     ret += "%s</%s>%s" % (currTab, prop, eol)
-                ret += "%s</properties>%s"  % ("\t" * (level+1), eol)
+                ret += "%s</properties>%s" % ("\t" * (level+1), eol)
 
         if dct.has_key("children") and len(dct["children"]) > 0:
             ret += eol
@@ -386,12 +383,12 @@ def addInheritedInfo(src, super, updateCode=False):
 
 
 
-#if __name__ == "__main__":
-    #test_dict = {"name": "test", "attributes":{"path": "c:\\temp\\name",
-            #"problemChars": "Welcome to <Jos\xc3\xa9's \ Stuff!>\xc2\xae".decode("latin-1")}}
-    #print "test_dict:", test_dict
-    #xml = dicttoxml(test_dict)
-    #print "xml:", xml
-    #test_dict2 = xmltodict(xml)
-    #print "test_dict2:", test_dict2
-    #print "same?:", test_dict == test_dict2
+# if __name__ == "__main__":
+    # test_dict = {"name": "test", "attributes":{"path": "c:\\temp\\name",
+            # "problemChars": "Welcome to <Jos\xc3\xa9's \ Stuff!>\xc2\xae".decode("latin-1")}}
+    # print "test_dict:", test_dict
+    # xml = dicttoxml(test_dict)
+    # print "xml:", xml
+    # test_dict2 = xmltodict(xml)
+    # print "test_dict2:", test_dict2
+    # print "same?:", test_dict == test_dict2