diff --git a/Event/EventBookkeeperTools/CMakeLists.txt b/Event/EventBookkeeperTools/CMakeLists.txt index 97705ec7682333e4a78c895435cd83a6627f0033..3878dd2fec896cc6d1a75c893ebd572cbadbcada 100644 --- a/Event/EventBookkeeperTools/CMakeLists.txt +++ b/Event/EventBookkeeperTools/CMakeLists.txt @@ -43,7 +43,7 @@ atlas_add_executable( dump-cbk LINK_LIBRARIES ${xaod_access_lib} AsgTools ) # Install files from the package: -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_joboptions( share/*.py ) # Tests diff --git a/Event/EventBookkeeperTools/python/BookkeepingInfoWriter.py b/Event/EventBookkeeperTools/python/BookkeepingInfoWriter.py index 06b6ff2d5755b3258445ee7be4868545e5ba3a6e..3b45b72840be921f98ed964cec2be74bf1d315e8 100644 --- a/Event/EventBookkeeperTools/python/BookkeepingInfoWriter.py +++ b/Event/EventBookkeeperTools/python/BookkeepingInfoWriter.py @@ -93,11 +93,11 @@ class BookkeepingWriterBase( PyAthena.Alg ): if alg: dic[name]["Alg"]=alg - self.msg.debug("Succesfully added algorithm '%s'"%name) + self.msg.debug("Succesfully added algorithm '%s'", name) else: - self.msg.warning("BookkeepingWriterBase cannot get algorithm '%s'. This alg will not be bookkept."%name) + self.msg.warning("BookkeepingWriterBase cannot get algorithm '%s'. This alg will not be bookkept.", name) dic.pop(name) return @@ -119,7 +119,7 @@ class SkimDecisionsWriter(BookkeepingWriterBase): return def initialize(self): - self.msg.info("SkimDecisionsContainer name: '%s'"%self.SkimDecisionsContainerName) + self.msg.info("SkimDecisionsContainer name: '%s'", self.SkimDecisionsContainerName) self.sg = PyAthena.py_svc("StoreGateSvc") return BookkeepingWriterBase.initialize(self) @@ -129,12 +129,12 @@ class SkimDecisionsWriter(BookkeepingWriterBase): sd.setName(prefix+"_"+key) try: sd.setIsAccepted(dic[key]["Alg"].filterPassed()) - except: - self.msg.error("problem with filterPassed() for alg %s..."%key) + except Exception: + self.msg.error("problem with filterPassed() for alg %s...", key) sdc.push_back(sd) ROOT.SetOwnership (sd, False) - self.msg.debug("Skim %s: %i (%s)"%(key,sd.isAccepted(),prefix)) + self.msg.debug("Skim %s: %i (%s)", key, sd.isAccepted(), prefix) return def execute(self): diff --git a/Event/EventBookkeeperTools/python/CutFlowHelpers.py b/Event/EventBookkeeperTools/python/CutFlowHelpers.py index 6e246a6e802f1437a678894dfd233cbb95504d25..351ed7a8ee1b749cb36a1fe0215c6a5d52238430 100644 --- a/Event/EventBookkeeperTools/python/CutFlowHelpers.py +++ b/Event/EventBookkeeperTools/python/CutFlowHelpers.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Creation: Karsten Koeneke def GetCurrentStreamName( msg ): @@ -6,7 +6,7 @@ def GetCurrentStreamName( msg ): # First, try to get the info from the RecFlags try: from RecExConfig.RecFlags import rec - msg.debug("Got the stream name from the RecFlags: %s" % rec.mergingStreamName()) + msg.debug("Got the stream name from the RecFlags: %s", rec.mergingStreamName()) streamName = rec.mergingStreamName() if streamName == "": streamName = "unknownStream" @@ -39,7 +39,7 @@ def CreateCutFlowSvc( svcName="CutFlowSvc", seq=None, addMetaDataToAllOutputFile # Determine current input stream name inputStreamName = GetCurrentStreamName( msg=msg ) - msg.debug("CreateCutFlowSvc: Have inputStreamName = %s" % (inputStreamName) ) + msg.debug("CreateCutFlowSvc: Have inputStreamName = %s", inputStreamName) # Create the CutFlowSvc instance import AthenaCommon.CfgMgr as CfgMgr @@ -81,11 +81,11 @@ def CreateCutFlowSvc( svcName="CutFlowSvc", seq=None, addMetaDataToAllOutputFile if alg.getName() == "xAODMaker::EventInfoCnvAlg": break pass pass - msg.debug("Adding EventCounterAlg with name AllExecutedEvents to sequence with name %s at position %i" % (seq.getName(),index)) + msg.debug("Adding EventCounterAlg with name AllExecutedEvents to sequence with name %s at position %i", seq.getName(), index) seq.insert( index, CfgMgr.EventCounterAlg("AllExecutedEvents") ) pass else : - msg.info("Could NOT add EventCounterAlg with name AllExecutedEvents to locked sequence with name %s" % seq.getName()) + msg.info("Could NOT add EventCounterAlg with name AllExecutedEvents to locked sequence with name %s", seq.getName()) pass pass diff --git a/Event/EventBookkeeperTools/python/PyFilterTester.py b/Event/EventBookkeeperTools/python/PyFilterTester.py index 3257a3a64bc37c3112ff7042e218a417ea70c0da..ad4f070ef6dc73ce7c1aa289b32a29686d7176b7 100644 --- a/Event/EventBookkeeperTools/python/PyFilterTester.py +++ b/Event/EventBookkeeperTools/python/PyFilterTester.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration ##============================================================================= ## Name: PyFilterTester @@ -35,5 +35,5 @@ class PyFilterTester( AthFilterAlgorithm ): return StatusCode.Success def finalize(self): - self.msg.info( ' Number of processed events: %r' % self.nProcessed ) + self.msg.info( ' Number of processed events: %r', self.nProcessed ) return StatusCode.Success diff --git a/Event/EventBookkeeperTools/python/TestLogicalFilterCombiner.py b/Event/EventBookkeeperTools/python/TestLogicalFilterCombiner.py index 111bdc81fc3310d1c2f3e31098546b1cd196df00..fec3b11db7e0d141f505f00f350cb8b8b1994e21 100644 --- a/Event/EventBookkeeperTools/python/TestLogicalFilterCombiner.py +++ b/Event/EventBookkeeperTools/python/TestLogicalFilterCombiner.py @@ -88,7 +88,7 @@ class TestLogicalFilterCombiner( PyAthena.AthFilterAlgorithm ): self.msg.error("Algorithm %s not found" , tokval) return False else: - self.msg.debug("Found algorithm: %s -> %s" % (tokval, _alg)) + self.msg.debug("Found algorithm: %s -> %s", tokval, _alg) exec('self.%s = _alg' % tokval) @@ -123,7 +123,7 @@ class TestLogicalFilterCombiner( PyAthena.AthFilterAlgorithm ): def execute(self): for k,v in self.algdict.iteritems(): - self.msg.debug("Alg %s : %s" % (k, v.filterPassed())) + self.msg.debug("Alg %s : %s", k, v.filterPassed()) pass response = bool(eval(self.cmd)) diff --git a/Event/EventKernel/CMakeLists.txt b/Event/EventKernel/CMakeLists.txt index 88b35e78eea6b9c4b60ca4195e89922b511ae2f1..9edbda24983f57fcc783f0ec04294ee6508bb7fe 100644 --- a/Event/EventKernel/CMakeLists.txt +++ b/Event/EventKernel/CMakeLists.txt @@ -26,4 +26,4 @@ atlas_add_dictionary( EventKernelDict LINK_LIBRARIES EventKernel ) # Install files from the package: -atlas_install_python_modules( python/__init__.py python/ParticleDataType.py ) +atlas_install_python_modules( python/__init__.py python/ParticleDataType.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/Event/FourMomUtils/CMakeLists.txt b/Event/FourMomUtils/CMakeLists.txt index c2daa8b5d117af7ddf7f7e9e4882a17bf6487e86..87b974f4fbbf505d83527346971fd671cee83071 100644 --- a/Event/FourMomUtils/CMakeLists.txt +++ b/Event/FourMomUtils/CMakeLists.txt @@ -39,4 +39,4 @@ atlas_add_dictionary( FourMomUtilsDict LINK_LIBRARIES FourMomUtils ) # Install files from the package: -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/Event/FourMomUtils/python/Bindings.py b/Event/FourMomUtils/python/Bindings.py index b752c20616082b143e6787cf69348acfe767556f..44192fc88b905f65f2182083e64d0b9b3aadb07d 100644 --- a/Event/FourMomUtils/python/Bindings.py +++ b/Event/FourMomUtils/python/Bindings.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # @file FourMomUtils/python/Bindings.py # @author Sebastien Binet <binet@cern.ch> @@ -12,7 +12,7 @@ def _installBindings(): import cppyy cppyy.load_library('liblibFourMomUtilsDict') - x = cppyy.gbl.xAOD.Helpers._importHelper() + x = cppyy.gbl.xAOD.Helpers._importHelper() # noqa: F841 return diff --git a/Event/PyDumper/CMakeLists.txt b/Event/PyDumper/CMakeLists.txt index b072c68b996bc4062db77b67592712a90a29cac9..5bd90b2b20ae560d1b7e81793b3e9b2b7bf19b3e 100644 --- a/Event/PyDumper/CMakeLists.txt +++ b/Event/PyDumper/CMakeLists.txt @@ -13,7 +13,7 @@ atlas_add_dictionary( PyDumperDictDict LINK_LIBRARIES AthContainers ) # Install files from the package: -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_scripts( bin/sg-dump.py ) # Aliases: diff --git a/Event/PyDumper/python/Dumpers.py b/Event/PyDumper/python/Dumpers.py index 3d2a63c20c3b4503e2407a81da1db11c57c39212..4a83826b58ffc60e36decff6a8001b388f29f7c5 100644 --- a/Event/PyDumper/python/Dumpers.py +++ b/Event/PyDumper/python/Dumpers.py @@ -19,7 +19,6 @@ __author__ = "Scott Snyder, Sebastien Binet" ### imports from contextlib import contextmanager -import math import sys from io import StringIO from functools import cmp_to_key @@ -33,7 +32,8 @@ from PyUtils.fprint import fprint, fprintln, fwrite import ROOT import cppyy -cmp = lambda x, y: (x > y) - (x < y) +def cmp(x, y): + return (x > y) - (x < y) # not available due to a reflex bug. etcone10 = 0 @@ -3090,7 +3090,7 @@ def dump_ExtendedVxCandidate (c, f): def dump_V0Hypothesis (h, f): - if h == None: + if h is None: fprint (f, None) return fprint (f, 'V0Hypothesis', h.positiveTrackID(), @@ -3668,7 +3668,7 @@ def dump_CaloTopoTowerContainer (t, f): dl(t.GetTowers()) dl(t.GetCells()) if t.GetCellToClusterMap(): - fprintln (f, ' ', GetCellToClusterMap().size()) + fprintln (f, ' ', t.GetCellToClusterMap().size()) else: fprintln (f, ' (null)') return @@ -3814,7 +3814,7 @@ def dump_TrigRNNOutput (p, f): def dump_InDetLowBetaCandidate (p, f): - if p == None: + if p is None: fprint (f, '(null)') return if hasattr (p, 'getTRTInverseBeta'): @@ -4714,9 +4714,9 @@ atomic_accessors = { def format_obj (x, name=None): - if type(x) == type(1.5): + if isinstance(x, float): return format_float (x) - if type(x) == type(1): + if isinstance(x, int): return format_int (x) tname = typename(type(x)) if tname.startswith ('ROOT.'): @@ -4855,7 +4855,7 @@ def dump_xAODObjectNL(o, f): def dump_list (l, f, dumper, nmax = None): i = 0 for x in l: - if nmax != None and i >= nmax: break + if nmax is not None and i >= nmax: break i += 1 fprint (f, ' ') dumper (x, f) diff --git a/Event/PyDumper/python/PyComps.py b/Event/PyDumper/python/PyComps.py index e13eedff6eebb6826be99ff63c7a17ccc7189ef4..7621415ad250b7d68273d056c82cf0a1fc2aa29e 100644 --- a/Event/PyDumper/python/PyComps.py +++ b/Event/PyDumper/python/PyComps.py @@ -3,7 +3,6 @@ # @file: PyDumper/python/PyComps.py # @purpose: A set of PyAthena components to test reading/writing EDM classes # @author: Sebastien Binet <binet@cern.ch> -# $Id: PyComps.py,v 1.11 2008-12-17 10:19:03 binet Exp $ __doc__ = 'A set of PyAthena components to test reading/writing EDM classes' __version__ = '$Revision: 1.11 $' @@ -11,7 +10,7 @@ __author__ = 'Sebastien Binet <binet@cern.ch>' import os from fnmatch import fnmatch -import AthenaCommon.SystemOfUnits as Units +from io import IOBase import AthenaPython.PyAthena as PyAthena from AthenaPython.PyAthena import StatusCode @@ -149,7 +148,7 @@ class PyReader (PyAthena.Alg): pass elif isinstance(self.ofile, str): self.ofile = open(self.ofile, 'w') - elif isinstance(self.ofile, file): + elif isinstance(self.ofile, IOBase): pass else: self.msg.error("don't know how to handle ofile value/type [%s/%s]!", @@ -261,7 +260,7 @@ class PySgDumper (PyAthena.Alg): pass elif isinstance(self.ofile, str): self.ofile = open(self.ofile, 'w') - elif isinstance(self.ofile, file): + elif isinstance(self.ofile, IOBase): pass else: self.msg.error("don't know how to handle ofile value/type [%s/%s]!", @@ -441,12 +440,8 @@ class DataProxyLoader(PyAthena.Alg): return StatusCode.Success def execute(self): - _debug= self.msg.debug - _info = self.msg.info - _warn = self.msg.warning - _fatal= self.msg.fatal _add_fail = self.failed_dumps.add - _info('==> processing event [%s]...', self._evt_nbr) + self.msg.info('==> processing event [%s]...', self._evt_nbr) self._evt_nbr += 1 if self.items is None: # take all from storegate @@ -466,13 +461,13 @@ class DataProxyLoader(PyAthena.Alg): for p in proxies: clid = p.clID() sgkey= p.name() - _debug('loading proxy [%s#%s]...', clid, sgkey) + self.msg.debug('loading proxy [%s#%s]...', clid, sgkey) try: dobj = p.accessData() if not dobj: all_good = False except Exception as err: - _fatal('problem loading proxy [%s#%s]', clid, sgkey) + self.msg.fatal('problem loading proxy [%s#%s]', clid, sgkey) _add_fail((sgkey, clid, str(err))) all_good = False diff --git a/Event/PyDumper/python/SgDumpLib.py b/Event/PyDumper/python/SgDumpLib.py index e1380d81380a2c8359da3777e2b0fea55d5c1142..85387d68d093d3219eae6db828172c02f80233c2 100644 --- a/Event/PyDumper/python/SgDumpLib.py +++ b/Event/PyDumper/python/SgDumpLib.py @@ -5,19 +5,13 @@ # @author Sebastien Binet <binet@cern.ch> # @date August 2009 -from __future__ import with_statement, print_function -import sys import os -from future import standard_library -standard_library.install_aliases() - __doc__ = """\ API for the sg-dump script (which dumps an ASCII representation of events in POOL or RAW files """ __author__ = "Sebastien Binet <binet@cern.ch>" -__version__= "$Revision$" __all__ = [ 'run_sg_dump', @@ -226,7 +220,7 @@ def _gen_jobo(dct): return job def _run_jobo(job, msg, options): - import os,atexit,tempfile,shutil,glob + import os,atexit,tempfile,shutil # capture current directory's content keep_files = [os.path.abspath(item) for item in os.listdir(os.getcwd())] @@ -275,7 +269,7 @@ def _run_jobo(job, msg, options): if options.use_recex_links: sc,out = subprocess.getstatusoutput ('RecExCommon_links.sh') if sc != 0: - msg.error("could not run 'RecExCommon_links.sh':\n%s"%out) + msg.error("could not run 'RecExCommon_links.sh':\n%s", out) return sc, out msg.info ('installed RecExCommon links') @@ -309,7 +303,7 @@ def _run_jobo(job, msg, options): stderr=logfile, env=env) pos = 0 - import time, re + import re pat = re.compile (r'^Py:pyalg .*') evt_pat = re.compile ( r'^Py:pyalg .*? ==> processing event \[(?P<evtnbr>\d*?)\].*' diff --git a/Event/xAOD/xAODBase/CMakeLists.txt b/Event/xAOD/xAODBase/CMakeLists.txt index 97c640fda79fad99ba7e6784d4c0f636712cfc9c..7ce6b21596a21f782d43554095a3d77c4929a5b8 100644 --- a/Event/xAOD/xAODBase/CMakeLists.txt +++ b/Event/xAOD/xAODBase/CMakeLists.txt @@ -36,7 +36,7 @@ atlas_add_dictionary( xAODBaseObjectTypeDict xAODBase/selection-ObjectType.xml ) # Install files from the package. -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) # Test(s) in the package. atlas_add_test( ut_xAODObjectType_test diff --git a/Event/xAOD/xAODEgamma/CMakeLists.txt b/Event/xAOD/xAODEgamma/CMakeLists.txt index ab77b70d752e335d5fc2cf7585dfee648a7452c0..7f4d9c75bd1aa000201f217a20f4cb3abb93688b 100644 --- a/Event/xAOD/xAODEgamma/CMakeLists.txt +++ b/Event/xAOD/xAODEgamma/CMakeLists.txt @@ -33,4 +33,4 @@ atlas_add_dictionary( xAODEgammaParametersDict xAODEgamma/selectionParameters.xml ) # Install files from the package. -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) diff --git a/Event/xAOD/xAODJetCnv/CMakeLists.txt b/Event/xAOD/xAODJetCnv/CMakeLists.txt index f03c03e7cb032bc17be34cf68f77f1ea264a74a5..edb816cb9717c1a1de2e1d1974e86cf33df4cd3d 100644 --- a/Event/xAOD/xAODJetCnv/CMakeLists.txt +++ b/Event/xAOD/xAODJetCnv/CMakeLists.txt @@ -16,6 +16,6 @@ atlas_add_component( xAODJetCnv LINK_LIBRARIES xAODJetCnvLib xAODJet GaudiKernel AthenaBaseComps AthenaKernel StoreGateLib SGtests JetEvent ) # Install files from the package: -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) atlas_install_joboptions( share/*.py ) diff --git a/Event/xAOD/xAODPrimitives/CMakeLists.txt b/Event/xAOD/xAODPrimitives/CMakeLists.txt index 5563fec425bfb0df96e6ecfb081952966c0f2292..ac725ffe4497b23b57aaf0c5598394da3b95a09e 100644 --- a/Event/xAOD/xAODPrimitives/CMakeLists.txt +++ b/Event/xAOD/xAODPrimitives/CMakeLists.txt @@ -20,4 +20,4 @@ atlas_add_test( ut_xAOD_primitives_enums_test LINK_LIBRARIES xAODPrimitives ) # Install files from the package. -atlas_install_python_modules( python/*.py ) +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )