From cfdd228e53e1b55d56855375950f0814203f5854 Mon Sep 17 00:00:00 2001 From: Sebastian Neumann Date: Tue, 14 Nov 2023 15:51:22 +0100 Subject: [PATCH] Add Zuul job python-black and format Python files Signed-off-by: Sebastian Neumann --- .zuul.yaml | 3 +++ main.py | 21 +++++++++++--------- output/conf.py | 52 +++++++++++++++++++++++--------------------------- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 8e65d71..b5cc012 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -6,11 +6,14 @@ jobs: - flake8 - hadolint + - python-black gate: jobs: - flake8 - hadolint + - python-black periodic-daily: jobs: - flake8 - hadolint + - python-black diff --git a/main.py b/main.py index a848803..5a551b1 100644 --- a/main.py +++ b/main.py @@ -23,15 +23,12 @@ template_service = environment.get_template("service.j2") fp = open(f"/output/{SERVICE}.rst", "w+") - template_data = { - "name": SERVICE, - "sections": sorted(groups.keys()) - } + template_data = {"name": SERVICE, "sections": sorted(groups.keys())} fp.write(template_service.render(template_data)) template = environment.get_template("confval.j2") for name, data in groups.items(): - _, options = data['namespaces'][0] + _, options = data["namespaces"][0] if not options: next @@ -44,7 +41,10 @@ option_type = "Boolean" elif isinstance(option.type, types.Integer): if option.type.min and option.type.max: - option_type = "Integer, ``>= %d``, ``<= %d``" % (option.type.min, option.type.max) + option_type = "Integer, ``>= %d``, ``<= %d``" % ( + option.type.min, + option.type.max, + ) elif option.type.min: option_type = "Integer, ``>= %d``" % option.type.min elif option.type.max: @@ -53,7 +53,10 @@ option_type = "Integer" elif isinstance(option.type, types.Float): if option.type.min and option.type.max: - option_type = "Float, ``>= %.2f``, <= ``%.2f``" % (option.type.min, option.type.max) + option_type = "Float, ``>= %.2f``, <= ``%.2f``" % ( + option.type.min, + option.type.max, + ) elif option.type.min: option_type = "Float, ``>= %.2f``" % option.type.min elif option.type.max: @@ -77,8 +80,8 @@ fp = open(f"/output/{SERVICE}-{name}.rst", "w+") template_data = { "name": name, - "options": sorted(options, key=attrgetter('name')), - "types": option_types + "options": sorted(options, key=attrgetter("name")), + "types": option_types, } fp.write(template.render(template_data)) diff --git a/output/conf.py b/output/conf.py index 28cdbdf..4a78cfc 100644 --- a/output/conf.py +++ b/output/conf.py @@ -1,38 +1,34 @@ -extensions = [ - 'sphinx_toolbox.confval' -] -source_suffix = '.rst' -master_doc = 'index' -project = u'Reference' -copyright = u'2021-2023, OSISM GmbH' -author = u'OSISM GmbH' -version = u'' -release = u'' -language = 'en' +extensions = ["sphinx_toolbox.confval"] +source_suffix = ".rst" +master_doc = "index" +project = "Reference" +copyright = "2021-2023, OSISM GmbH" +author = "OSISM GmbH" +version = "" +release = "" +language = "en" exclude_patterns = [] -pygments_style = 'sphinx' +pygments_style = "sphinx" todo_include_todos = True -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" html_show_sphinx = False html_show_sourcelink = False html_show_copyright = True -htmlhelp_basename = 'documentation' +htmlhelp_basename = "documentation" html_theme_options = { - 'display_version': False, - 'canonical_url': 'https://docs.osism.tech/reference/', - 'style_external_links': True, - 'logo_only': True, - 'prev_next_buttons_location': None + "display_version": False, + "canonical_url": "https://docs.osism.tech/reference/", + "style_external_links": True, + "logo_only": True, + "prev_next_buttons_location": None, } html_context = { - 'display_github': True, - 'github_user': 'osism', - 'github_repo': 'openstack-configuration-reference', - 'github_version': 'main', - 'conf_py_path': '/output/' + "display_github": True, + "github_user": "osism", + "github_repo": "openstack-configuration-reference", + "github_version": "main", + "conf_py_path": "/output/", } -html_logo = 'images/logo.png' -html_static_path = [ - '_static' -] +html_logo = "images/logo.png" +html_static_path = ["_static"] latex_elements = {}