nexB/license-expression

Possible simplify error

Closed this issue · 1 comments

This is likely a bug, possibly fixed with dedup instead of simplify

>>> from license_expression import *
>>> l=Licensing()
>>> l.parse('(mit OR gpl-2.0) AND mit AND bsd-new')
AND(OR(LicenseSymbol(u'mit', is_exception=False), LicenseSymbol(u'gpl-2.0', is_exception=False)), LicenseSymbol(u'mit', is_exception=False), LicenseSymbol(u'bsd-new', is
_exception=False))
>>> x=l.parse('(mit OR gpl-2.0) AND mit AND bsd-new')
>>> x.simplify()
AND(LicenseSymbol(u'bsd-new', is_exception=False), LicenseSymbol(u'mit', is_exception=False))
>>> print x.simplify()
bsd-new AND mit

Simplify is correct. Dedup does the what we want in these special cases:

>>> str(l.dedup('(mit OR gpl-2.0) AND mit AND bsd-new'))
'(mit OR gpl-2.0) AND mit AND bsd-new'
>>> str(l.dedup('mit and (mit OR gpl-2.0) AND mit AND bsd-new'))
'mit AND (mit OR gpl-2.0) AND bsd-new'