1""" 2Some topic definition validation functions. 3 4:copyright: Copyright since 2006 by Oliver Schoenborn, all rights reserved. 5:license: BSD, see LICENSE_BSD_Simple.txt for details. 6""" 7 8from .topicexc import MessageDataSpecError 9 10 11def verifyArgsDifferent(allArgs, allParentArgs, topicName): 12 """Verify that allArgs does not contain any of allParentArgs. Raise 13 MessageDataSpecError if fail. """ 14 extra = set(allArgs).intersection(allParentArgs) 15 if extra: 16 msg = 'Args %%s already used in parent of "%s"' % topicName 17 raise MessageDataSpecError( msg, tuple(extra) ) 18 19 20def verifySubset(all, sub, topicName, extraMsg=''): 21 """Verify that sub is a subset of all for topicName. Raise 22 MessageDataSpecError if fail. """ 23 notInAll = set(sub).difference(all) 24 if notInAll: 25 args = ','.join(all) 26 msg = 'Params [%s] missing inherited [%%s] for topic "%s"%s' % (args, topicName, extraMsg) 27 raise MessageDataSpecError(msg, tuple(notInAll) ) 28 29 30