Skip to content

Commit

Permalink
Strip out wip command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishwillee committed Nov 13, 2018
1 parent 8cdff66 commit d19d58d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
13 changes: 2 additions & 11 deletions generator/mavgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
DEFAULT_ERROR_LIMIT = 200
DEFAULT_VALIDATE = True
DEFAULT_STRICT_UNITS = False
DEFAULT_WITH_WIP = False

# List the supported languages. This is done globally because it's used by the GUI wrapper too
supportedLanguages = ["C", "CS", "JavaScript", "Python", "WLua", "ObjC", "Swift", "Java", "C++11"]
Expand Down Expand Up @@ -69,13 +68,6 @@ def mavgen_validate(xmlfile):
try:
with open(xmlfile, 'r') as f:
xmldocument = etree.parse(f)

if not opts.with_wip:
# remove wip elements from validation
print("Note: WIP Elements not validated")
wip_entry = xmldocument.findall('.//wip/..')
for entry in wip_entry:
entry.getparent().remove(entry)

xmlschema.assertValid(xmldocument)
forbidden_names_re = re.compile("^(break$|case$|class$|catch$|const$|continue$|debugger$|default$|delete$|do$|else$|\
Expand Down Expand Up @@ -107,7 +99,7 @@ def mavgen_validate(xmlfile):
print("Validation skipped for %s." % fname)

print("Parsing %s" % fname)
xml.append(mavparse.MAVXML(fname, opts.wire_protocol, opts.with_wip))
xml.append(mavparse.MAVXML(fname, opts.wire_protocol))

# expand includes
for x in xml[:]:
Expand Down Expand Up @@ -184,14 +176,13 @@ def mavgen_validate(xmlfile):

# build all the dialects in the dialects subpackage
class Opts(object):
def __init__(self, output, wire_protocol=DEFAULT_WIRE_PROTOCOL, language=DEFAULT_LANGUAGE, validate=DEFAULT_VALIDATE, error_limit=DEFAULT_ERROR_LIMIT, strict_units=DEFAULT_STRICT_UNITS, with_wip=DEFAULT_WITH_WIP):
def __init__(self, output, wire_protocol=DEFAULT_WIRE_PROTOCOL, language=DEFAULT_LANGUAGE, validate=DEFAULT_VALIDATE, error_limit=DEFAULT_ERROR_LIMIT, strict_units=DEFAULT_STRICT_UNITS):
self.wire_protocol = wire_protocol
self.error_limit = error_limit
self.language = language
self.output = output
self.validate = validate
self.strict_units = strict_units
self.with_wip = with_wip

def mavgen_python_dialect(dialect, wire_protocol):
'''generate the python code on the fly for a MAVLink dialect'''
Expand Down
16 changes: 2 additions & 14 deletions generator/mavparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def __init__(self, name, linenumber, description=''):

class MAVXML(object):
'''parse a mavlink XML file'''
def __init__(self, filename, wire_protocol_version=PROTOCOL_0_9, with_wip=False):
def __init__(self, filename, wire_protocol_version=PROTOCOL_0_9):
self.filename = filename
self.basename = os.path.basename(filename)
if self.basename.lower().endswith(".xml"):
Expand All @@ -181,7 +181,6 @@ def __init__(self, filename, wire_protocol_version=PROTOCOL_0_9, with_wip=False)
self.version = 2
self.include = []
self.wire_protocol_version = wire_protocol_version
self.with_wip = with_wip

# setup the protocol features for the requested protocol version
if wire_protocol_version == PROTOCOL_0_9:
Expand Down Expand Up @@ -291,22 +290,11 @@ def char_data(data):
self.include.append(data)

f = open(filename, mode='rb')
from lxml import etree
xmldocument = etree.parse(f)

if not self.with_wip:
# remove wip elements from parsing
wip_entry = xmldocument.findall('.//wip/..')
for entry in wip_entry:
entry.getparent().remove(entry)

p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = start_element
p.EndElementHandler = end_element
p.CharacterDataHandler = char_data
xmlstring = etree.tostring(xmldocument)
p.Parse(xmlstring)

p.ParseFile(f)
f.close()

self.message_lengths = {}
Expand Down
1 change: 0 additions & 1 deletion tools/mavgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
parser.add_argument("--no-validate", action="store_false", dest="validate", default=mavgen.DEFAULT_VALIDATE, help="Do not perform XML validation. Can speed up code generation if XML files are known to be correct.")
parser.add_argument("--error-limit", default=mavgen.DEFAULT_ERROR_LIMIT, help="maximum number of validation errors to display")
parser.add_argument("--strict-units", action="store_true", dest="strict_units", default=mavgen.DEFAULT_STRICT_UNITS, help="Perform validation of units attributes.")
parser.add_argument("--with-wip", action="store_true", dest="with_wip", default=mavgen.DEFAULT_WITH_WIP, help="Include WIP messages in generated library.")
parser.add_argument("definitions", metavar="XML", nargs="+", help="MAVLink definitions")
args = parser.parse_args()

Expand Down

0 comments on commit d19d58d

Please sign in to comment.