From 13c0c618f3355282719b010f50183ddb9e6a74f7 Mon Sep 17 00:00:00 2001 From: TSC21 Date: Mon, 13 Jan 2020 18:37:11 +0000 Subject: [PATCH] px4modulesdoc: move to Python3 --- Tools/px4moduledoc/markdownout.py | 1 + Tools/px4moduledoc/srcparser.py | 16 ++++++++-------- Tools/px4moduledoc/srcscanner.py | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Tools/px4moduledoc/markdownout.py b/Tools/px4moduledoc/markdownout.py index ba59f82e19..6c3aae7728 100644 --- a/Tools/px4moduledoc/markdownout.py +++ b/Tools/px4moduledoc/markdownout.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 """ Class to generate Markdown documentation pages from parsed module doc strings """ diff --git a/Tools/px4moduledoc/srcparser.py b/Tools/px4moduledoc/srcparser.py index e498b33ed6..7e0f74926a 100644 --- a/Tools/px4moduledoc/srcparser.py +++ b/Tools/px4moduledoc/srcparser.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 import sys import re import math @@ -369,9 +370,9 @@ class SourceParser(object): failed = True if failed: - print("Warning: documentation inconsistency in %s:" % scope) - print(" Documented options : %s" % sorted_module_options) - print(" Options found in getopt(): %s" % sorted_getopt_args) + print(("Warning: documentation inconsistency in %s:" % scope)) + print((" Documented options : %s" % sorted_module_options)) + print((" Options found in getopt(): %s" % sorted_getopt_args)) self._consistency_checks_failure = True @@ -393,7 +394,7 @@ class SourceParser(object): continue # handled in the base class if not command in doc_commands: - print("Warning: undocumented command '%s' in %s" %(command, scope)) + print(("Warning: undocumented command '%s' in %s" %(command, scope))) self._consistency_checks_failure = True # limit the maximum line length in the module doc string @@ -409,8 +410,8 @@ class SourceParser(object): elif not verbatim_mode: if not 'www.' in line and not 'http' in line: if len(line) > max_line_length: - print('Line too long (%i > %i) in %s:' % (len(line), max_line_length, scope)) - print(' '+line) + print(('Line too long (%i > %i) in %s:' % (len(line), max_line_length, scope))) + print((' '+line)) self._consistency_checks_failure = True @@ -442,7 +443,7 @@ class SourceParser(object): while next_position < len(contents): if contents[next_position] == '\\': # escaping if contents[next_position + 1] != '\n': # skip if continued on next line - string += contents[next_position:next_position+2].decode('string_escape') + string += contents[next_position:next_position+2].encode().decode('unicode_escape') next_position += 2 elif contents[next_position] == '"': next_position += 1 @@ -519,4 +520,3 @@ class SourceParser(object): for subcategory in group: group[subcategory] = sorted(group[subcategory], key=lambda x: x.name()) return groups - diff --git a/Tools/px4moduledoc/srcscanner.py b/Tools/px4moduledoc/srcscanner.py index e3c0aa5bec..5bc8b6a6b0 100644 --- a/Tools/px4moduledoc/srcscanner.py +++ b/Tools/px4moduledoc/srcscanner.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 import os import re import codecs @@ -24,7 +25,7 @@ class SourceScanner(object): if not self.ScanFile(path, parser): return False except: - print("Exception in file %s" % path) + print(("Exception in file %s" % path)) raise return True @@ -44,6 +45,6 @@ class SourceScanner(object): contents = f.read() except: contents = '' - print('Failed reading file: %s, skipping content.' % path) + print(('Failed reading file: %s, skipping content.' % path)) pass return parser.Parse(scope, contents)