Skip to content

Commit

Permalink
autopep8 action fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
souravpy authored Jan 10, 2024
1 parent 09c83ee commit c383271
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
27 changes: 17 additions & 10 deletions doc/fill_gpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Check failure on line 52 in doc/fill_gpi.py

View workflow job for this annotation

GitHub Actions / Linting

E741 ambiguous variable name 'l'


def reindent(docstring, depth=''):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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():
Expand All @@ -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))
Expand All @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions ganga/GangaCore/Utility/Runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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!",

Check failure on line 148 in ganga/GangaCore/Utility/Runtime.py

View workflow job for this annotation

GitHub Actions / Linting

E501 line too long (137 > 127 characters)
self.name,
self.modpath,
self.syspath)
else:
logger.debug(
"runtime package %s imported from %s", self.name, self.modpath)
Expand All @@ -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))
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions ganga/GangaCore/Utility/Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def setPath(self, name, var):
return True



def checkPythonVersion(minVersion, minHexVersion):

Check failure on line 141 in ganga/GangaCore/Utility/Setup.py

View workflow job for this annotation

GitHub Actions / Linting

E303 too many blank lines (3)
"""Function to check that the Python version number is greater
than the minimum required.
Expand Down
2 changes: 1 addition & 1 deletion ganga/GangaCore/test/GPI/TestStartUp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 4 additions & 7 deletions ganga/GangaCore/testlib/GangaUnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ganga/GangaDirac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
configDirac.addOption('default_unpackOutputSandbox', True, 'Unpack output sandboxes by default')


def standardSetup():
# def standardSetup():

from . import PACKAGE
PACKAGE.standardSetup()
Expand Down

0 comments on commit c383271

Please sign in to comment.