File size: 601 Bytes
96d549d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from abc import ABCMeta, abstractmethod
import sys


class Source(object):
    __metaclass__ = ABCMeta

    @abstractmethod
    def contents(self):
        pass

    def __len__(self):
        return sys.maxint

class ListSource(Source):
    def __init__(self, list):
        self.list = list

    def contents(self):
        return self.list

    def __len__(self):
        return len(self.contents())


class AnalyzerSource(Source):
    def __init__(self, analyzer):
        self.analyzer = analyzer

    def contents(self):
        for content in self.analyzer.analyze():
            yield content