def _new_open_bin(self, width=None, height=None, rid=None):
        """
        Extract the next empty bin and append it to open bins

        Returns:
            PackingAlgorithm: Initialized empty packing bin.
            None: No bin big enough for the rectangle was found
        """
        factories_to_delete = set() #
        new_bin = None

        for key, binfac in self._empty_bins.items():

            # Only return the new bin if the rect fits.
            # (If width or height is None, caller doesn't know the size.)
            if not binfac.fits_inside(width, height):
                continue
           
            # Create bin and add to open_bins
            new_bin = binfac.new_bin()
            if new_bin is None:
                continue
            self._open_bins.append(new_bin)

            # If the factory was depleted mark for deletion
            if binfac.is_empty():
                factories_to_delete.add(key)
       
            break

        # Delete marked factories
        for f in factories_to_delete:
            del self._empty_bins[f]

        return new_bin
def _new_open_bin ( self , width = None , height = None , rid = None ) : factories_to_delete = set ( ) new_bin = None for key , binfac in self . _empty_bins . items ( ) : if not binfac . fits_inside ( width , height ) : continue new_bin = binfac . new_bin ( ) if new_bin is None : continue self . _open_bins . append ( new_bin ) if binfac . is_empty ( ) : factories_to_delete . add ( key ) break for f in factories_to_delete : del self . _empty_bins [ f ] return new_bin
Extract the next empty bin and append it to open bins

        Returns:
            PackingAlgorithm: Initialized empty packing bin.
            None: No bin big enough for the rectangle was found