Fix index json path

This commit is contained in:
Sewon Ahn 2020-11-23 18:29:16 +09:00
parent 6f5fb3a07b
commit 99736540b9
2 changed files with 94 additions and 76 deletions

View file

@ -28,9 +28,9 @@ class Fragments:
self.index_file = 'index.json' self.index_file = 'index.json'
def init_json(self, directory): def init_json(self, directory):
index_path = os.path.join(directory, self.index_file) self.index_path = index_path = os.path.join(directory, self.index_file)
if os.path.isfile(index_path): if os.path.isfile(self.index_path):
with open(index_path) as json_file: with open(self.index_path) as json_file:
self.json_data = json.load(json_file) self.json_data = json.load(json_file)
self.temp_data = {"fragments":[]} self.temp_data = {"fragments":[]}
@ -191,7 +191,7 @@ class Fragments:
def save(self): def save(self):
print(json.dumps(self.indextable, cls=CustomEncoder)) print(json.dumps(self.indextable, cls=CustomEncoder))
with open(self.index_file, 'w') as outfile: with open(self.index_path, 'w') as outfile:
json.dump(self.indextable, outfile, indent=4, cls=CustomEncoder) json.dump(self.indextable, outfile, indent=4, cls=CustomEncoder)
self.count = len(self.indextable) self.count = len(self.indextable)

View file

@ -2,7 +2,7 @@
{ {
"__Fragment__": { "__Fragment__": {
"index": 0, "index": 0,
"update": 1605624006.157665, "update": 1605935441.1233928,
"directory": "./test_data/event_lecture", "directory": "./test_data/event_lecture",
"artist": "event_lecture", "artist": "event_lecture",
"file": "event_0000" "file": "event_0000"
@ -11,7 +11,7 @@
{ {
"__Fragment__": { "__Fragment__": {
"index": 1, "index": 1,
"update": 1605624006.16457, "update": 1605935441.1251554,
"directory": "./test_data/event_lecture", "directory": "./test_data/event_lecture",
"artist": "event_lecture", "artist": "event_lecture",
"file": "event_0001" "file": "event_0001"
@ -20,52 +20,52 @@
{ {
"__Fragment__": { "__Fragment__": {
"index": 2, "index": 2,
"update": 1503837516.0, "update": 1603870906.290785,
"directory": "./test_data/carrot", "directory": "./test_data/carrot",
"artist": "carrot", "artist": "carrot",
"file": "\u110c\u1175\u11af\u110c\u116e.mp4" "file": "\uc9c8\uc8fc.mp4"
} }
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 3, "index": 3,
"update": 1567569419.653444, "update": 1604043931.1111157,
"directory": "./test_data/carrot", "directory": "./test_data/carrot",
"artist": "carrot", "artist": "carrot",
"file": "\u1101\u116e\u1106\u116e\u11af\u1101\u116e\u1106\u116e\u11af.mov" "file": "RTF\ud14c\uc2a4\ud2b8.rtf"
} }
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 4, "index": 4,
"update": 1603737283.2655902, "update": 1604043931.1281314,
"directory": "./test_data/grape", "directory": "./test_data/carrot",
"artist": "grape", "artist": "carrot",
"file": "IMG_1693.png" "file": "\uafb8\ubb3c\uafb8\ubb3c.mov"
} }
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 5, "index": 5,
"update": 1603737296.0838926, "update": 1604043931.147918,
"directory": "./test_data/grape", "directory": "./test_data/fig",
"artist": "grape", "artist": "fig",
"file": "IMG_1340.jpg" "file": "20201022"
} }
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 6, "index": 6,
"update": 1603737307.8227732, "update": 1604043931.1488578,
"directory": "./test_data/grape", "directory": "./test_data/fig",
"artist": "grape", "artist": "fig",
"file": "IMG_1690.png" "file": "20201029"
} }
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 7, "index": 7,
"update": 1603737326.0093782, "update": 1604043931.238141,
"directory": "./test_data/grape", "directory": "./test_data/grape",
"artist": "grape", "artist": "grape",
"file": "IMG_1334.png" "file": "IMG_1334.png"
@ -74,61 +74,61 @@
{ {
"__Fragment__": { "__Fragment__": {
"index": 8, "index": 8,
"update": 1603737524.8806562, "update": 1605581893.2483907,
"directory": "./test_data/event_workshop",
"artist": "event_workshop",
"file": "event_0008"
}
},
{
"__Fragment__": {
"index": 9,
"update": 1604043931.259867,
"directory": "./test_data/grape",
"artist": "grape",
"file": "IMG_1340.jpg"
}
},
{
"__Fragment__": {
"index": 10,
"update": 1604043931.3548143,
"directory": "./test_data/grape",
"artist": "grape",
"file": "IMG_1690.png"
}
},
{
"__Fragment__": {
"index": 11,
"update": 1604043931.4324255,
"directory": "./test_data/grape",
"artist": "grape",
"file": "IMG_1693.png"
}
},
{
"__Fragment__": {
"index": 12,
"update": 1604043931.4409137,
"directory": "./test_data/grape", "directory": "./test_data/grape",
"artist": "grape", "artist": "grape",
"file": "sample.pdf" "file": "sample.pdf"
} }
}, },
{
"__Fragment__": {
"index": 9,
"update": 1604243002.5126157,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "RTF\ud14c\uc2a4\ud2b8.rtf"
}
},
{
"__Fragment__": {
"index": 10,
"update": 1604247403.2948427,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "md\uc4f0\uae30.md"
}
},
{
"__Fragment__": {
"index": 11,
"update": 1604247403.2950983,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "txt\uc4f0\uae30.txt"
}
},
{
"__Fragment__": {
"index": 12,
"update": 1604851924.8719456,
"directory": "./test_data/fig",
"artist": "fig",
"file": "20201022"
}
},
{ {
"__Fragment__": { "__Fragment__": {
"index": 13, "index": 13,
"update": 1604851924.8802848, "update": 1604912200.5855331,
"directory": "./test_data/fig", "directory": "./test_data/carrot",
"artist": "fig", "artist": "carrot",
"file": "20201029" "file": "test_folder"
} }
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 14, "index": 14,
"update": 1605496049.4045768, "update": 1605935441.120187,
"directory": "./test_data/carrot", "directory": "./test_data/carrot",
"artist": "carrot", "artist": "carrot",
"file": "1030.txt" "file": "1030.txt"
@ -137,7 +137,16 @@
{ {
"__Fragment__": { "__Fragment__": {
"index": 15, "index": 15,
"update": 1605496049.4053128, "update": 1605935441.1206152,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "md\uc4f0\uae30.md"
}
},
{
"__Fragment__": {
"index": 16,
"update": 1605935441.1206863,
"directory": "./test_data/carrot", "directory": "./test_data/carrot",
"artist": "carrot", "artist": "carrot",
"file": "test002.txt" "file": "test002.txt"
@ -145,8 +154,17 @@
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 16, "index": 17,
"update": 1605496049.4058702, "update": 1605935441.1208577,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "txt\uc4f0\uae30.txt"
}
},
{
"__Fragment__": {
"index": 18,
"update": 1605935441.1260843,
"directory": "./test_data/fig", "directory": "./test_data/fig",
"artist": "fig", "artist": "fig",
"file": "20201020" "file": "20201020"
@ -154,8 +172,8 @@
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 17, "index": 19,
"update": 1605496049.4062285, "update": 1605935441.1264834,
"directory": "./test_data/fig", "directory": "./test_data/fig",
"artist": "fig", "artist": "fig",
"file": "fig002.txt" "file": "fig002.txt"
@ -163,8 +181,8 @@
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 18, "index": 20,
"update": 1605496049.4064658, "update": 1605935441.126623,
"directory": "./test_data/fig", "directory": "./test_data/fig",
"artist": "fig", "artist": "fig",
"file": "test.txt" "file": "test.txt"
@ -172,8 +190,8 @@
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 19, "index": 21,
"update": 1605496049.406584, "update": 1605935441.126737,
"directory": "./test_data/fig", "directory": "./test_data/fig",
"artist": "fig", "artist": "fig",
"file": "test001.txt" "file": "test001.txt"
@ -181,8 +199,8 @@
}, },
{ {
"__Fragment__": { "__Fragment__": {
"index": 20, "index": 22,
"update": 1605496049.407514, "update": 1605935441.127966,
"directory": "./test_data/grape", "directory": "./test_data/grape",
"artist": "grape", "artist": "grape",
"file": "fbdbdbf54d766dd86e5964de01ddc16b.jpg" "file": "fbdbdbf54d766dd86e5964de01ddc16b.jpg"