diff --git a/.docs/macros/includes/main.py b/.docs/macros/includes/main.py index 07f6e6e1c..332abd794 100644 --- a/.docs/macros/includes/main.py +++ b/.docs/macros/includes/main.py @@ -10,13 +10,15 @@ GitHub branch/tag URL replacer regex = r"(github\.com/.+/rook/.+)/master/" subst = "\\1/%s/" + def define_env(env): - repo = Repository('.') + repo = Repository(".") if repo is not None: target = repo.head.shorthand - env.variables['current_branch'] = target + env.variables["current_branch"] = target + def on_post_page_macros(env): """ @@ -24,8 +26,8 @@ def on_post_page_macros(env): with the correct one that is currently active. """ - target = env.variables['current_branch'] - if target == 'master': + target = env.variables["current_branch"] + if target == "master": return env.raw_markdown = re.sub(regex, subst % target, env.raw_markdown, 0) diff --git a/tests/scripts/pythonwebserver/server.py b/tests/scripts/pythonwebserver/server.py index d2b1459e3..a9c359001 100644 --- a/tests/scripts/pythonwebserver/server.py +++ b/tests/scripts/pythonwebserver/server.py @@ -1,4 +1,4 @@ -''' +""" Copyright 2022 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,7 +12,7 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -''' +""" #!/usr/bin/env python3 """ Very simple HTTP server in python for logging requests @@ -22,30 +22,35 @@ Usage:: from http.server import BaseHTTPRequestHandler, HTTPServer import logging + class S(BaseHTTPRequestHandler): def _set_response(self): self.send_response(200) - self.send_header('Content-type', 'text/html') + self.send_header("Content-type", "text/html") self.end_headers() def do_POST(self): - content_length = int(self.headers['Content-Length']) # <--- Gets the size of data - post_data = self.rfile.read(content_length) # <--- Gets the data itself - logging.info("POST request\nBody:\n%s\n", post_data.decode('utf-8')) + content_length = int( + self.headers["Content-Length"] + ) # <--- Gets the size of data + post_data = self.rfile.read(content_length) # <--- Gets the data itself + logging.info("POST request\nBody:\n%s\n", post_data.decode("utf-8")) + def run(server_class=HTTPServer, handler_class=S, port=8080): logging.basicConfig(level=logging.INFO) - server_address = ('', port) + server_address = ("", port) httpd = server_class(server_address, handler_class) - logging.info('Starting httpd...\n') + logging.info("Starting httpd...\n") try: httpd.serve_forever() except KeyboardInterrupt: pass httpd.server_close() - logging.info('Stopping httpd...\n') + logging.info("Stopping httpd...\n") -if __name__ == '__main__': + +if __name__ == "__main__": from sys import argv if len(argv) == 2: