Merge branch 'feature/index' of https://github.com/hynchl/distribusi-foh
This commit is contained in:
commit
9cc7523133
12 changed files with 253 additions and 39 deletions
|
|
@ -18,19 +18,31 @@ class Fragment:
|
|||
|
||||
class Fragments:
|
||||
def __init__(self):
|
||||
self.json_data = {}
|
||||
self.index = {}
|
||||
self.indextable = []
|
||||
self.timetable = []
|
||||
self.ignore = ['.ignore']
|
||||
|
||||
self.config_file = 'config.json'
|
||||
self.index_file = 'fragments_index.json'
|
||||
self.ignore_file = '.ignore'
|
||||
self.index_file = 'index.json'
|
||||
|
||||
with open(self.index_file) as json_file:
|
||||
self.json_data = json.load(json_file)
|
||||
if os.path.isfile(self.index_file):
|
||||
with open(self.index_file) as json_file:
|
||||
self.json_data = json.load(json_file)
|
||||
|
||||
self.temp_data = {"fragments":[]}
|
||||
self.count = len(self.json_data)
|
||||
|
||||
def add_ignore(self, directory):
|
||||
ignore_path = os.path.join(directory, self.ignore_file)
|
||||
if os.path.isfile(ignore_path):
|
||||
ignore = open(ignore_path, 'r')
|
||||
ignore_lines = ignore.readlines()
|
||||
for line in ignore_lines:
|
||||
stripped_line = line.rstrip()
|
||||
self.ignore.append(stripped_line)
|
||||
|
||||
def creation_date(self, path_to_file):
|
||||
"""
|
||||
Try to get the date that a file was created, falling back to when it was
|
||||
|
|
@ -55,7 +67,8 @@ class Fragments:
|
|||
if occupation > -1:
|
||||
origin_path = os.path.join(directory, file)
|
||||
date = self.creation_date(origin_path)
|
||||
arr = directory.split("/")
|
||||
arr = directory\
|
||||
.split("/")
|
||||
if arr.__len__() == 2:
|
||||
artist = arr[1]
|
||||
else:
|
||||
|
|
@ -80,6 +93,7 @@ class Fragments:
|
|||
|
||||
def preindex(self, directory):
|
||||
for root, dirs, files in os.walk(directory):
|
||||
self.add_ignore(root)
|
||||
arr = root.split("/")
|
||||
# 2뎁스까지만 인덱스 함.
|
||||
if arr.__len__() < 4:
|
||||
|
|
@ -87,12 +101,13 @@ class Fragments:
|
|||
for f in files:
|
||||
if self.is_meta(f):
|
||||
pass
|
||||
elif f == "index.html" or f == ".DS_Store":
|
||||
elif f in self.ignore:
|
||||
pass
|
||||
elif self.has_meta(root, f):
|
||||
self.occupancy(root, f)
|
||||
else:
|
||||
self.add_timetable(root, f)
|
||||
if arr.__len__() > 2 and arr[2]:
|
||||
# dirs index
|
||||
for d in dirs:
|
||||
if self.has_meta(root, d):
|
||||
|
|
|
|||
|
|
@ -7,15 +7,12 @@ from distribusi.distribusi import build_index
|
|||
parser = build_argparser()
|
||||
args = parser.parse_args()
|
||||
|
||||
event_path = './events'
|
||||
data_path = './test_data'
|
||||
data_path = args.directory
|
||||
|
||||
freg = fragments.Fragments()
|
||||
freg.preindex(event_path)
|
||||
freg.preindex(data_path)
|
||||
freg.postindex()
|
||||
|
||||
distribusify(args, event_path, freg)
|
||||
distribusify(args, data_path, freg)
|
||||
|
||||
build_index(args, data_path, freg)
|
||||
|
|
@ -2,19 +2,19 @@
|
|||
{
|
||||
"__Fragment__": {
|
||||
"index": 0,
|
||||
"update": 1605496049.4004154,
|
||||
"directory": "./events",
|
||||
"artist": "events",
|
||||
"update": 1605581893.2526722,
|
||||
"directory": "./test_data/event_lecture",
|
||||
"artist": "event_lecture",
|
||||
"file": "event_0000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 1,
|
||||
"update": 1503837516.0,
|
||||
"directory": "./test_data/carrot",
|
||||
"artist": "carrot",
|
||||
"file": "\u110c\u1175\u11af\u110c\u116e.mp4"
|
||||
"update": 1605584344.6146529,
|
||||
"directory": "./test_data/event_lecture",
|
||||
"artist": "event_lecture",
|
||||
"file": "event_0001"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -74,10 +74,10 @@
|
|||
{
|
||||
"__Fragment__": {
|
||||
"index": 8,
|
||||
"update": 1604243002.5126157,
|
||||
"directory": "./test_data/carrot",
|
||||
"artist": "carrot",
|
||||
"file": "RTF\ud14c\uc2a4\ud2b8.rtf"
|
||||
"update": 1605581893.2483907,
|
||||
"directory": "./test_data/event_workshop",
|
||||
"artist": "event_workshop",
|
||||
"file": "event_0008"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -187,23 +187,5 @@
|
|||
"artist": "fig",
|
||||
"file": "test.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 21,
|
||||
"update": 1605496049.406584,
|
||||
"directory": "./test_data/fig",
|
||||
"artist": "fig",
|
||||
"file": "test001.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 22,
|
||||
"update": 1605496049.407514,
|
||||
"directory": "./test_data/grape",
|
||||
"artist": "grape",
|
||||
"file": "fbdbdbf54d766dd86e5964de01ddc16b.jpg"
|
||||
}
|
||||
}
|
||||
]
|
||||
191
index.json
Normal file
191
index.json
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
[
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 0,
|
||||
"update": 1605581893.2526722,
|
||||
"directory": "./test_data/event_lecture",
|
||||
"artist": "event_lecture",
|
||||
"file": "event_0000"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 1,
|
||||
"update": 1605584344.6146529,
|
||||
"directory": "./test_data/event_lecture",
|
||||
"artist": "event_lecture",
|
||||
"file": "event_0001"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 2,
|
||||
"update": 1567569419.653444,
|
||||
"directory": "./test_data/carrot",
|
||||
"artist": "carrot",
|
||||
"file": "\u1101\u116e\u1106\u116e\u11af\u1101\u116e\u1106\u116e\u11af.mov"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 3,
|
||||
"update": 1603737283.2655902,
|
||||
"directory": "./test_data/grape",
|
||||
"artist": "grape",
|
||||
"file": "IMG_1693.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 4,
|
||||
"update": 1603737296.0838926,
|
||||
"directory": "./test_data/grape",
|
||||
"artist": "grape",
|
||||
"file": "IMG_1340.jpg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 5,
|
||||
"update": 1603737307.8227732,
|
||||
"directory": "./test_data/grape",
|
||||
"artist": "grape",
|
||||
"file": "IMG_1690.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 6,
|
||||
"update": 1603737326.0093782,
|
||||
"directory": "./test_data/grape",
|
||||
"artist": "grape",
|
||||
"file": "IMG_1334.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 7,
|
||||
"update": 1603737524.8806562,
|
||||
"directory": "./test_data/grape",
|
||||
"artist": "grape",
|
||||
"file": "sample.pdf"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 8,
|
||||
"update": 1605581893.2483907,
|
||||
"directory": "./test_data/event_workshop",
|
||||
"artist": "event_workshop",
|
||||
"file": "event_0008"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 9,
|
||||
"update": 1604247403.2948427,
|
||||
"directory": "./test_data/carrot",
|
||||
"artist": "carrot",
|
||||
"file": "md\uc4f0\uae30.md"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 10,
|
||||
"update": 1604247403.2950983,
|
||||
"directory": "./test_data/carrot",
|
||||
"artist": "carrot",
|
||||
"file": "txt\uc4f0\uae30.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 11,
|
||||
"update": 1604851924.8719456,
|
||||
"directory": "./test_data/fig",
|
||||
"artist": "fig",
|
||||
"file": "20201022"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 12,
|
||||
"update": 1604851924.8802848,
|
||||
"directory": "./test_data/fig",
|
||||
"artist": "fig",
|
||||
"file": "20201029"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 13,
|
||||
"update": 1605496049.3995717,
|
||||
"directory": "./events/event_0000",
|
||||
"artist": "event_0000",
|
||||
"file": "124157237_121248643124584_872058020963845448_n.jpg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 14,
|
||||
"update": 1605496049.4002707,
|
||||
"directory": "./events/event_0000",
|
||||
"artist": "event_0000",
|
||||
"file": "124469821_121248626457919_479957910997498417_n.jpg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 15,
|
||||
"update": 1605496049.400738,
|
||||
"directory": "./events/event_0000",
|
||||
"artist": "event_0000",
|
||||
"file": "124476076_121248659791249_2342598949363915450_n.jpg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 16,
|
||||
"update": 1605496049.4045768,
|
||||
"directory": "./test_data/carrot",
|
||||
"artist": "carrot",
|
||||
"file": "1030.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 17,
|
||||
"update": 1605496049.4053128,
|
||||
"directory": "./test_data/carrot",
|
||||
"artist": "carrot",
|
||||
"file": "test002.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 18,
|
||||
"update": 1605496049.4058702,
|
||||
"directory": "./test_data/fig",
|
||||
"artist": "fig",
|
||||
"file": "20201020"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 19,
|
||||
"update": 1605496049.4062285,
|
||||
"directory": "./test_data/fig",
|
||||
"artist": "fig",
|
||||
"file": "fig002.txt"
|
||||
}
|
||||
},
|
||||
{
|
||||
"__Fragment__": {
|
||||
"index": 20,
|
||||
"update": 1605496049.4064658,
|
||||
"directory": "./test_data/fig",
|
||||
"artist": "fig",
|
||||
"file": "test.txt"
|
||||
}
|
||||
}
|
||||
]
|
||||
3
test_data/.ignore
Normal file
3
test_data/.ignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
.DS_Store
|
||||
index.html
|
||||
404.html
|
||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
26
test_data/event_lecture/event_0001/event_0001.txt
Normal file
26
test_data/event_lecture/event_0001/event_0001.txt
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
이벤트 0001 에 대한 설명문
|
||||
|
||||
|
||||
Loading…
Reference in a new issue