anycall/bytequeue.py
def dequeue(self, n):
        """
        Remove and return the first `n` characters from the queue.
        Throws an error if there are less than `n` characters in the queue.
        
        Equivalent to::
        
            s = queue[:n]
            queue = queue[n:]
            
        if `queue` where a regular string.
        """
        if self._len < n:
            raise ValueError("Not enough bytes in the queue")
        self._len -= n
        
        def part_generator(n):
            """
            Returns the requested bytes in parts
            """
            remaining = n
            while remaining:
                part = self._parts.popleft()
                if len(part) <= remaining:
                    yield part
                    remaining -= len(part)
                else:
                    yield part[:remaining]
                    self._parts.appendleft(part[remaining:])
                    remaining = 0
                    
        return "".join(part_generator(n))
def dequeue(self, n):
        """
        Remove and return the first `n` characters from the queue.
        Throws an error if there are less than `n` characters in the queue.
        
        Equivalent to::
        
            s = queue[:n]
            queue = queue[n:]
            
        if `queue` where a regular string.
        """
        if self._len < n:
            raise ValueError("Not enough bytes in the queue")
        self._len -= n
        
        def part_generator(n):
            """
            Returns the requested bytes in parts
            """
            remaining = n
            while remaining:
                part = self._parts.popleft()
                if len(part) <= remaining:
                    yield part
                    remaining -= len(part)
                else:
                    yield part[:remaining]
                    self._parts.appendleft(part[remaining:])
                    remaining = 0
                    
        return "".join(part_generator(n))
def dequeue ( self , n ) : if self . _len < n : raise ValueError ( "Not enough bytes in the queue" ) self . _len -= n def part_generator ( n ) : """
            Returns the requested bytes in parts
            """ remaining = n while remaining : part = self . _parts . popleft ( ) if len ( part ) <= remaining : yield part remaining -= len ( part ) else : yield part [ : remaining ] self . _parts . appendleft ( part [ remaining : ] ) remaining = 0 return "" . join ( part_generator ( n ) )
Remove and return the first `n` characters from the queue.
        Throws an error if there are less than `n` characters in the queue.
        
        Equivalent to::
        
            s = queue[:n]
            queue = queue[n:]
            
        if `queue` where a regular string.
Remove and return the first n characters from the queue . Throws an error if there are less than n characters in the queue . Equivalent to :: s = queue [ : n ] queue = queue [ n : ] if queue where a regular string .