Skip to content

Commit

Permalink
Client: protect documentation generation against py3
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Jun 29, 2021
1 parent 54ea9a2 commit 12b8f69
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/DIRAC/Core/Base/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def __get__(self, instance, owner):
)

import importlib_resources

try:
FileNotFoundError = FileNotFoundError
except NameError:
FileNotFoundError = OSError


import six

from DIRAC.Core.Tornado.Client.ClientSelector import RPCClientSelector
Expand All @@ -36,6 +43,7 @@ def __get__(self, instance, owner):

class partialmethodWithDoc(partialmethod):
"""Extension of meth:`functools.partialmethod` that preserves docstrings"""

def __get__(self, instance, owner):
func = super(partialmethodWithDoc, self).__get__(instance, owner)
func.__doc__ = self.__doc__
Expand Down Expand Up @@ -169,11 +177,11 @@ def addFunctions(clientCls):
"%s.%sSystem.Service" % (extension, systemName),
"%s.py" % handlerModuleName,
)
except (ImportError, OSError):
fullHandlerClassPath = '%s.%s' % (extension, handlerClassPath)
with path as fp:
handlerAst = ast.parse(fp.read_text(), str(path))
except (ImportError, OSError, FileNotFoundError):
continue
fullHandlerClassPath = '%s.%s' % (extension, handlerClassPath)
with path as fp:
handlerAst = ast.parse(fp.read_text(), str(path))

# loop over all the nodes (classes, functions, imports) in the handlerModule
for node in ast.iter_child_nodes(handlerAst):
Expand Down

0 comments on commit 12b8f69

Please sign in to comment.