Skip to content
Snippets Groups Projects
Commit 996bddba authored by Marco Clemencic's avatar Marco Clemencic
Browse files

GaudiKernel: flake8 fixes

See merge request gaudi/Gaudi!1434
parents bdb84f5f b60ccd60
No related branches found
No related tags found
No related merge requests found
Showing with 75 additions and 63 deletions
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -295,7 +295,6 @@ class DotVisitor(object):
If AND nodes are inside AND nodes, the graph could be simplified
to not contain those (same true for OR and ordered)
"""
counter = 0
if len(self.stack) != 0:
mother = self.stack[-1][1]
for entry in self.stack[::-1]:
......
#####################################################################################
# (c) Copyright 1998-2021 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -15,7 +15,6 @@ from __future__ import absolute_import
import copy
import os
import string
import sys
import types
from inspect import isclass
......@@ -42,8 +41,14 @@ from GaudiKernel.Constants import (
WARNING,
error_explanation,
)
from GaudiKernel.DataHandle import *
from GaudiKernel.GaudiHandles import *
from GaudiKernel.DataHandle import DataHandle
from GaudiKernel.GaudiHandles import (
GaudiHandle,
GaudiHandleArray,
PrivateToolHandle,
PublicToolHandle,
ServiceHandle,
)
from GaudiKernel.PropertyProxy import PropertyProxy
# data ---------------------------------------------------------------------
......@@ -238,7 +243,7 @@ class Configurable(six.with_metaclass(ConfigurableMeta.ConfigurableMeta, object)
setattr(conf, n, v)
if (
not cls._configurationLocked
and not "_enabled" in kwargs
and "_enabled" not in kwargs
and isinstance(conf, ConfigurableUser)
):
# Ensure that the ConfigurableUser gets enabled if nothing is
......@@ -551,7 +556,7 @@ class Configurable(six.with_metaclass(ConfigurableMeta.ConfigurableMeta, object)
if type(items) != list and type(items) != tuple:
items = [items]
self.__children = [e for e in self.__children if not e in items]
self.__children = [e for e in self.__children if e not in items]
def removeAll(self):
self.remove(self.__children)
......@@ -743,7 +748,7 @@ class Configurable(six.with_metaclass(ConfigurableMeta.ConfigurableMeta, object)
# defaults from C++
for k, v in cls._properties.items():
if not k in c.__dict__ and hasattr(v, "default"):
if k not in c.__dict__ and hasattr(v, "default"):
c.__dict__[k] = v.default
return c.__dict__
......@@ -920,7 +925,7 @@ class Configurable(six.with_metaclass(ConfigurableMeta.ConfigurableMeta, object)
import __main__
for svc in svcs:
handle = __main__.Service(svc)
handle = __main__.Service(svc) # noqa: F841 (used in eval below)
# services should be configurables as well, but aren't for now
# handle.setup()
......@@ -932,7 +937,7 @@ class Configurable(six.with_metaclass(ConfigurableMeta.ConfigurableMeta, object)
dlls = self.getDlls()
if not dlls:
dlls = []
elif type(dlls) == types.StringType:
elif isinstance(dlls, types.StringType):
dlls = [dlls]
from __main__ import theApp
......@@ -1113,7 +1118,7 @@ class ConfigurableGeneric(Configurable):
return
# assume all the rest are properties
if not name in self._properties:
if name not in self._properties:
self._properties[name] = PropertyProxy(DummyDescriptor(name))
self._properties[name].__set__(self, value)
......@@ -1145,7 +1150,9 @@ class ConfigurableAlgorithm(Configurable):
return self # algorithms are always shared
def getHandle(self):
return iAlgorithm(self.getJobOptName())
return iAlgorithm( # noqa: F821 (to avoid circular dependeny)
self.getJobOptName()
)
@classmethod
def getGaudiType(cls):
......@@ -1197,6 +1204,7 @@ class ConfigurableAlgorithm(Configurable):
class ConfigurableService(Configurable):
__slots__ = {
"OutputLevel": 0,
"AuditServices": 0,
......@@ -1215,7 +1223,7 @@ class ConfigurableService(Configurable):
return child
def getHandle(self):
return iService(self._name)
return iService(self._name) # noqa: F821 (to avoid circular dependeny)
@classmethod
def getGaudiType(cls):
......@@ -1249,7 +1257,9 @@ class ConfigurableAlgTool(Configurable):
def getHandle(self):
# iAlgTool isn't useful, unless one knows for sure that the tool exists
return iProperty(self.getJobOptName())
return iProperty( # noqa: F821 (to avoid circular dependeny)
self.getJobOptName()
)
@classmethod
def getGaudiType(cls):
......@@ -1330,7 +1340,9 @@ class ConfigurableAuditor(Configurable):
def getHandle(self):
# iAlgTool isn't useful, unless one knows for sure that the tool exists
return iProperty(self.getJobOptName())
return iProperty( # noqa: F821 (to avoid circular dependeny)
self.getJobOptName()
)
@classmethod
def getGaudiType(cls):
......@@ -1572,7 +1584,7 @@ def appendPostConfigAction(function):
"""
try:
postConfigActions.remove(function)
except:
except Exception:
pass
postConfigActions.append(function)
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -122,8 +122,6 @@ def loadConfigurableDb():
informations about Configurables
"""
import os
import sys
from glob import glob
from os.path import join as path_join
log.debug("loading confDb files...")
......
#####################################################################################
# (c) Copyright 1998-2022 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -23,8 +23,6 @@ __all__ = [
]
__doc__ = """The python module holding python bindings to XyzHandles"""
from os import linesep
class GaudiHandle(object):
componentType = "Unspecified" # must be overridden by derived class
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -50,7 +50,7 @@
# 08.07.20 Updated
# -----
from GaudiKernel.SystemOfUnits import *
import GaudiKernel.SystemOfUnits as Units
#
#
......@@ -63,13 +63,13 @@ pi2 = pi * pi
#
#
#
Avogadro = 6.0221367e23 / mole
Avogadro = 6.0221367e23 / Units.mole
#
# c = 299.792458 mm/ns
# c^2 = 898.7404 (mm/ns)^2
#
c_light = 2.99792458e8 * m / s
c_light = 2.99792458e8 * Units.m / Units.s
c_squared = c_light * c_light
#
......@@ -77,7 +77,7 @@ c_squared = c_light * c_light
# hbar = 6.58212e-13 MeV*ns
# hbarc = 197.32705e-12 MeV*mm
#
h_Planck = 6.62606896e-34 * joule * s
h_Planck = 6.62606896e-34 * Units.joule * Units.s
hbar_Planck = h_Planck / twopi
hbarc = hbar_Planck * c_light
hbarc_squared = hbarc * hbarc
......@@ -85,24 +85,24 @@ hbarc_squared = hbarc * hbarc
#
#
#
electron_charge = -eplus # see SystemOfUnits.h
e_squared = eplus * eplus
electron_charge = -Units.eplus # see SystemOfUnits.h
e_squared = Units.eplus * Units.eplus
#
# amu_c2 - atomic equivalent mass unit
# amu - atomic mass unit
#
electron_mass_c2 = 0.510998910 * MeV
proton_mass_c2 = 938.272013 * MeV
neutron_mass_c2 = 939.56536 * MeV
amu_c2 = 931.494028 * MeV
electron_mass_c2 = 0.510998910 * Units.MeV
proton_mass_c2 = 938.272013 * Units.MeV
neutron_mass_c2 = 939.56536 * Units.MeV
amu_c2 = 931.494028 * Units.MeV
amu = amu_c2 / c_squared
#
# permeability of free space mu0 = 2.01334e-16 Mev*(ns*eplus)^2/mm
# permittivity of free space epsil0 = 5.52636e+10 eplus^2/(MeV*mm)
#
mu0 = 4 * pi * 1.0e-7 * henry / m
mu0 = 4 * pi * 1.0e-7 * Units.henry / Units.m
epsilon0 = 1.0 / (c_squared * mu0)
#
......@@ -122,16 +122,16 @@ twopi_mc2_rcl2 = (
#
#
#
k_Boltzmann = 8.617343e-11 * MeV / kelvin
k_Boltzmann = 8.617343e-11 * Units.MeV / Units.kelvin
#
#
#
STP_Temperature = 273.15 * kelvin
STP_Pressure = 1.0 * atmosphere
kGasThreshold = 10.0 * mg / cm3
STP_Temperature = 273.15 * Units.kelvin
STP_Pressure = 1.0 * Units.atmosphere
kGasThreshold = 10.0 * Units.mg / Units.cm3
#
#
#
universe_mean_density = 1.0e-25 * g / cm3
universe_mean_density = 1.0e-25 * Units.g / Units.cm3
#####################################################################################
# (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -19,7 +19,7 @@ import logging
import os
from GaudiKernel.DataHandle import DataHandle
from GaudiKernel.GaudiHandles import *
from GaudiKernel.GaudiHandles import GaudiHandle, GaudiHandleArray
from GaudiKernel import ConfigurableDb
......@@ -137,7 +137,7 @@ class PropertyProxy(object):
# binding (if ever done)
if (
proptype
and proptype != type(None)
and not isinstance(None, proptype)
and not derives_from(value, "PropertyReference")
):
try:
......@@ -166,9 +166,9 @@ class PropertyProxy(object):
# allow a property to be set if we're in non-default mode, or if it
# simply hasn't been set before
if not obj._isInSetDefaults() or not obj in self.history:
if not obj._isInSetDefaults() or obj not in self.history:
# by convention, 'None' for default is used to designate objects setting
if hasattr(self, "default") and self.default == None:
if hasattr(self, "default") and self.default is None:
obj.__iadd__(value, self.descr) # to establish hierarchy
else:
self.descr.__set__(obj, value)
......@@ -226,7 +226,7 @@ class GaudiHandlePropertyProxyBase(PropertyProxy):
def __set__(self, obj, value):
# allow a property to be set if we're in non-default mode, or if it
# simply hasn't been set before
if not obj._isInSetDefaults() or not obj in self.history:
if not obj._isInSetDefaults() or obj not in self.history:
value = self.convertValueToBeSet(obj, value)
# assign the value
self.descr.__set__(obj, value)
......@@ -442,7 +442,7 @@ class DataHandlePropertyProxy(PropertyProxy):
return self.descr.__get__(obj, type)
def __set__(self, obj, value):
if not obj._isInSetDefaults() or not obj in self.history:
if not obj._isInSetDefaults() or obj not in self.history:
value = self.convertValueToBeSet(obj, value)
# assign the value
self.descr.__set__(obj, value)
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -39,6 +39,6 @@ import sys
sys.modules["GaudiKernel.Proxy.Configurable"] = Configurable
sys.modules["GaudiKernel.Proxy.ConfigurableDb"] = ConfigurableDb
import GaudiKernel.Proxy.Configurable
import GaudiKernel.Proxy.ConfigurableDb
import GaudiKernel.Proxy.ConfigurableDb # noqa: F401
del sys
#!/usr/bin/env python3
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -98,7 +98,7 @@ def getMaps(pathstring="", sysrtmap=False):
rtmpfile = os.path.join(p, f)
if os.path.exists(rtmpfile):
_procRootMap(rtmpfile, rtmapdict)
except:
except Exception:
pass
return rtmapdict
......
#!/usr/bin/env python3
#####################################################################################
# (c) Copyright 1998-2020 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -244,7 +244,7 @@ def main():
import Gaudi.Configurables
Gaudi.Configurables.ignoreMissingConfigurables = True
except:
except ImportError:
pass
# load configurables database to avoid fake duplicates
loadConfigurableDb(opts.build_dir, opts.project_name)
......@@ -260,7 +260,7 @@ def main():
# Extend the search path of the package module to find the configurables
package_module = __import__(package_name)
package_module.__path__.insert(0, os.path.join(genConfDir, package_name))
except:
except Exception:
pass # ignore failures (not important)
# Collecting ConfigurableUser specializations
......
#!/usr/bin/env python3
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -15,7 +15,7 @@ import os
import re
import sys
from fnmatch import fnmatch
from subprocess import PIPE, STDOUT, Popen
from subprocess import PIPE, Popen
def command(cmd, *args, **kwargs):
......@@ -30,9 +30,16 @@ def command(cmd, *args, **kwargs):
return proc.communicate()
cmt = lambda *args, **kwargs: command("cmt", *args, **kwargs)
cvs = lambda *args, **kwargs: command("cvs", *args, **kwargs)
svn = lambda *args, **kwargs: command("svn", *args, **kwargs)
def cmt(*args, **kwargs):
return command("cmt", *args, **kwargs)
def cvs(*args, **kwargs):
return command("cvs", *args, **kwargs)
def svn(*args, **kwargs):
return command("svn", *args, **kwargs)
def broadcast_packages():
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -8,7 +8,6 @@
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
#####################################################################################
from GaudiConfig.ControlFlow import *
from GaudiKernel.Configurable import Configurable
from test_Configurables import MyAlg
......
#####################################################################################
# (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations #
# (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations #
# #
# This software is distributed under the terms of the Apache version 2 licence, #
# copied verbatim in the file "LICENSE". #
......@@ -8,7 +8,6 @@
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
#####################################################################################
import os
from platform import processor
from subprocess import PIPE, Popen
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment