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*?)\].*'