コード例 #1
0
def main():
    dumpOutput(InputFile('input1.html'))
    time.sleep(0.02)
    dumpOutput(InputFile('input1.html'))
    time.sleep(0.02)
    with open('input2.html', 'w') as f:
        f.write('test111111111')
    dumpOutput(InputFile('input1.html'))
    dumpOutput(InputFile('input1.html'))
コード例 #2
0
ファイル: example.py プロジェクト: shouldsee/file_tracer
 def main():
     dumpOutput(InputFile('input1.html'))  ## first_run
     time.sleep(0.02)
     dumpOutput(InputFile('input1.html'))  ## using_cache
     time.sleep(0.02)
     with open('input2.html', 'w') as f:
         f.write('test111111111')  ## change implicit input
     dumpOutput(InputFile('input1.html'))  ## recalc
     dumpOutput(InputFile('input1.html'))  ## using_cache
     dumpOutput(InputFile('input2.html'))  ## first_run
コード例 #3
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
コード例 #4
0
ファイル: test.py プロジェクト: shouldsee/file_tracer
 def main():
     print('[1]')
     dumpOutput(InputFile('input1.html'))
     time.sleep(0.02)
     print('[2]')
     dumpOutput(InputFile('input1.html'))
     time.sleep(0.02)
     with open('input2.html', 'w') as f:
         f.write('test111111111')
     # assert 0
     print('[3]')
     dumpOutput(InputFile('input1.html'))
     print('[4]')
     dumpOutput(InputFile('input1.html'))
     print('[5]')
     dumpOutput(InputFile('input2.html'))
コード例 #5
0
ファイル: test.py プロジェクト: shouldsee/file_tracer
    def test_tamp(self):
        # with self.DIR:
        tracer = FileTracer()
        v = InputFile('input1.html')
        v.addTimeStamp()

        time.sleep(0.02)
        vout = InputFile(v)
        vout.addTimeStamp()
        assert (v.stamp == vout.stamp), (v.stamp, vout.stamp)

        time.sleep(0.02)
        with open(v, 'w') as f:
            f.write('test111111111')
        vout = type(v)(v)
        vout.addTimeStamp()
        assert (v.stamp != vout.stamp), (v.stamp, vout.stamp)
コード例 #6
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()])
コード例 #7
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
コード例 #8
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()])
コード例 #9
0
ファイル: test2.py プロジェクト: shouldsee/file_tracer
def main():
    p = dumpOutput(InputFile('input1.html'))
    print(p(),p.hist)
コード例 #10
0
ファイル: test2.py プロジェクト: shouldsee/file_tracer
        while isinstance(self, Proxy):
            self=self._value
        return self
    def set_value(self,v):
        if isinstance(v,Proxy):
            v = v()
        self._value = v
    @property
    def value(self):
        return self()
        # self._foo
    

from file_tracer import FileTracer,InputFile,OutputFile,tree_as_string
from collections import Counter
with open(InputFile('input1.html'),'w') as f:
    f.write('123')
with open(InputFile('input2.html'),'w') as f:
    f.write('abc')

@Dye
def readInput(x):
    with open((x),'r') as f:
        return f.read()

@Dye
def middleStep(x):
    return readInput(x)

@Dye
def dumpOutput(x):
コード例 #11
0
ファイル: test.py プロジェクト: shouldsee/file_tracer
 def main():
     dumpOutput(InputFile('input1.html'))
コード例 #12
0
ファイル: test.py プロジェクト: shouldsee/file_tracer
 def test_init(self):
     # with self.DIR:
     with open(InputFile('input1.html'), 'w') as f:
         f.write('123')
     with open(InputFile('input2.html'), 'w') as f:
         f.write('abc')
コード例 #13
0
from file_tracer import FileTracer, InputFile, OutputFile, tree_as_string
from collections import Counter

tracer = FileTracer()

import time
import dill

v = InputFile('input1.html')
v.addTimeStamp()
s = dill.dumps(v)
time.sleep(0.02)
vout = dill.loads(s)
vout.addTimeStamp()
assert (v.stamp == vout.stamp), (v.stamp, vout.stamp)

time.sleep(0.02)
with open(v, 'w') as f:
    f.write('test111111111')
vout = type(v)(v)
vout.addTimeStamp()
assert (v.stamp != vout.stamp), (v.stamp, vout.stamp)
print v.stamp
print vout.stamp
# stat_result.st_mtime
print(hash(v))
v.addTimeStamp()
print(hash(v))
print(hash(vout))
print(v == vout)