This repository was archived by the owner on Dec 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.py
More file actions
106 lines (88 loc) · 3.11 KB
/
Copy pathbuild.py
File metadata and controls
106 lines (88 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import os
def loadjson(file):
from json import load
f = open(file, encoding="utf8")
return load(f)
builddata = [
{
"source": "characters.json",
"title": "Characters",
"category": "characters",
"categories": "watch-dogs2 watch-dogs characters models character-list",
"description": "A list of every Character Model in Watch Dogs 2 with Images."
},
{
"source": "lmalayers.json",
"title": "LMA Layers",
"category": "lmalayers",
"categories": "watch-dogs2 watch-dogs lmalayers lma layers",
"description": "A list of every LMA-Layer in Watch Dogs 2."
},
{
"source": "vehicles.json",
"title": "Vehicles",
"category": "vehicles",
"categories": "watch-dogs2 watch-dogs vehicles vehicle-list",
"description": "A list of every Vehicle Model in Watch Dogs 2 with Images."
},
{
"source": "weather.json",
"title": "Weather",
"category": "weather",
"categories": "watch-dogs2 watch-dogs weather weather-showcase weather-list",
"description": "A list of every Weather Type in Watch Dogs 2 with Videos."
}
]
example_header = """---
layout: post
title: "{}"
date: 2022-01-01 00:00:01 +0000
categories: {}
description: "{}"
---
"""
table_basic = """| ID | Name | Image/Video
| - | - | ----------
"""
table_basic_loc = """| ID | Name | Image/Video | Location
| - | - | ---------- | -
"""
table_empty_row = """| | | """
table_empty_row_loc = """| | | """
lozad_video = "< video file={} >"
lozad_image = "< image file={} >"
for data in builddata:
build_json = loadjson("./source_data/{}".format(data["source"]))
with open("./content/{}/_index.md".format(data["category"]), "w+", encoding="utf-8") as f:
site_data = []
for item in build_json:
site_data.append(item["name"])
f.write(example_header.format(data["title"], data["categories"], data["description"]))
if (data["category"] == "lmalayers"):
f.write(table_basic_loc)
else:
f.write(table_basic)
for item in build_json:
save_image = ""
try:
if (item["image"] == "1"):
save_image = "{{" + lozad_image.format("/images/webp/{}/{}".format(data["category"], item["name"].lower())) + "}}"
except KeyError:
pass
try:
if (item["weathervideo"] == "1"):
save_image = "{{" + lozad_video.format("/videos/webm/{}/{}".format(data["category"], item["name"])) + "}}"
except KeyError:
pass
location = ""
try:
if (item["location"] != ""):
location = item["location"]
except KeyError:
pass
if (data["category"] == "lmalayers"):
f.write("| {} | {} | {} | {}\n".format(item["id"], item["name"], save_image, location))
else:
f.write("| {} | {} | {}\n".format(item["id"], item["name"], save_image))
f.write(table_empty_row)
f.close()