import os
from pyfileindex import PyFileIndex
def touch(fname, times=None):
with open(fname, "a"):
os.utime(fname, times)
def filter_function(file_name):
return ".txt" in file_name
pfi = PyFileIndex(path=".", filter_function=filter_function, debug=True)
pfi
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
1 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
pfi.update()
pfi
Changes: [] [] []
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
1 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
os.makedirs("bla")
pfi.update()
pfi
Changes: ['/home/jovyan/notebooks/bla'] ['/home/jovyan/notebooks'] []
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
2 | bla | /home/jovyan/notebooks/bla | /home/jovyan/notebooks | True | 1.563533e+09 | 2 |
os.makedirs("bla/bla")
pfi.update()
pfi
Changes: ['/home/jovyan/notebooks/bla/bla'] ['/home/jovyan/notebooks/bla'] []
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
2 | bla | /home/jovyan/notebooks/bla | /home/jovyan/notebooks | True | 1.563533e+09 | 3 |
3 | bla | /home/jovyan/notebooks/bla/bla | /home/jovyan/notebooks/bla | True | 1.563533e+09 | 2 |
touch("bla/bla/test.txt")
pfi.update()
pfi
Changes: ['/home/jovyan/notebooks/bla/bla/test.txt'] ['/home/jovyan/notebooks/bla/bla'] []
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
2 | bla | /home/jovyan/notebooks/bla | /home/jovyan/notebooks | True | 1.563533e+09 | 3 |
3 | bla | /home/jovyan/notebooks/bla/bla | /home/jovyan/notebooks/bla | True | 1.563533e+09 | 2 |
4 | test.txt | /home/jovyan/notebooks/bla/bla/test.txt | /home/jovyan/notebooks/bla/bla | False | 1.563533e+09 | 1 |
touch("bla/test.txt")
pfi.update()
pfi
Changes: ['/home/jovyan/notebooks/bla/test.txt'] ['/home/jovyan/notebooks/bla'] []
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
2 | bla | /home/jovyan/notebooks/bla/bla | /home/jovyan/notebooks/bla | True | 1.563533e+09 | 2 |
3 | test.txt | /home/jovyan/notebooks/bla/bla/test.txt | /home/jovyan/notebooks/bla/bla | False | 1.563533e+09 | 1 |
4 | bla | /home/jovyan/notebooks/bla | /home/jovyan/notebooks | True | 1.563533e+09 | 3 |
5 | test.txt | /home/jovyan/notebooks/bla/test.txt | /home/jovyan/notebooks/bla | False | 1.563533e+09 | 1 |
touch("bla/bla/test.txt", (1330712280, 1330712292))
pfi.update()
pfi
Changes: [] ['/home/jovyan/notebooks/bla/bla/test.txt'] []
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
2 | bla | /home/jovyan/notebooks/bla/bla | /home/jovyan/notebooks/bla | True | 1.563533e+09 | 2 |
3 | bla | /home/jovyan/notebooks/bla | /home/jovyan/notebooks | True | 1.563533e+09 | 3 |
4 | test.txt | /home/jovyan/notebooks/bla/test.txt | /home/jovyan/notebooks/bla | False | 1.563533e+09 | 1 |
5 | test.txt | /home/jovyan/notebooks/bla/bla/test.txt | /home/jovyan/notebooks/bla/bla | False | 1.330712e+09 | 1 |
os.remove("bla/bla/test.txt")
pfi.update()
pfi
Changes: [] ['/home/jovyan/notebooks/bla/bla'] ['/home/jovyan/notebooks/bla/bla/test.txt']
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
2 | bla | /home/jovyan/notebooks/bla | /home/jovyan/notebooks | True | 1.563533e+09 | 3 |
3 | test.txt | /home/jovyan/notebooks/bla/test.txt | /home/jovyan/notebooks/bla | False | 1.563533e+09 | 1 |
4 | bla | /home/jovyan/notebooks/bla/bla | /home/jovyan/notebooks/bla | True | 1.563533e+09 | 2 |
os.rmdir("bla/bla")
pfi.update()
pfi
Changes: [] ['/home/jovyan/notebooks/bla'] ['/home/jovyan/notebooks/bla/bla']
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |
2 | test.txt | /home/jovyan/notebooks/bla/test.txt | /home/jovyan/notebooks/bla | False | 1.563533e+09 | 1 |
3 | bla | /home/jovyan/notebooks/bla | /home/jovyan/notebooks | True | 1.563533e+09 | 2 |
os.remove("bla/test.txt")
os.rmdir("bla")
pfi.update()
pfi
Changes: [] ['/home/jovyan/notebooks'] ['/home/jovyan/notebooks/bla/test.txt' '/home/jovyan/notebooks/bla']
basename | path | dirname | is_directory | mtime | nlink | |
---|---|---|---|---|---|---|
0 | .ipynb_checkpoints | /home/jovyan/notebooks/.ipynb_checkpoints | /home/jovyan/notebooks | True | 1.563532e+09 | 2 |
1 | notebooks | /home/jovyan/notebooks | /home/jovyan | True | 1.563533e+09 | 1 |