def fromDict(self, ring): if not any_in(RingMaker.KEYS, ring): if any_in(ring, self.segmentMaker.KEYS): return [ring] else: raise BudSyntaxError('Invalid {} format'.format(RingMaker.NM)) elif not all_in(ring, RingMaker.KEYS): raise BudSyntaxError('{} contains odd keywords'.format( RingMaker.NM)) else: return ring['segments']
def fromDict(self, ring): if not any_in(RingMaker.KEYS, ring): if any_in(ring, self.segmentMaker.KEYS): return [ring] else: raise BudSyntaxError( 'Invalid {} format'.format(RingMaker.NM)) elif not all_in(ring, RingMaker.KEYS): raise BudSyntaxError( '{} contains odd keywords'.format(RingMaker.NM)) else: return ring['segments']
def fromDict(self, layer): if not any_in(SliceMaker.KEYS, layer): if any_in(layer, self.ringMaker.KEYS): return [layer] else: raise BudSyntaxError( 'Invalid {} format'.format(SliceMaker.NM)) elif not all_in(layer, SliceMaker.KEYS): raise BudSyntaxError( '{} contains odd keywords'.format(SliceMaker.NM)) else: return layer['rings']
def test_non(self): assert not all_in([1, 2, 3], [1, 2]) assert not any_in([4, 5], [1, 2, 3])
def test_equ(self): assert all_in([1, 2], [1, 2, 3]) assert any_in([1, 2, 3], [1, 2])