Use pylint check
authorPetr Vobornik <pvoborni@redhat.com>
Thu, 23 Jan 2014 14:51:20 +0000 (15:51 +0100)
committerSimo Sorce <simo@redhat.com>
Fri, 24 Jan 2014 22:32:18 +0000 (17:32 -0500)
Signed-off-by: Petr Vobornik <pvoborni@redhat.com>
Reviewed-by: Simo Sorce <simo@redhat.com>
Makefile [new file with mode: 0644]
ipsilon/util/data.py
ipsilon/util/page.py
ipsilon/util/plugin.py
ipsilon/util/user.py

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..7d81f00
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+all: lint
+
+lint:
+       # Analyze code
+       # don't show recommendations, info, comments, report
+       # W0613 - unused argument
+       # Ignore cherrypy class members as they are dynamically added
+       pylint -d c,r,i,W0613 -r n -f colorized \
+                  --notes= \
+                  --ignored-classes=cherrypy \
+                  ./ipsilon
index ec64588..858fa55 100755 (executable)
@@ -102,7 +102,7 @@ class Store(object):
 
         return conf
 
 
         return conf
 
-    def _get_user_preferences(self, user):
+    def get_user_preferences(self, user):
         path = None
         if 'user.prefs.db' in cherrypy.config:
             path = cherrypy.config['user.prefs.db']
         path = None
         if 'user.prefs.db' in cherrypy.config:
             path = cherrypy.config['user.prefs.db']
index a99ece8..a7e2035 100755 (executable)
@@ -34,8 +34,10 @@ class Page(object):
         self._env = template_env
         self.basepath = cherrypy.config.get('base.mount', "")
         self.username = None
         self._env = template_env
         self.basepath = cherrypy.config.get('base.mount', "")
         self.username = None
+        self.user = None
 
     def __call__(self, *args, **kwargs):
 
     def __call__(self, *args, **kwargs):
+        # pylint: disable=star-args
         self.username = cherrypy.session.get('user', None)
         self.user = User(self.username)
 
         self.username = cherrypy.session.get('user', None)
         self.user = User(self.username)
 
index be9ed02..2db88dd 100755 (executable)
@@ -37,11 +37,11 @@ class Plugins(object):
         try:
             if ext.lower() == '.py':
                 mod = imp.load_source(name, file_name)
         try:
             if ext.lower() == '.py':
                 mod = imp.load_source(name, file_name)
-            elif ex.lower() == '.pyc':
+            elif ext.lower() == '.pyc':
                 mod = imp.load_compiled(name, file_name)
             else:
                 return
                 mod = imp.load_compiled(name, file_name)
             else:
                 return
-        except Exception, e:
+        except Exception, e:  # pylint: disable=broad-except
             cherrypy.log.error('Failed to load "%s" module: [%s]' % (name, e))
             return
 
             cherrypy.log.error('Failed to load "%s" module: [%s]' % (name, e))
             return
 
@@ -53,12 +53,12 @@ class Plugins(object):
         files = None
         try:
             files = os.listdir(path)
         files = None
         try:
             files = os.listdir(path)
-        except Exception, e:
+        except Exception, e:  # pylint: disable=broad-except
             cherrypy.log.error('No modules in %s: [%s]' % (path, e))
             return
 
         for name in files:
             cherrypy.log.error('No modules in %s: [%s]' % (path, e))
             return
 
         for name in files:
-            filename = od.path.join(path, name)
+            filename = os.path.join(path, name)
             self._load_class(tree, class_type, filename)
 
     def get_providers(self):
             self._load_class(tree, class_type, filename)
 
     def get_providers(self):
@@ -74,7 +74,7 @@ class Plugins(object):
 
         return self._providers_tree
 
 
         return self._providers_tree
 
-    def get_custom(self, class_type):
+    def get_custom(self, path, class_type):
         tree = []
         tree = []
-        self._load_classes(tree, class_type)
+        self._load_classes(tree, path, class_type)
         return tree
         return tree
index 3b58724..6c5fc51 100755 (executable)
@@ -36,7 +36,7 @@ class User(object):
 
     def _get_user_data(self, username):
         store = Store()
 
     def _get_user_data(self, username):
         store = Store()
-        return store._get_user_preferences(username)
+        return store.get_user_preferences(username)
 
     @property
     def is_admin(self):
 
     @property
     def is_admin(self):