From 38aa9a20f643c2b5eb713085d74e254cfa48dc2e Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sun, 23 Sep 2018 11:06:20 -0400 Subject: [PATCH] parameters delete unused scope --- src/lib/parameters/px4params/__init__.py | 2 +- src/lib/parameters/px4params/markdownout.py | 19 +----------- src/lib/parameters/px4params/scope.py | 32 --------------------- src/lib/parameters/px4params/srcparser.py | 3 +- src/lib/parameters/px4params/srcscanner.py | 7 +---- 5 files changed, 4 insertions(+), 59 deletions(-) delete mode 100644 src/lib/parameters/px4params/scope.py diff --git a/src/lib/parameters/px4params/__init__.py b/src/lib/parameters/px4params/__init__.py index 5103c86f3a..6ade09ef6f 100644 --- a/src/lib/parameters/px4params/__init__.py +++ b/src/lib/parameters/px4params/__init__.py @@ -1 +1 @@ -__all__ = ["srcscanner", "srcparser", "xmlout", "scope"] +__all__ = ["srcscanner", "srcparser", "xmlout"] diff --git a/src/lib/parameters/px4params/markdownout.py b/src/lib/parameters/px4params/markdownout.py index 2f7634dfa2..98634ae428 100644 --- a/src/lib/parameters/px4params/markdownout.py +++ b/src/lib/parameters/px4params/markdownout.py @@ -8,16 +8,6 @@ class MarkdownTablesOutput(): "\n") for group in groups: result += '## %s\n\n' % group.GetName() - - #Check if scope (module where parameter is defined) is the same for all parameters in the group. - # If so then display just once about the table. - scope_set = set() - for param in group.GetParams(): - scope_set.add(param.GetFieldValue("scope")) - if len(scope_set)==1: - result+='\nThe module where these parameters are defined is: *%s*.\n\n' % list(scope_set)[0] - - result += '\n' result += ' \n' result += ' \n' @@ -63,13 +53,6 @@ class MarkdownTablesOutput(): if reboot_required: reboot_required='

Reboot required: %s

\n' % reboot_required - - scope='' - if not len(scope_set)==1 or len(scope_set)==0: - scope = param.GetFieldValue("scope") or '' - if scope: - scope='

Module: %s

\n' % scope - enum_codes=param.GetEnumCodes() or '' # Gets numerical values for parameter. enum_output='' @@ -93,7 +76,7 @@ class MarkdownTablesOutput(): bitmask_output+='\n' - result += '\n \n \n \n \n \n\n' % (code,type,name, long_desc, enum_output, bitmask_output, reboot_required, scope, max_min_combined,def_val,unit) + result += '\n \n \n \n \n \n\n' % (code, type, name, long_desc, enum_output, bitmask_output, reboot_required, max_min_combined, def_val, unit) #Close the table. result += '
%s (%s)

%s

%s %s %s %s %s
%s%s %s
%s (%s)

%s

%s %s %s %s
%s%s %s
\n\n' diff --git a/src/lib/parameters/px4params/scope.py b/src/lib/parameters/px4params/scope.py deleted file mode 100644 index 212b591513..0000000000 --- a/src/lib/parameters/px4params/scope.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -import re - -class Scope(object): - """ - Single parameter group - """ - re_deep_lines = re.compile(r'.*\/.*\/') - def __init__(self,): - self.scope = set() - - - def __str__(self): - return self.scope.__str__() - - def Add(self, scope): - """ - Add Scope to set - """ - self.scope.add(scope) - - def Has(self, scope): - """ - Check for existance - """ - if len(self.scope) == 0: - return True - # Anything in the form xxxxx/yyyyy/zzzzz.... - # is treated as xxxxx/yyyyy - while (self.re_deep_lines.match(scope)): - scope = os.path.dirname(scope) - return scope in self.scope diff --git a/src/lib/parameters/px4params/srcparser.py b/src/lib/parameters/px4params/srcparser.py index 03abb0a801..5098545683 100644 --- a/src/lib/parameters/px4params/srcparser.py +++ b/src/lib/parameters/px4params/srcparser.py @@ -186,7 +186,7 @@ class SourceParser(object): def __init__(self): self.param_groups = {} - def Parse(self, scope, contents): + def Parse(self, contents): """ Incrementally parse program contents and append all found parameters to the list. @@ -288,7 +288,6 @@ class SourceParser(object): if defval != "" and self.re_is_a_number.match(defval): defval = self.re_cut_type_specifier.sub('', defval) param = Parameter(name, tp, defval) - param.SetField("scope", scope) param.SetField("short_desc", name) # If comment was found before the parameter declaration, # inject its data into the newly created parameter. diff --git a/src/lib/parameters/px4params/srcscanner.py b/src/lib/parameters/px4params/srcscanner.py index 38686c1e76..8be54a2450 100644 --- a/src/lib/parameters/px4params/srcscanner.py +++ b/src/lib/parameters/px4params/srcscanner.py @@ -34,11 +34,6 @@ class SourceScanner(object): Scans provided file and passes its contents to the parser using parser.Parse method. """ - # Extract the scope: it is the directory within the repo. Either it - # starts directly with 'src/module/abc', or it has the form 'x/y/z/src/module/abc'. - # The output is 'module/abc' in both cases. - prefix = "^(|.*" + os.path.sep + ")src" + os.path.sep - scope = re.sub(prefix.replace("\\", "/"), "", os.path.dirname(os.path.relpath(path)).replace("\\", "/")) with codecs.open(path, 'r', 'utf-8') as f: try: @@ -47,4 +42,4 @@ class SourceScanner(object): contents = '' print('Failed reading file: %s, skipping content.' % path) pass - return parser.Parse(scope, contents) + return parser.Parse(contents)