From e4e1bbc97ec664aaf9542babb3aba3809129599d Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Mon, 9 Dec 2019 17:15:28 +0100
Subject: [PATCH] JetRecConfig:  Basic python3 fixes.

 - Relative import fixes.
 - iteritems
---
 .../Jet/JetRecConfig/python/JetGroomConfig.py          | 10 ++++++----
 Reconstruction/Jet/JetRecConfig/python/JetGrooming.py  |  2 +-
 Reconstruction/Jet/JetRecConfig/python/JetModConfig.py |  2 +-
 Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py |  6 +++---
 .../Jet/JetRecConfig/python/StandardJetMods.py         |  2 +-
 5 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/Reconstruction/Jet/JetRecConfig/python/JetGroomConfig.py b/Reconstruction/Jet/JetRecConfig/python/JetGroomConfig.py
index 208634ab156..3f84030afa1 100644
--- a/Reconstruction/Jet/JetRecConfig/python/JetGroomConfig.py
+++ b/Reconstruction/Jet/JetRecConfig/python/JetGroomConfig.py
@@ -17,12 +17,14 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 # So, import package conf modules rather than a dozen individual classes
 from JetRec import JetRecConf
 
+import six
+
 ########################################################################
 # Get a jet groomer class given a tool name and the grooming definition object
 #
 def getJetGroomer(groomdef):
     tooltype = groomdef.groomspec["ToolType"]
-    toolprops = {key:val for key,val in groomdef.groomspec.iteritems() if key not in ["groomalg","ToolType"]}
+    toolprops = {key:val for key,val in six.iteritems (groomdef.groomspec) if key not in ["groomalg","ToolType"]}
     return tooltype(groomdef.basename,**toolprops)
 
 
@@ -33,13 +35,13 @@ def getJetGroomer(groomdef):
 def getJetGroomAlg(jetname,groomdef,modlist):
     jetlog.debug("Configuring JetAlgorithm \"jetalg_{0}\"".format(jetname))
 
-    import JetRecConfig
+    from . import JetRecConfig
     builder = JetRecConfig.getJetBuilder()
 
     groomer = getJetGroomer(groomdef)
     groomer.JetBuilder = builder
 
-    import JetModConfig
+    from . import JetModConfig
     mods = []
     # Dependency resolution should be done externally
     for moddef,modspec in modlist:
@@ -76,7 +78,7 @@ def JetGroomCfg(groomdef, configFlags, jetnameprefix="",jetnamesuffix=""):
     # If not, we need to configure their reconstruction.
     filecontents = configFlags.Input.Collections
     if groomdef.ungroomedname not in filecontents:
-        from JetRecConfig import JetRecCfg
+        from . import JetRecCfg
         components.merge(JetRecCfg(groomdef.ungroomeddef, configFlags,
                                    jetnameoverride=groomdef.ungroomedname))
     else:
diff --git a/Reconstruction/Jet/JetRecConfig/python/JetGrooming.py b/Reconstruction/Jet/JetRecConfig/python/JetGrooming.py
index 53c9d6d866b..a915ff6b446 100644
--- a/Reconstruction/Jet/JetRecConfig/python/JetGrooming.py
+++ b/Reconstruction/Jet/JetRecConfig/python/JetGrooming.py
@@ -126,7 +126,7 @@ class JetTrimming(GroomingDefinition):
         ptfrac = self.groomspec["PtFrac"]
         ptfracstr = int(ptfrac*100) # Not usually smaller than %
         smallR = self.groomspec["RClus"]
-        from JetDefinition import formatRvalue
+        from .JetDefinition import formatRvalue
         smallRstr = formatRvalue(smallR*10)
         
         groomstr = "TrimmedPtFrac{}SmallR{}".format(ptfracstr,smallRstr)
diff --git a/Reconstruction/Jet/JetRecConfig/python/JetModConfig.py b/Reconstruction/Jet/JetRecConfig/python/JetModConfig.py
index 346ed1984ec..d494a0ce160 100644
--- a/Reconstruction/Jet/JetRecConfig/python/JetModConfig.py
+++ b/Reconstruction/Jet/JetRecConfig/python/JetModConfig.py
@@ -59,7 +59,7 @@ def getFinalModifierListAndPrereqs(mods_initial, jetdef):
 # Translate modifier string into JetModifier if necessary
 # Extracts the modspec from the string or the config object
 def getModDefAndSpec(mod):
-    from StandardJetMods import jetmoddict
+    from .StandardJetMods import jetmoddict
     moddef = mod
     modspec = ""
     if mod.__class__ == type("str"):
diff --git a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py
index 0ff0b882a5b..71811d6aa2a 100644
--- a/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py
+++ b/Reconstruction/Jet/JetRecConfig/python/JetRecConfig.py
@@ -123,7 +123,7 @@ def resolveDependencies(jetdef):
     # Need to use a list, as the order matters.
     # The elements of the "final" list are tuples extracting
     # the modifier specification.
-    import JetModConfig
+    from . import JetModConfig
     mods_final, modprereqs = JetModConfig.getFinalModifierListAndPrereqs( mods_initial, jetdef )
 
     # Remove the duplicates in the mod list -- just do this
@@ -196,7 +196,7 @@ def classifyPrereqs(prereqs):
 #
 def expandPrereqs(reqtype,prereqs):
     reqdefs = set()
-    from JetDefinition import JetGhost
+    from .JetDefinition import JetGhost
     for req in prereqs:
         if reqtype=="ghost":
             if req.__class__ == JetGhost:
@@ -417,7 +417,7 @@ def getJetAlgorithm(jetname, jetdef, pjs, modlist):
     finder = getJetFinder(jetname, jetdef)
     finder.JetBuilder = builder
 
-    import JetModConfig
+    from . import JetModConfig
     mods = []
     for moddef,modspec in modlist:
         mod = JetModConfig.getModifier(jetdef,moddef,modspec)
diff --git a/Reconstruction/Jet/JetRecConfig/python/StandardJetMods.py b/Reconstruction/Jet/JetRecConfig/python/StandardJetMods.py
index 28718aeda7a..2fcc750dbdb 100644
--- a/Reconstruction/Jet/JetRecConfig/python/StandardJetMods.py
+++ b/Reconstruction/Jet/JetRecConfig/python/StandardJetMods.py
@@ -1,4 +1,4 @@
-from JetDefinition import JetModifier
+from .JetDefinition import JetModifier
 
 ########################################################################
 # Define the dictionary of tool configurations using the helpers defined
-- 
GitLab