diff --git a/.github/workflows/api-documentation.yml b/.github/workflows/api-documentation.yml index 80a3c1e3a..5e9337c5f 100644 --- a/.github/workflows/api-documentation.yml +++ b/.github/workflows/api-documentation.yml @@ -18,17 +18,15 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [2.7] + python-version: [3.12] steps: - uses: actions/checkout@v4 - name: Set up Python - # setup-python stopped supporting Python 2.7, use https://github.com/MatteoH2O1999/setup-python - uses: MatteoH2O1999/setup-python@v3.2.1 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - allow-build: info - cache-build: true + architecture: x64 - name: Install dependencies run: | diff --git a/tools/api/generate-openapi.py b/tools/api/generate-openapi.py index b922b86e1..672a8991e 100755 --- a/tools/api/generate-openapi.py +++ b/tools/api/generate-openapi.py @@ -12,24 +12,23 @@ This module imports (and therefore executes) ruleset code. Do not run it on untrusted codebases. """ -from __future__ import print_function __copyright__ = 'Copyright (c) 2020-2024, Utrecht University' __license__ = 'GPLv3, see LICENSE' -__author__ = ('Chris Smeele') -__author__ = ('Lazlo Westerhof') +__author__ = ('Chris Smeele') +__author__ = ('Lazlo Westerhof') # (in alphabetical order) -import sys -import re +import argparse import inspect import json - -from importlib import import_module +import re +import sys from collections import OrderedDict +from importlib import import_module -import argparse +sys.path.extend(['./rules_uu', './rules_uu/util']) parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('ruleset', metavar='RULESET', type=str, @@ -44,6 +43,7 @@ core = args.core module = args.module + # Strategy: Import the requested ruleset with an instrumented environment, and # apply introspection to extract API function information. @@ -55,9 +55,15 @@ class Sandbag(object): Used as a stub for various internal irods modules so that we can import rulesets without errors. """ - def __init__(self, *_, **kw): self._data = kw - def __call__(self, *_, **__): return Sandbag() - def __getattr__(self, k): return self._data.get(k, Sandbag()) + def __init__(self, *_, **kw): + self._data = kw + + def __call__(self, *_, **__): + return Sandbag() + + def __getattr__(self, k): + return self._data.get(k, Sandbag()) + def __setattr__(self, k, v): if k == '_data': return super(Sandbag, self).__setattr__(k, v) @@ -80,6 +86,7 @@ def f(g): return g return f + # Inject iRODS modules. sys.modules['irods_types'] = Sandbag() sys.modules['genquery'] = Sandbag()