ソースを参照

HUE-8888 [core] Light restyling of the appmanager

Romain 5 年 前
コミット
12b0a49b41
1 ファイル変更18 行追加14 行削除
  1. 18 14
      desktop/core/src/desktop/appmanager.py

+ 18 - 14
desktop/core/src/desktop/appmanager.py

@@ -23,15 +23,19 @@ import sys
 import traceback
 import pkg_resources
 
+from django.utils.translation import ugettext as _
+
 import desktop
+
 from desktop.lib.paths import get_desktop_root
 
-from django.utils.translation import ugettext as _
 
 # Directories where apps and libraries are to be found
-APP_DIRS = [get_desktop_root('core-apps'),
-            get_desktop_root('apps'),
-            get_desktop_root('libs')]
+APP_DIRS = [
+    get_desktop_root('core-apps'),
+    get_desktop_root('apps'),
+    get_desktop_root('libs')
+]
 
 LOG = logging.getLogger(__name__)
 
@@ -42,7 +46,7 @@ LOG = logging.getLogger(__name__)
 # List of DesktopModuleInfo that have been loaded
 DESKTOP_LIBS = None
 DESKTOP_APPS = None
-DESKTOP_MODULES = [ ]           # Sum of APPS and LIBS
+DESKTOP_MODULES = []  # Sum of APPS and LIBS
 
 def _import_module_or_none(module):
   """Like import_module, but returns None if the module does not exist.
@@ -133,10 +137,12 @@ class DesktopModuleInfo(object):
       self.display_name = self.config_key
 
     # Look for static directory in two places:
-    new_style, old_style = [ os.path.abspath(p) for p in [
-      os.path.join(module_root, "static", self.name),
-      os.path.join(self.root_dir, "static")
-    ]]
+    new_style, old_style = [
+      os.path.abspath(p) for p in [
+        os.path.join(module_root, "static", self.name),
+        os.path.join(self.root_dir, "static")
+      ]
+    ]
 
     self.static_dir = None
     if os.path.isdir(new_style):
@@ -225,13 +231,12 @@ def load_libs():
 
   if DESKTOP_LIBS is not None:
     raise Exception("load_apps already has been called.")
-  DESKTOP_LIBS = [ ]
+  DESKTOP_LIBS = []
 
   for lib in pkg_resources.iter_entry_points("desktop.sdk.lib"):
     m = lib.load()
     DESKTOP_LIBS.append(DesktopModuleInfo(m))
 
-
   LOG.debug("Loaded Desktop Libraries: " + ", ".join(a.name for a in DESKTOP_LIBS))
   DESKTOP_MODULES += DESKTOP_LIBS
   # Desktop itself is "special"; neither an app or a lib, but
@@ -241,10 +246,9 @@ def load_libs():
 
 
 def load_apps(app_blacklist):
-  """Loads the applications from the directories in APP_DIRS.
+  """
+  Loads the applications from the directories in APP_DIRS.
   Sets DESKTOP_MODULES and DJANGO_APPS globals in this module.
-
-  TODO(todd) make this a singleton perhaps if people are anti-global?
   """
   global DESKTOP_MODULES
   global DESKTOP_APPS