Code Duplication    Length = 15-15 lines in 2 locations

server/lib/medusa/asynchat.py 1 location

@@ 230-244 (lines=15) @@
227
            self.producer_fifo.pop()
228
229
230
class simple_producer:
231
232
    def __init__ (self, data, buffer_size=512):
233
        self.data = data
234
        self.buffer_size = buffer_size
235
236
    def more (self):
237
        if len (self.data) > self.buffer_size:
238
            result = self.data[:self.buffer_size]
239
            self.data = self.data[self.buffer_size:]
240
            return result
241
        else:
242
            result = self.data
243
            self.data = ''
244
            return result
245
246
class fifo:
247
    def __init__ (self, list=None):

server/lib/medusa/producers.py 1 location

@@ 14-28 (lines=15) @@
11
producer, then wrap this with the 'chunked' transfer-encoding producer.
12
"""
13
14
class simple_producer:
15
    "producer for a string"
16
    def __init__ (self, data, buffer_size=1024):
17
        self.data = data
18
        self.buffer_size = buffer_size
19
20
    def more (self):
21
        if len (self.data) > self.buffer_size:
22
            result = self.data[:self.buffer_size]
23
            self.data = self.data[self.buffer_size:]
24
            return result
25
        else:
26
            result = self.data
27
            self.data = ''
28
            return result
29
30
class scanning_producer:
31
    "like simple_producer, but more efficient for large strings"