Skip to content

Commit

Permalink
[DEV] Add parsing of command ID of xml files.
Browse files Browse the repository at this point in the history
Change-Id: I206d8cf968a8755fd4713d0fa3101a8ac79ab670
Reviewed-on: https://gerrit.parrot.biz/28551
Reviewed-by: Djavan Bertrand <[email protected]>
  • Loading branch information
m-maxime committed Jan 28, 2016
1 parent 2e128ad commit 22fd5b7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Utils/Python/ARCommandsParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ def toString(val):

class ARCommand:
"Represent a command"
def __init__(self, cmdName):
def __init__(self, cmdName, ident):
self.name = cmdName
self.ident = ident
self.comments = []
self.args = []
self.buf = ARCommandBuffer.ACK
Expand Down Expand Up @@ -391,14 +392,21 @@ def parseXml(fileName, projectName, previousProjects):
currentClass.addCommentLine(stripName)
commands = cmdclass.getElementsByTagName ('cmd')
for command in commands:
# Get command name
currentCommand = ARCommand(command.attributes["name"].nodeValue)
# Check if command name is unique
# Get command name / id
currentCommand = ARCommand(command.attributes["name"].nodeValue, command.attributes["id"].nodeValue)
# Check if command is unique
for cmd in currentClass.cmds:
# Check if command name is unique
if cmd.name == currentCommand.name:
ARPrint ('Command `' + cmd.name + '` appears multiple times in `' + proj.name + '.' + currentClass.name + '` !')
ARPrint (' --> Commands must have unique names in a given class (but can exist in multiple classes)')
EXIT (1)

# Check if command id is unique
if cmd.ident == currentCommand.ident:
ARPrint ('Command id:`' + cmd.ident + '` appears multiple times in `' + proj.name + '.' + currentClass.name + '` !')
ARPrint (' --> Commands must have unique id in a given class (but can exist in multiple classes)')
EXIT (1)

# Try to get the suggested buffer type for the command
try:
Expand Down

0 comments on commit 22fd5b7

Please sign in to comment.