diff --git a/distribusi/distribusi/fragments.py b/distribusi/distribusi/fragments.py index b414c49..6841071 100644 --- a/distribusi/distribusi/fragments.py +++ b/distribusi/distribusi/fragments.py @@ -25,10 +25,12 @@ class Fragments: self.ignore = ['.ignore'] self.ignore_file = '.ignore' - self.index_file = 'test_data/index.json' + self.index_file = 'index.json' - if os.path.isfile(self.index_file): - with open(self.index_file) as json_file: + def init_json(self, directory): + index_path = os.path.join(directory, self.index_file) + if os.path.isfile(index_path): + with open(index_path) as json_file: self.json_data = json.load(json_file) self.temp_data = {"fragments":[]} @@ -92,28 +94,40 @@ class Fragments: return False def preindex(self, directory): + self.init_json(directory) for root, dirs, files in os.walk(directory): self.add_ignore(root) + + print(root) + arr = root.split("/") - # 2뎁스까지만 인덱스 함. - if arr.__len__() < 4: - # files index - for f in files: - if self.is_meta(f): - pass - 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): - self.occupancy(root, d) - else: - self.add_timetable(root, d) + + print(arr[2]) + + if arr[2] in self.ignore: + pass # ignore 폴더 처리 + else: + # 2뎁스까지만 인덱스 함. + if arr.__len__() < 4: + # files index + for f in files: + if self.is_meta(f): + pass + 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): + self.occupancy(root, d) + elif d in self.ignore: + pass + else: + self.add_timetable(root, d) def postindex(self): self.timetable = sorted(self.timetable, key=lambda fragment: fragment.update) diff --git a/distribusi/test.py b/distribusi/test.py index 576276c..90ab328 100644 --- a/distribusi/test.py +++ b/distribusi/test.py @@ -2,7 +2,6 @@ # 2020. 10. 26 from distribusi.cli import build_argparser, distribusify from distribusi import fragments -from distribusi.distribusi import build_index parser = build_argparser() args = parser.parse_args() @@ -13,6 +12,4 @@ freg = fragments.Fragments() freg.preindex(data_path) freg.postindex() -distribusify(args, data_path, freg) - -build_index(args, data_path, freg) \ No newline at end of file +distribusify(args, data_path, freg) \ No newline at end of file diff --git a/test_data/.ignore b/test_data/.ignore index a14a6c5..7f373fa 100644 --- a/test_data/.ignore +++ b/test_data/.ignore @@ -6,3 +6,5 @@ participants.html fragment.html home.html intorudction.json +src +index.json \ No newline at end of file