forked from FRC8725/FRC8725-Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.py
58 lines (52 loc) · 2.04 KB
/
render.py
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
import os
import html, article, portfolio, rss, siteCover
VERSION = 'v1.0.1'
DESCRIPTION = '''
--h, -help
--v, -version
-custom <custom directory path>
-update <update type (all / config / article / portfolio)>
'''
CUSTOM_DIR_PATH = 'custom_frc8725'
DATA_DIR_PATH = 'data'
def process(customDirPath, dataDirPath, updateValueList):
moduleList = [article, portfolio, html, rss, siteCover]
if 'all' in updateValueList:
for module in moduleList:
getattr(module, 'process')(customDirPath, dataDirPath)
else:
processModule = {hash(module):False for module in moduleList}
if 'config' in updateValueList:
for module in [html, rss, siteCover]: processModule[hash(module)] = True
if 'article' in updateValueList:
for module in [article, rss]: processModule[hash(module)] = True
if 'portfolio' in updateValueList:
for module in [portfolio]: processModule[hash(module)] = True
for module in moduleList:
if processModule[hash(module)]:
getattr(module, 'process')(customDirPath, dataDirPath)
if __name__ == '__main__':
argTable = {
'--v': 'version', '-version': 'version',
'--h': 'help', '-help': 'help',
'-custom': 'custom',
'-update': 'update'
}
argData = {'default': []}
lastList = argData['default']
for arg in os.sys.argv[1:]:
if arg in argTable:
valueList = []
argData[argTable[arg]] = valueList
lastList = valueList
else:
lastList.append(arg)
if argData.get('help', None) != None: print(DESCRIPTION)
if argData.get('version', None) != None: print(VERSION)
customDirPath = CUSTOM_DIR_PATH
customValueList = argData.get('custom', None)
if customValueList != None and len(customValueList) > 0:
customDirPath = customValueList[0]
updateValueList = argData.get('update', None)
if updateValueList != None and len(updateValueList) > 0:
process(customDirPath, DATA_DIR_PATH, updateValueList)