コード例 #1
0
ファイル: test.py プロジェクト: shouldsee/file_tracer
def dumpOutput(x):
    s = middleStep(x)
    d = collections.Counter(s)
    fn = OutputFile(x + '.count')
    with open(fn, 'w') as f:
        map(f.write, [str(x) for x in d.items()])
    return
コード例 #2
0
ファイル: test.py プロジェクト: shouldsee/file_tracer
    def test_simple(self):
        # with self.DIR:
        tracer = FileTracer()
        # tracer.clear()

        @tracer.cache
        def main():
            dumpOutput(InputFile('input1.html'))

        tracer.run(main)
        # print(self.)
        # assert tracer.fileSetByFunc)main].output_files == {OutputFile(u'input1.html.count').addTimeStamp()},tracer.fileSetByFunc[main].output_files
        assert list(tracer.byFunc[main].values())[0][0].output_files == {
            OutputFile(u'input1.html.count').addTimeStamp()
        }, tracer.fileSetByFunc[main].output_files
        assert list(tracer.byFunc[main].values())[0][0].input_files == {
            InputFile(u'input1.html').addTimeStamp()
        }, tracer.fileSetByFunc[main].input_files

        # assert tracer.output_files == {OutputFile(u'input1.html.count').addTimeStamp()},tracer.output_files
        # assert tracer.input_files == {InputFile(u'input1.html').addTimeStamp()},tracer.input_files
        tracer.dump_to_file(strict=1)

        tracer.clear()
        assert main not in tracer.byFunc
コード例 #3
0
ファイル: test2.py プロジェクト: shouldsee/file_tracer
def dumpOutput(x):
    s = middleStep(x)()
    d = Counter(s)
    of = OutputFile(x+'.count')
    with open( of,'w') as f:
        map(f.write,[str(x) for x in d.items()])
        # f.write(d.items())
    return of
コード例 #4
0
ファイル: example.py プロジェクト: shouldsee/file_tracer
 def dumpOutput(x):
     s = readInput(x)
     d = collections.Counter(s)
     fn = OutputFile(x + '.count')
     ### merely referencing the file is enough to log dependency
     with open(InputFile('input2.html'), 'r') as f:
         pass
     with open(fn, 'w') as f:
         map(f.write, [str(x) for x in d.items()])
コード例 #5
0
def dumpOutput(x):
    s = middleStep(x)
    d = Counter(s)
    fn = OutputFile(x + '.count')
    with open(InputFile('input2.html'), 'r') as f:
        pass
    # with open
    with open(fn, 'w') as f:
        map(f.write, [str(x) for x in d.items()])
    return
コード例 #6
0
ファイル: test.py プロジェクト: shouldsee/file_tracer
        def dumpOutput(x):
            s = middleStep(x)
            d = collections.Counter(s)
            fn = OutputFile(x + '.count')
            fo = [
                InputFile('input2.html'),
            ]
            # fo = (InputFile('input2.html'),)

            with open(('input2.html'), 'r') as f:
                pass
            # with open
            with open(fn, 'w') as f:
                map(f.write, [str(x) for x in d.items()])
コード例 #7
0
def job1(num):
    print('RUNNING', job1.__name__, num)
    with open(OutputFile(SharedObject.DIR / '%s.txt.temp' % num), 'w') as f:
        f.write('a' * num)
    return num
コード例 #8
0
    d = Counter(s)
    fn = OutputFile(x + '.count')
    with open(fn, 'w') as f:
        map(f.write, [str(x) for x in d.items()])
    return


@tracer.cache
def main():
    dumpOutput(InputFile('input1.html'))
    # dumpOutput(InputFile('input2.html'))


tracer(main)
assert tracer.byFunc[main].output_files == {
    OutputFile(u'input1.html.count').addTimeStamp()
}, tracer.byFunc[main].output_files
assert tracer.byFunc[main].input_files == {
    InputFile(u'input1.html').addTimeStamp()
}, tracer.byFunc[main].input_files

assert tracer.output_files == {
    OutputFile(u'input1.html.count').addTimeStamp()
}, tracer.output_files
assert tracer.input_files == {InputFile(u'input1.html').addTimeStamp()
                              }, tracer.input_files


def main():
    dumpOutput(InputFile('input1.html'))