-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for with-wip #234
Conversation
@peterbarker @amilcarlucas FYI. Please review and approve if you OK with this. |
FYI, My test file is as below. I ran it with a few different combinations of wip on different enum values and messages to validate message removal.
|
@peterbarker Actually I need your help here. The code works locally but fails on CI with:
But the argument appears to be defined properly in code
Thoughts .... |
@@ -144,10 +145,11 @@ def __init__(self, index, description=''): | |||
self.description = description | |||
|
|||
class MAVEnumEntry(object): | |||
def __init__(self, name, value, description='', end_marker=False, autovalue=False, origin_file='', origin_line=0): | |||
def __init__(self, name, value, description='', wip=False, end_marker=False, autovalue=False, origin_file='', origin_line=0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to add the wip=false
at the end of the parameter list instead of after the description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, but you haven't considered that name, value, description AND wip are properties of the XML file and hence sensibly grouped. The others are properties of this parser. IMO doesn't make sense to shove at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks, I planned to do this, but you beat me to it :)
@@ -257,7 +261,9 @@ def start_element(name, attrs): | |||
if (value > self.enum[-1].highest_value): | |||
self.enum[-1].highest_value = value | |||
# append the new entry | |||
self.enum[-1].entry.append(MAVEnumEntry(attrs['name'], value, '', False, autovalue, self.filename, p.CurrentLineNumber)) | |||
self.enum[-1].entry.append(MAVEnumEntry(attrs['name'], value, '', False, False, autovalue, self.filename, p.CurrentLineNumber)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the False
be self.wip
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. At this point I don't know if the value is a wip or not. I discover that later on. I am using False as the default though because most entries are not wip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
One is |
@amilcarlucas Yes, but I believe that is correct. The ArgumentParser takes an argument (what you actually enter of Or do I misunderstand your point? |
regarding |
@peterbarker Ready to merge. The test fail is nothing to do with me. Honest guv.
|
Once this goes in, we can minimize the diff between the Ardupilot/mavlink fork and the upstream mavlink/mavlink :) The ardupilot team does not want to have |
generator/mavparse.py
Outdated
|
||
if not self.with_wip: | ||
# remove wip elements from parsing | ||
wip_entry = xmldocument.findall('.//wip/..') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI This is a bit messy because you can't delete an object from itself. Here I find the wip parents, then delete each of them from their parent.
generator/mavparse.py
Outdated
p = xml.parsers.expat.ParserCreate() | ||
p.StartElementHandler = start_element | ||
p.EndElementHandler = end_element | ||
p.CharacterDataHandler = char_data | ||
p.ParseFile(f) | ||
xmlstring = etree.tostring(xmldocument) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, - I use lxml.etree to remove the elements, then convert XML to a string that is then passed to the existing expat parser.
@peterbarker The Rather than attempt to clean the XML representation before output generation I have updated this to strip all WIP elements before they are validated or parsed. The code to record wip information in the parser has not been removed in case we want to keep WIP elements but still update the output generated for them. Tests now pass. I think ready for a sanity check. |
@amilcarlucas Can you take this to the ArduPilot dev meeting? I just want to understand "when" it might be looked at. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be merged soonish??
I think it would be better to auto-generate warning("Work in progress message") on use of any WIP msgs in the C interface |
a bit more explanation ... |
@tridge I wish I had talked this through before doing the work - your point makes sense. The code to get this into the parser is present so I'll just strip out my message stripper and add the warning in. Sometime soon. |
Fix up bug in wip removal Add some test code to see if can debug problem Remove test code added in previous commit Add with_wip to Opts() test class Strip wip elements before parsing Strip out wip command line option Remove unneeded changes
d19d58d
to
b1f1945
Compare
Closing. Superseded by #240 |
Recently we added a tag
<wip>
for messages and enum values that indicates the message is a work in progress.This adds a flag
--with--wip
that you must specify in a build to include those messages/values in the generated library. If you don't specify it, the messages are stripped (as discussed by @amilcarlucas here).The generator strips the wip messages/enums after validation, but before generation.