From a1c57c92ceebbfdb9ba5ba1e2c0b8c97ac200106 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Wed, 8 Feb 2023 18:29:36 +0100
Subject: [PATCH] Fix python style errors

---
 DDCore/python/dd4hep_base.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/DDCore/python/dd4hep_base.py b/DDCore/python/dd4hep_base.py
index 952189736..5f95ba180 100644
--- a/DDCore/python/dd4hep_base.py
+++ b/DDCore/python/dd4hep_base.py
@@ -10,15 +10,18 @@
 # ==========================================================================
 from __future__ import absolute_import, unicode_literals
 import cppyy
-import importlib
+import imp
 import logging
 
-logger = logging.getLogger(__name__)
 
-# We compile the DDG4 plugin on the fly if it does not exist using the AClick mechanism:
+logger = logging.getLogger(__name__)
 
 
 def compileAClick(dictionary, g4=True):
+  """
+  We compile the DDG4 plugin on the fly if it does not exist using the AClick mechanism.
+
+  """
   from ROOT import gInterpreter, gSystem
   import os.path
   dd4hep = os.environ['DD4hepINSTALL']
@@ -32,7 +35,7 @@ def compileAClick(dictionary, g4=True):
   gSystem.AddIncludePath(inc)
   gSystem.AddLinkedLibs(lib)
   logger.info('Loading AClick %s', dictionary)
-  package = importlib.import_module('DDG4')
+  package = imp.find_module('DDG4')
   dic = os.path.dirname(package[1]) + os.sep + dictionary
   gInterpreter.ProcessLine('.L ' + dic + '+')
   from ROOT import dd4hep as module
@@ -40,6 +43,9 @@ def compileAClick(dictionary, g4=True):
 
 
 def loaddd4hep():
+  """
+  Import DD4hep module from ROOT using ROOT reflection
+  """
   import os
   import sys
   # Add ROOT to the python path in case it is not yet there....
@@ -149,7 +155,6 @@ cond = dd4hep.cond
 tools = dd4hep.tools
 align = dd4hep.align
 detail = dd4hep.detail
-import imp
 units = imp.new_module('units')
 # ---------------------------------------------------------------------------
 import_namespace_item('tools', 'Evaluator')
@@ -413,20 +418,25 @@ class CommandLine:
 #
 try:
   import_namespace_item('core', 'dd4hep_units')
+
+
   def import_units(ns=None):
     if ns is None:
       ns = name_space
+
     logger.debug('Importing units into namespace ' + str(ns.__name__))
-    count = 0;
+    count = 0
     for nam in dir(dd4hep.dd4hep_units):
       if nam[0] != '_':
         count = count + 1
         setattr(ns, nam, getattr(core.dd4hep_units, nam))
-        ##setattr(ns, nam, getattr(core, nam))
+        # setattr(ns, nam, getattr(core, nam))
     return count
+
 except Exception as e:
   logger.warning('No units can be imported. ' + str(e))
 
+
   def import_units(ns=None):
     return 0
 
-- 
GitLab