diff --git a/distribusi/distribusi/distribusi.py b/distribusi/distribusi/distribusi.py
index 4bc66b7..21e500a 100644
--- a/distribusi/distribusi/distribusi.py
+++ b/distribusi/distribusi/distribusi.py
@@ -14,7 +14,7 @@ from distribusi.page_template import html_footer, html_head
from distribusi.mappings import CODE_TYPES, FILE_TYPES, SUB_TYPES
from distribusi import fragments
import uuid
-
+from distribusi.ignore import Ignore
MIME_TYPE = magic.Magic(mime=True)
@@ -205,7 +205,11 @@ def render_dir(args, directory):
def distribusify(args, directory, freg): # noqa
+
+ ignore = Ignore()
+
for root, dirs, files in os.walk(directory):
+ ignore.add(root)
if args.exclude_directory:
if args.verbose:
@@ -234,7 +238,9 @@ def distribusify(args, directory, freg): # noqa
print('Generating directory listing for', root)
for name in sorted(files):
- if 'index.html' not in name:
+ if ignore.test(name):
+ pass
+ elif 'index.html' not in name:
full_path = os.path.join(root, name)
mime = MIME_TYPE.from_file(full_path)
# example: MIME plain/text becomes 'type' plain 'subtype' text
@@ -300,8 +306,9 @@ def distribusify(args, directory, freg): # noqa
html.append('../ ')
for name in dirs:
- print(root)
- if len(path) == 3 and artist:
+ if ignore.test(name):
+ pass
+ elif len(path) == 3 and artist:
print(artist)
# dirs 내부의 콘텐츠를 렌더링해 가져와야 함
fid = freg.get_index(artist, name)
@@ -328,19 +335,3 @@ def distribusify(args, directory, freg): # noqa
os.remove(index)
except Exception as e:
print(e)
-
-def build_index(args, directory, freg):
- #
- # fragments index
- # 임시 데이터 저장
- #
- print("--------- Build main index --------------")
- html = []
- freg_data = freg.get_fragments()
- for f in freg_data:
- index = "{}".format(f.index)
- url = "/{}/#{} ".format(f.artist, index.zfill(4))
- label = "{} 번째 조각".format(f.index)
- html.append('{} '.format(url, label))
- index = os.path.join(directory, 'index.html')
- write_index(args, index, html, html_head, html_footer)
diff --git a/distribusi/distribusi/fragments.py b/distribusi/distribusi/fragments.py
index 8619562..04ace4d 100644
--- a/distribusi/distribusi/fragments.py
+++ b/distribusi/distribusi/fragments.py
@@ -3,7 +3,7 @@ import os
import platform
import json
from operator import itemgetter
-
+from distribusi.ignore import Ignore
class Fragment:
def __init__(self, index, update, directory, artist, file):
@@ -23,9 +23,8 @@ class Fragments:
self.index = {}
self.indextable = []
self.timetable = []
- self.ignore = ['.ignore']
+ self.ignore = Ignore()
- self.ignore_file = '.ignore'
self.index_file = 'index.json'
def init_json(self, directory):
@@ -37,14 +36,6 @@ class Fragments:
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):
"""
@@ -97,11 +88,11 @@ class Fragments:
def preindex(self, directory):
self.init_json(directory)
for root, dirs, files in os.walk(directory):
- self.add_ignore(root)
+ self.ignore.add(root)
arr = root.split("/")
- if arr[2] in self.ignore:
+ if self.ignore.test(arr[2]):
pass # ignore 폴더 처리
else:
# 2뎁스까지만 인덱스 함.
@@ -110,7 +101,7 @@ class Fragments:
for f in files:
if self.is_meta(f):
pass
- elif f in self.ignore:
+ elif self.ignore.test(f):
pass
elif self.has_meta(root, f):
self.occupancy(root, f)
@@ -121,7 +112,7 @@ class Fragments:
for d in dirs:
if self.has_meta(root, d):
self.occupancy(root, d)
- elif d in self.ignore:
+ elif self.ignore.test(d):
pass
else:
self.add_timetable(root, d)
diff --git a/distribusi/distribusi/ignore.py b/distribusi/distribusi/ignore.py
new file mode 100644
index 0000000..f046e12
--- /dev/null
+++ b/distribusi/distribusi/ignore.py
@@ -0,0 +1,23 @@
+import os
+
+
+class Ignore:
+ def __init__(self):
+ self.ignore = ['.ignore']
+ self.ignore_file = '.ignore'
+ return
+
+ def add(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 test(self, target):
+ if target in self.ignore:
+ return True
+ else:
+ return False
diff --git a/distribusi/distribusi/page_template.py b/distribusi/distribusi/page_template.py
index f564e88..812d792 100644
--- a/distribusi/distribusi/page_template.py
+++ b/distribusi/distribusi/page_template.py
@@ -8,6 +8,7 @@ html_head = """
%s
+
diff --git a/test_data/.ignore b/test_data/.ignore
index f26dc52..835a10a 100644
--- a/test_data/.ignore
+++ b/test_data/.ignore
@@ -7,3 +7,5 @@ index.json
Readme.md
src
participants.html
+style.css
+404.html
diff --git a/test_data/carrot/index.html b/test_data/carrot/index.html
index 57a3782..b3b4c27 100644
--- a/test_data/carrot/index.html
+++ b/test_data/carrot/index.html
@@ -7,6 +7,7 @@
+
@@ -60,18 +61,18 @@
-
-
IMG_1334.png #0007
-
IMG_1340.jpg #0005
-
IMG_1690.png #0006
-
IMG_1693.png #0004
+
IMG_1334.png #0016
+
IMG_1340.jpg #0017
+
IMG_1690.png #0018
+
IMG_1693.png #0019
fbdbdbf54d766dd86e5964de01ddc16b.jpg #0020
-
+
../
diff --git a/test_data/index.json b/test_data/index.json
index 02eb48a..3750ad6 100644
--- a/test_data/index.json
+++ b/test_data/index.json
@@ -2,7 +2,7 @@
{
"__Fragment__": {
"index": 0,
- "update": 1605624006.157665,
+ "update": 1607256782.1336884,
"directory": "./test_data/event_lecture",
"artist": "event_lecture",
"file": "event_0000"
@@ -11,7 +11,7 @@
{
"__Fragment__": {
"index": 1,
- "update": 1605624006.16457,
+ "update": 1607256782.1344724,
"directory": "./test_data/event_lecture",
"artist": "event_lecture",
"file": "event_0001"
@@ -20,70 +20,16 @@
{
"__Fragment__": {
"index": 2,
- "update": 1503837516.0,
+ "update": 1607256782.1055331,
"directory": "./test_data/carrot",
"artist": "carrot",
- "file": "\u110c\u1175\u11af\u110c\u116e.mp4"
+ "file": "1030.txt"
}
},
{
"__Fragment__": {
"index": 3,
- "update": 1567569419.653444,
- "directory": "./test_data/carrot",
- "artist": "carrot",
- "file": "\u1101\u116e\u1106\u116e\u11af\u1101\u116e\u1106\u116e\u11af.mov"
- }
- },
- {
- "__Fragment__": {
- "index": 4,
- "update": 1603737283.2655902,
- "directory": "./test_data/grape",
- "artist": "grape",
- "file": "IMG_1693.png"
- }
- },
- {
- "__Fragment__": {
- "index": 5,
- "update": 1603737296.0838926,
- "directory": "./test_data/grape",
- "artist": "grape",
- "file": "IMG_1340.jpg"
- }
- },
- {
- "__Fragment__": {
- "index": 6,
- "update": 1603737307.8227732,
- "directory": "./test_data/grape",
- "artist": "grape",
- "file": "IMG_1690.png"
- }
- },
- {
- "__Fragment__": {
- "index": 7,
- "update": 1603737326.0093782,
- "directory": "./test_data/grape",
- "artist": "grape",
- "file": "IMG_1334.png"
- }
- },
- {
- "__Fragment__": {
- "index": 8,
- "update": 1603737524.8806562,
- "directory": "./test_data/grape",
- "artist": "grape",
- "file": "sample.pdf"
- }
- },
- {
- "__Fragment__": {
- "index": 9,
- "update": 1604243002.5126157,
+ "update": 1607256782.1057456,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "RTF\ud14c\uc2a4\ud2b8.rtf"
@@ -91,8 +37,8 @@
},
{
"__Fragment__": {
- "index": 10,
- "update": 1604247403.2948427,
+ "index": 4,
+ "update": 1607256782.1060278,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "md\uc4f0\uae30.md"
@@ -100,44 +46,8 @@
},
{
"__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__": {
- "index": 13,
- "update": 1604851924.8802848,
- "directory": "./test_data/fig",
- "artist": "fig",
- "file": "20201029"
- }
- },
- {
- "__Fragment__": {
- "index": 14,
- "update": 1605496049.4042296,
- "directory": "./test_data/",
- "artist": "",
- "file": "404.html"
- }
- },
- {
- "__Fragment__": {
- "index": 15,
- "update": 1605496049.4053128,
+ "index": 5,
+ "update": 1607256782.1060853,
"directory": "./test_data/carrot",
"artist": "carrot",
"file": "test002.txt"
@@ -145,8 +55,35 @@
},
{
"__Fragment__": {
- "index": 16,
- "update": 1605496049.4058702,
+ "index": 6,
+ "update": 1607256782.1062121,
+ "directory": "./test_data/carrot",
+ "artist": "carrot",
+ "file": "txt\uc4f0\uae30.txt"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 7,
+ "update": 1607256782.1183975,
+ "directory": "./test_data/carrot",
+ "artist": "carrot",
+ "file": "\uafb8\ubb3c\uafb8\ubb3c.mov"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 8,
+ "update": 1607256782.1308887,
+ "directory": "./test_data/carrot",
+ "artist": "carrot",
+ "file": "\uc9c8\uc8fc.mp4"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 9,
+ "update": 1607256782.1359093,
"directory": "./test_data/fig",
"artist": "fig",
"file": "20201020"
@@ -154,8 +91,26 @@
},
{
"__Fragment__": {
- "index": 17,
- "update": 1605496049.4062285,
+ "index": 10,
+ "update": 1607256782.144392,
+ "directory": "./test_data/fig",
+ "artist": "fig",
+ "file": "20201022"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 11,
+ "update": 1607256782.1451015,
+ "directory": "./test_data/fig",
+ "artist": "fig",
+ "file": "20201029"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 12,
+ "update": 1607256782.1454825,
"directory": "./test_data/fig",
"artist": "fig",
"file": "fig002.txt"
@@ -163,8 +118,8 @@
},
{
"__Fragment__": {
- "index": 18,
- "update": 1605496049.4064658,
+ "index": 13,
+ "update": 1607256782.1458695,
"directory": "./test_data/fig",
"artist": "fig",
"file": "test.txt"
@@ -172,17 +127,62 @@
},
{
"__Fragment__": {
- "index": 19,
- "update": 1605496049.406584,
+ "index": 14,
+ "update": 1607256782.1459706,
"directory": "./test_data/fig",
"artist": "fig",
"file": "test001.txt"
}
},
+ {
+ "__Fragment__": {
+ "index": 15,
+ "update": 1607256782.1462324,
+ "directory": "./test_data/",
+ "artist": "",
+ "file": "fragment.html"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 16,
+ "update": 1607256782.2283018,
+ "directory": "./test_data/grape",
+ "artist": "grape",
+ "file": "IMG_1334.png"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 17,
+ "update": 1607256782.2359385,
+ "directory": "./test_data/grape",
+ "artist": "grape",
+ "file": "IMG_1340.jpg"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 18,
+ "update": 1607256782.2999306,
+ "directory": "./test_data/grape",
+ "artist": "grape",
+ "file": "IMG_1690.png"
+ }
+ },
+ {
+ "__Fragment__": {
+ "index": 19,
+ "update": 1607256782.3536453,
+ "directory": "./test_data/grape",
+ "artist": "grape",
+ "file": "IMG_1693.png"
+ }
+ },
{
"__Fragment__": {
"index": 20,
- "update": 1605496049.407514,
+ "update": 1607256782.3545525,
"directory": "./test_data/grape",
"artist": "grape",
"file": "fbdbdbf54d766dd86e5964de01ddc16b.jpg"
@@ -191,19 +191,10 @@
{
"__Fragment__": {
"index": 21,
- "update": 1606474058.2468154,
- "directory": "./test_data/carrot",
- "artist": "carrot",
- "file": "1030.txt"
- }
- },
- {
- "__Fragment__": {
- "index": 22,
- "update": 1606499064.7076151,
- "directory": "./test_data/",
- "artist": "",
- "file": "fragment.html"
+ "update": 1607256782.3548856,
+ "directory": "./test_data/grape",
+ "artist": "grape",
+ "file": "sample.pdf"
}
}
]
\ No newline at end of file
diff --git a/test_data/src/ai/index.html b/test_data/src/ai/index.html
index b7cc3b5..6159ad8 100644
--- a/test_data/src/ai/index.html
+++ b/test_data/src/ai/index.html
@@ -7,6 +7,7 @@
+
diff --git a/test_data/src/img/index.html b/test_data/src/img/index.html
index b7cc3b5..6159ad8 100644
--- a/test_data/src/img/index.html
+++ b/test_data/src/img/index.html
@@ -7,6 +7,7 @@
+
diff --git a/test_data/src/index.html b/test_data/src/index.html
index 675f7f5..90df598 100644
--- a/test_data/src/index.html
+++ b/test_data/src/index.html
@@ -7,6 +7,7 @@
+
@@ -60,7 +61,6 @@
-
original.svg #-1
@@ -407,15 +407,11 @@
d="M475.86,684.78a24.08,24.08,0,0,1-.64,4.35c-1.09,4.1-2.64,8.86-5.82,13a14.63,14.63,0,0,1-3.84,3.56c-.74.46-1.48.94-2.22,1.41-1.46.94-3,1.92-4.52,2.81a25.32,25.32,0,0,1-9.45,2.9c-3.25.44-6.56.81-9.76,1.17l-.76.09c-2.41.27-4.81.51-7,.72-3.53.33-7.27.69-11,1-1.1.1-2.19.16-3.29.23l-2.77.19c-5.21.42-10.64.62-16.5.62l-3.83,0h-2.88c-2.32,0-4.71,0-7.13,0a36.17,36.17,0,0,1-12.65-2.66,19.61,19.61,0,0,1-6.64-4.43c-3.19-3.11-6.15-5.82-9.06-8.29-3.87-3.28-5.68-7.93-5.26-13.46.49-6.33,1.89-11.3,4.39-15.67.5-.86.94-1.75,1.31-2.51a13.35,13.35,0,0,1,4.37-5.09,51.22,51.22,0,0,1,16.73-8c2.78-.74,5.54-1.51,8.31-2.28,4.17-1.16,8.49-2.36,12.76-3.45a64.6,64.6,0,0,1,6.45-1.21q1.41-.21,2.82-.45l3.21-.57c2.45-.43,5-.88,7.49-1.28,1.31-.21,2.61-.44,3.91-.67a81.08,81.08,0,0,1,10.35-1.39h.34c.7,0,1.42-.07,2.16-.06l8,.09,12,.13a5.13,5.13,0,0,1,2.51.75l1.25.7c2,1.13,4.13,2.3,6.23,3.3a11.85,11.85,0,0,1,5.07,4.49A28.12,28.12,0,0,1,474.3,665,78.91,78.91,0,0,1,475.86,684.78Zm-4.94-19.17a24.71,24.71,0,0,0-3.29-9,8.42,8.42,0,0,0-3.64-3.22c-2.21-1-4.36-2.25-6.43-3.41l-1.24-.69a2,2,0,0,0-.88-.32q-6,0-12-.13l-8-.09c-.63,0-1.27,0-1.95.06h-.35a76.45,76.45,0,0,0-9.9,1.33c-1.32.24-2.65.48-4,.69-2.48.39-5,.84-7.43,1.27l-3.22.57c-1,.17-1.93.31-2.89.46-2.13.33-4.14.64-6.12,1.14-4.24,1.09-8.54,2.28-12.69,3.44-2.78.77-5.55,1.54-8.34,2.28a47.83,47.83,0,0,0-15.61,7.47,10,10,0,0,0-3.29,3.79c-.4.82-.87,1.79-1.42,2.74-2.25,3.91-3.5,8.43-3.95,14.23-.34,4.44,1,8,4.06,10.57s6,5.29,9.24,8.46a16,16,0,0,0,5.48,3.67,32.5,32.5,0,0,0,11.46,2.44c2.39,0,4.77,0,7.07,0h2.93c7.24.11,13.79-.08,20-.58l2.83-.19c1.07-.07,2.14-.14,3.2-.23,3.68-.31,7.42-.66,10.93-1,2.22-.21,4.6-.44,7-.71l.77-.09c3.18-.36,6.46-.73,9.68-1.16A21.62,21.62,0,0,0,457.1,707c1.48-.85,3-1.8,4.39-2.72q1.11-.74,2.25-1.44a11.28,11.28,0,0,0,2.94-2.74c2.81-3.67,4.22-8,5.23-11.81a19.84,19.84,0,0,0,.52-3.71A75,75,0,0,0,470.92,665.61Z"
transform="translate(-97.5 -31)" />Nodl
- -1
+
#-1
../
+
#-1
-
-
author.ai
author__0set.svg
author__109.svg
author_blblbg.svg
@@ -454,7 +450,7 @@
instagram.svg
logo.svg
test.svg
-
-1
+
#-1