From 7080739daf8bb0722c6f3ce948a014af23d7289a Mon Sep 17 00:00:00 2001 From: souravpy Date: Wed, 10 Jan 2024 17:10:16 +0000 Subject: [PATCH] autopep8 action fixes --- doc/fill_gpi.py | 27 +++++++++++++++--------- ganga/GangaCore/Utility/Runtime.py | 13 +++++++----- ganga/GangaCore/Utility/Setup.py | 1 + ganga/GangaCore/test/GPI/TestStartUp.py | 2 +- ganga/GangaCore/testlib/GangaUnitTest.py | 11 ++++------ ganga/GangaDirac/__init__.py | 2 +- ganga/GangaGaudi/__init__.py | 18 ++++++++-------- ganga/GangaLHCb/__init__.py | 10 ++++----- ganga/GangaND280/BOOT.py | 5 ++--- ganga/GangaTest/Framework/runner.py | 14 ++++++------ 10 files changed, 55 insertions(+), 48 deletions(-) diff --git a/doc/fill_gpi.py b/doc/fill_gpi.py index 0f7161d19c..aed4102252 100755 --- a/doc/fill_gpi.py +++ b/doc/fill_gpi.py @@ -49,7 +49,7 @@ def indent(s, depth=''): """ Adds `indent` to the beginning of every line """ - return '\n'.join(depth+l for l in s.splitlines()) + return '\n'.join(depth + l for l in s.splitlines()) def reindent(docstring, depth=''): @@ -84,23 +84,29 @@ def signature(func, name=None): for arg, default in arg_pairs: full_arg = arg if default is not None: - full_arg += '='+default + full_arg += '=' + default arg_strings.append(full_arg) # and append args and kwargs if necessary to get # arg_strings=['a', 'b', 'a=None', 'd=4', '*args', '**kwargs'] if varargs is not None: - arg_strings.append('*'+varargs) + arg_strings.append('*' + varargs) if varkw is not None: - arg_strings.append('**'+varkw) + arg_strings.append('**' + varkw) # Signature is then 'foo(a, b, c=None, d=4, *args, **kwargs)' return '{name}({args})'.format(name=name or func.__name__, args=', '.join(arg_strings)) # First we get all objects that are in Ganga.GPI and filter out any non-GangaObjects -gpi_classes = [stripProxy(o) for name, o in GangaCore.GPI.__dict__.items() if isinstance(o, type) and issubclass(o, GPIProxyObject)] +gpi_classes = [ + stripProxy(o) for name, + o in GangaCore.GPI.__dict__.items() if isinstance( + o, + type) and issubclass( + o, + GPIProxyObject)] -with open(doc_dir+'/GPI/classes.rst', 'w') as cf: +with open(doc_dir + '/GPI/classes.rst', 'w') as cf: print('GPI classes', file=cf) print('===========', file=cf) @@ -154,7 +160,7 @@ def signature(func, name=None): # Looking through the plugin list helps categorise the GPI objects -with open(doc_dir+'/GPI/plugins.rst', 'w') as pf: +with open(doc_dir + '/GPI/plugins.rst', 'w') as pf: from GangaCore.Utility.Plugin.GangaPlugin import allPlugins print('Plugins', file=pf) @@ -163,7 +169,7 @@ def signature(func, name=None): for c, ps in allPlugins.allCategories().items(): print(c, file=pf) - print('-'*len(c), file=pf) + print('-' * len(c), file=pf) print('', file=pf) for name, c in ps.items(): @@ -175,7 +181,8 @@ def signature(func, name=None): print('') # All objects that are not proxied GangaObjects -gpi_objects = dict((name, stripProxy(o)) for name, o in GangaCore.GPI.__dict__.items() if stripProxy(o) not in gpi_classes and not name.startswith('__')) +gpi_objects = dict((name, stripProxy(o)) for name, o in GangaCore.GPI.__dict__.items() + if stripProxy(o) not in gpi_classes and not name.startswith('__')) # Any objects which are not exposed as proxies (mostly exceptions) non_proxy_classes = dict((k, v) for k, v in gpi_objects.items() if inspect.isclass(v)) @@ -186,7 +193,7 @@ def signature(func, name=None): # Things which were declared as actual functions functions = dict((k, v) for k, v in callables.items() if inspect.isfunction(v) or inspect.ismethod(v)) -with open(doc_dir+'/GPI/functions.rst', 'w') as ff: +with open(doc_dir + '/GPI/functions.rst', 'w') as ff: print('Functions', file=ff) print('=========', file=ff) diff --git a/ganga/GangaCore/Utility/Runtime.py b/ganga/GangaCore/Utility/Runtime.py index fdf591e85c..75b1ccb258 100644 --- a/ganga/GangaCore/Utility/Runtime.py +++ b/ganga/GangaCore/Utility/Runtime.py @@ -17,7 +17,7 @@ from GangaCore.Utility.util import importName -#from GangaCore.Utility.external.ordereddict import oDict +# from GangaCore.Utility.external.ordereddict import oDict from GangaCore.Utility.external.OrderedDict import OrderedDict as oDict allRuntimes = oDict() @@ -64,7 +64,7 @@ def getScriptPath(name="", searchPath=""): def getSearchPath(configPar="SCRIPTS_PATH"): """Determine search path from configuration parameter - Argument: + Argument: configPar : Name of configuration parameter defining search path Return value: Search path""" @@ -145,7 +145,10 @@ def __init__(self, path): if self.syspath: if self.modpath.find(self.syspath) == -1: logger.warning( - "runtime '%s' imported from '%s' but specified path is '%s'. You might be getting different code than expected!", self.name, self.modpath, self.syspath) + "runtime '%s' imported from '%s' but specified path is '%s'. You might be getting different code than expected!", + self.name, + self.modpath, + self.syspath) else: logger.debug( "runtime package %s imported from %s", self.name, self.modpath) @@ -154,7 +157,7 @@ def __init__(self, path): # @see Ganga/PACKAGE.py for description of this magic module # in this way we enforce any initialization of module is performed # (e.g PackageSetup.setPlatform() is called) - __import__(self.name + ".PACKAGE") + # __import__(self.name + ".PACKAGE") except ImportError as x: logger.warning("cannot import runtime package %s: %s", self.name, str(x)) @@ -204,7 +207,7 @@ def loadNamedTemplates(self, globals, file_ext='tpl', pickle_files=False): 'Ganga'), file_ext=file_ext, pickle_files=pickle_files) - except: + except BaseException: logger.debug('failed to load named template registry') raise diff --git a/ganga/GangaCore/Utility/Setup.py b/ganga/GangaCore/Utility/Setup.py index 7e1c588534..a252cdb007 100644 --- a/ganga/GangaCore/Utility/Setup.py +++ b/ganga/GangaCore/Utility/Setup.py @@ -137,6 +137,7 @@ def setPath(self, name, var): return True + def checkPythonVersion(minVersion, minHexVersion): """Function to check that the Python version number is greater than the minimum required. diff --git a/ganga/GangaCore/test/GPI/TestStartUp.py b/ganga/GangaCore/test/GPI/TestStartUp.py index 80ecd9ed33..be7cef9e84 100644 --- a/ganga/GangaCore/test/GPI/TestStartUp.py +++ b/ganga/GangaCore/test/GPI/TestStartUp.py @@ -48,7 +48,7 @@ def testStartUp(): assert os.path.isfile(os.path.join(homeDir, this_file)) # No way known to mimic IPython starting up in a simple way - #assert os.path.isdir(os.path.join(homeDir, '.ipython-ganga')) + # assert os.path.isdir(os.path.join(homeDir, '.ipython-ganga')) for this_folder in ['repository', ]: assert os.path.isdir(os.path.join(this_dir, this_folder)) diff --git a/ganga/GangaCore/testlib/GangaUnitTest.py b/ganga/GangaCore/testlib/GangaUnitTest.py index 7b8aa17df6..1ac20a5284 100644 --- a/ganga/GangaCore/testlib/GangaUnitTest.py +++ b/ganga/GangaCore/testlib/GangaUnitTest.py @@ -70,9 +70,6 @@ def start_ganga(gangadir_for_test, repositorytype="LocalXML", extra_opts=[], ext extra_opts (list): A list of tuples which are used to pass command line style options to Ganga """ - import GangaCore.PACKAGE - GangaCore.PACKAGE.standardSetup() - # End taken from the ganga binary import GangaCore.Runtime @@ -206,17 +203,17 @@ def emptyRepositories(): for j in jobs: try: j.remove() - except: + except BaseException: pass for t in templates: try: t.remove() - except: + except BaseException: pass for t in tasks: try: t.remove(remove_jobs=True) - except: + except BaseException: pass if hasattr(jobs, 'clean'): jobs.clean(confirm=True, force=True) @@ -258,7 +255,7 @@ def stop_ganga(force_cleanup=False): logger.info("Shutting Down Internal Services") # Disable internal services such as monitoring and other tasks - #from GangaCore.Core.InternalServices import Coordinator + # from GangaCore.Core.InternalServices import Coordinator # if Coordinator.servicesEnabled: # Coordinator.disableInternalServices() # Coordinator.servicesEnabled = False diff --git a/ganga/GangaDirac/__init__.py b/ganga/GangaDirac/__init__.py index d87b930619..7b9698b3f1 100755 --- a/ganga/GangaDirac/__init__.py +++ b/ganga/GangaDirac/__init__.py @@ -156,7 +156,7 @@ configDirac.addOption('default_unpackOutputSandbox', True, 'Unpack output sandboxes by default') -def standardSetup(): +# def standardSetup(): from . import PACKAGE PACKAGE.standardSetup() diff --git a/ganga/GangaGaudi/__init__.py b/ganga/GangaGaudi/__init__.py index b1df0fa859..3e78186181 100644 --- a/ganga/GangaGaudi/__init__.py +++ b/ganga/GangaGaudi/__init__.py @@ -9,7 +9,7 @@ if not _after_bootstrap: configGaudi = GangaCore.Utility.Config.makeConfig( - 'GAUDI', 'Generic GAUDI based parameters') + 'GAUDI', 'Generic GAUDI based parameters') dscrpt = 'The command used to make a CMT application.' configGaudi.addOption('make_cmd', 'make', dscrpt) @@ -18,18 +18,18 @@ configGaudi.addOption('pyFileCollectionDepth', 2, dscrpt) -def standardSetup(): +# def standardSetup(): from . import PACKAGE PACKAGE.standardSetup() def loadPlugins(config=None): - #import Lib.Backends - #import Lib.Checkers + # import Lib.Backends + # import Lib.Checkers pass - #import Lib.Applications - #import Lib.RTHandlers - #import Lib.Datasets - #import Lib.Datafiles - #import Lib.Splitters + # import Lib.Applications + # import Lib.RTHandlers + # import Lib.Datasets + # import Lib.Datafiles + # import Lib.Splitters diff --git a/ganga/GangaLHCb/__init__.py b/ganga/GangaLHCb/__init__.py index 6a0239b5dd..626d897638 100755 --- a/ganga/GangaLHCb/__init__.py +++ b/ganga/GangaLHCb/__init__.py @@ -94,7 +94,7 @@ def _store_root_version(): # _store_root_version() -def standardSetup(): +# def standardSetup(): from . import PACKAGE PACKAGE.standardSetup() @@ -150,10 +150,10 @@ def postBootstrapHook(): # # This will be nice to re-add once there is lazy loading support passed to the display for the 'jobs' command 09/2015 rcurrie # -#from GangaCore.GPIDev.Lib.Registry.JobRegistry import config as display_config -#display_config.setSessionValue( 'jobs_columns', ('fqid', 'status', 'name', 'subjobs', 'application', 'backend', 'backend.actualCE', 'backend.extraInfo', 'comment') ) -#display_config.setSessionValue( 'jobs_columns_functions', {'comment': 'lambda j: j.comment', 'backend.extraInfo': 'lambda j : j.backend.extraInfo ', 'subjobs': 'lambda j: len(j.subjobs)', 'backend.actualCE': 'lambda j:j.backend.actualCE', 'application': 'lambda j: j.application._name', 'backend': 'lambda j:j.backend._name'} ) -#display_config.setSessionValue('jobs_columns_width', {'fqid': 8, 'status': 10, 'name': 10, 'application': 15, 'backend.extraInfo': 30, 'subjobs': 8, 'backend.actualCE': 17, 'comment': 20, 'backend': 15} ) +# from GangaCore.GPIDev.Lib.Registry.JobRegistry import config as display_config +# display_config.setSessionValue( 'jobs_columns', ('fqid', 'status', 'name', 'subjobs', 'application', 'backend', 'backend.actualCE', 'backend.extraInfo', 'comment') ) +# display_config.setSessionValue( 'jobs_columns_functions', {'comment': 'lambda j: j.comment', 'backend.extraInfo': 'lambda j : j.backend.extraInfo ', 'subjobs': 'lambda j: len(j.subjobs)', 'backend.actualCE': 'lambda j:j.backend.actualCE', 'application': 'lambda j: j.application._name', 'backend': 'lambda j:j.backend._name'} ) +# display_config.setSessionValue('jobs_columns_width', {'fqid': 8, 'status': 10, 'name': 10, 'application': 15, 'backend.extraInfo': 30, 'subjobs': 8, 'backend.actualCE': 17, 'comment': 20, 'backend': 15} ) from GangaCore.Core.GangaThread.WorkerThreads import getQueues queue = getQueues() diff --git a/ganga/GangaND280/BOOT.py b/ganga/GangaND280/BOOT.py index d0c915b1db..86183acef6 100644 --- a/ganga/GangaND280/BOOT.py +++ b/ganga/GangaND280/BOOT.py @@ -1,9 +1,8 @@ def getEnvironment(c): - from . import PACKAGE - PACKAGE.standardSetup() + # from . import PACKAGE + # PACKAGE.standardSetup() return {} def loadPlugins(c): pass - diff --git a/ganga/GangaTest/Framework/runner.py b/ganga/GangaTest/Framework/runner.py index f94fa85f78..b00c826e98 100644 --- a/ganga/GangaTest/Framework/runner.py +++ b/ganga/GangaTest/Framework/runner.py @@ -55,7 +55,7 @@ # search for local tests lookup myConfig.addOption('SearchLocalTests', True, 'search for local tests lookup') # search for tests packaged in release (PACKAGE/old_test dir) lookup -myConfig.addOption('SearchReleaseTests', True, 'search for tests packaged in release (PACKAGE/old_test dir) lookup') +# myConfig.addOption('SearchReleaseTests', True, 'search for tests packaged in release (PACKAGE/old_test dir) lookup') # Coverage output myConfig.addOption('CoverageReport', '', 'The file used to save the testing coverage statistics') @@ -94,10 +94,10 @@ def start(config=myConfig, test_selection='GangaCore.test.*', logger=myLogger): """ """ import os - #rtconfig = getConfig('TestingFramework') + # rtconfig = getConfig('TestingFramework') my_full_path = os.path.abspath(os.path.dirname(__file__)) - #sys.stdout = UnbufferedStdout(sys.stdout) - #sys.stderr = UnbufferedStdout(sys.stderr) + # sys.stdout = UnbufferedStdout(sys.stdout) + # sys.stderr = UnbufferedStdout(sys.stderr) # configure Ganga TestLoader @@ -117,7 +117,7 @@ def start(config=myConfig, test_selection='GangaCore.test.*', logger=myLogger): # loader args pytf_loader_args = [] pytf_loader_args.append('--loader-args=%s' % config['Config']) - #pytf_loader_args.append( '--loader-args=%s/python' % gangaReleaseTopDir) + # pytf_loader_args.append( '--loader-args=%s/python' % gangaReleaseTopDir) pytf_loader_args.append('--loader-args=%s' % gangaReleaseTopDir) pytf_loader_args.append('--loader-args=%s' % int(config['ReleaseTesting'])) # output_dir @@ -131,7 +131,7 @@ def start(config=myConfig, test_selection='GangaCore.test.*', logger=myLogger): # pass the schmema version (if any) to test pytf_loader_args.append('--loader-args=%s' % config['SchemaTesting']) - #print("PYTF path %s config: %s" % (pytf_loader_path, pytf_loader_args)) + # print("PYTF path %s config: %s" % (pytf_loader_path, pytf_loader_args)) import sys sys.path.append(os.getenv('PYTF_TOP_DIR', '').split(':')[0]) sys.path.append(os.path.join(os.getenv('PYTF_TOP_DIR', '').split(':')[0], 'pytf')) @@ -145,7 +145,7 @@ def start(config=myConfig, test_selection='GangaCore.test.*', logger=myLogger): try: rc = runTests.main(logger, runner_args) - except: + except BaseException: rc = -9999 return rc