def _check_superbox_for_top_levels(self, boxes):
        """Several boxes can only occur at the top level."""
        # We are only looking at the boxes contained in a superbox, so if any
        # of the blacklisted boxes show up here, it's an error.
        TOP_LEVEL_ONLY_BOXES = set(['dtbl'])
        box_ids = set([box.box_id for box in boxes])
        intersection = box_ids.intersection(TOP_LEVEL_ONLY_BOXES)
        if len(intersection) > 0:
            msg = "A {0} box cannot be nested in a superbox."
            raise IOError(msg.format(list(intersection)[0]))

        # Recursively check any contained superboxes.
        for box in boxes:
            if hasattr(box, 'box'):
                self._check_superbox_for_top_levels(box.box)
def _check_superbox_for_top_levels ( self , boxes ) : TOP_LEVEL_ONLY_BOXES = set ( [ 'dtbl' ] ) box_ids = set ( [ box . box_id for box in boxes ] ) intersection = box_ids . intersection ( TOP_LEVEL_ONLY_BOXES ) if len ( intersection ) > 0 : msg = "A {0} box cannot be nested in a superbox." raise IOError ( msg . format ( list ( intersection ) [ 0 ] ) ) for box in boxes : if hasattr ( box , 'box' ) : self . _check_superbox_for_top_levels ( box . box )
Several boxes can only occur at the top level.