-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9707cad
commit 6935273
Showing
4 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
import json, os | ||
|
||
class HandleJson: | ||
def write_json(self, json_file, data): | ||
pass | ||
# reformat data as actual json format | ||
def add_link(self): | ||
self.dic = { | ||
"folder_number" : f"{len(self.data)}", | ||
# "folder1" : { | ||
# "folder1_url" : "", | ||
# "file_number" : "", | ||
# "file1" : "file1 url", | ||
# "file2" : "file2 url" | ||
# }, | ||
} | ||
|
||
for folder, file in self.data.items(): | ||
inner_dic = dict() | ||
inner_dic["folder_url"] = "https://github.com/mursalatul/code-park/tree/master/" + folder | ||
inner_dic["file_number"] = f"{len(file)}" | ||
file.sort() | ||
for f in file: | ||
inner_dic[f] = inner_dic["folder_url"] + f"/{f}" | ||
self.dic[folder] = inner_dic | ||
|
||
|
||
def write_json(self, data): | ||
self.data = data | ||
self.add_link() | ||
with open("DOC_DATA.json", "w") as outfile: | ||
json.dump(self.dic, outfile) |