ros-infrastructure/catkin_pkg

Condition can't handle multiple sequential 'or's

MatthijsBurgh opened this issue · 1 comments

The following condition results in a list of length 5

condition = "$ROS_PYTHON_VERSION == 2 or $ROS_PYTHON_VERSION == 2 or $ROS_PYTHON_VERSION == 2"

It creates the following AssertionError, as it only accepts a list of 3.

In [18]: evaluate_condition(condition, os.environ)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-18-68713d7cacd4> in <module>()
----> 1 evaluate_condition(condition, os.environ)

/usr/lib/python2.7/dist-packages/catkin_pkg/condition.pyc in evaluate_condition(condition, context)
     27         raise ValueError(
     28             "condition '%s' failed to parse: %s" % (condition, e))
---> 29     return _evaluate(parse_results.asList()[0], context)
     30 
     31 

/usr/lib/python2.7/dist-packages/catkin_pkg/condition.pyc in _evaluate(parse_results, context)
     59 
     60     # recursion
---> 61     assert len(parse_results) == 3
     62 
     63     # handle logical operators

AssertionError: 

This is the actual result, with a length of 5.

[['$ROS_PYTHON_VERSION', '==', '2'],
 'or',
 ['$ROS_PYTHON_VERSION', '==', '2'],
 'or',
 ['$ROS_PYTHON_VERSION', '==', '2']]

This should be fixed by #279 which will be part of the next patch release.