コード例 #1
0
class FilePreProcessorFactoryTests(TestCase):
    def setUp(self):
        self.fppf = FilePreProcessorFactory()

    def test_get_js_subset_preprocessor(self):
        pp = self.fppf.get_preprocessor(FilePreProcessJsSubset.get_name())
        eq_(type(pp), FilePreProcessJsSubset)

    @raises(FilePreProcessorDoesNotExistException)
    def test_throws_exception_for_nonsense_preprocessor_name(self):
        pp = self.fppf.get_preprocessor('non-existant preprocessor')
コード例 #2
0
ファイル: stat_lines.py プロジェクト: markdrago/caboose
class StatLines(Statistic):
    def __init__(self):
        self.preprocessor_factory = FilePreProcessorFactory()
        self.preprocessor = None

    def get_stat(self):
        return sum([self.get_single_file_stat(f) for f in self.files])

    @classmethod
    def get_name(clazz):
        return "lines"

    def set_config(self, conf):
        if 'preprocessor' in conf:
            self.preprocessor = self.get_preprocessor(conf['preprocessor'])
            self.preprocessor.set_config(conf)

    def get_single_file_stat(self, filename):
        f = open(filename, "r")
        contents = f.read()
        f.close()
        
        if self.preprocessor is not None:
            self.preprocessor.set_input(contents)
            contents = self.preprocessor.get_output()
        
        return len(contents.split("\n")) - 1

    def get_preprocessor(self, name):
        if name is None:
            return None
        return self.preprocessor_factory.get_preprocessor(name)

    def set_preprocessor_factory(self, factory):
        self.preprocessor_factory = factory

    def set_preprocessor_name(self, name):
        self.preprocessor_name = name
コード例 #3
0
ファイル: stat_lines.py プロジェクト: markdrago/caboose
 def __init__(self):
     self.preprocessor_factory = FilePreProcessorFactory()
     self.preprocessor = None
コード例 #4
0
 def setUp(self):
     self.fppf = FilePreProcessorFactory()