2023-02-19 21:59:05 +08:00
|
|
|
import CustomConfig, DecoratorCore, Progressbar
|
|
|
|
import os, sys, getopt, logging, time
|
2021-09-08 21:28:09 +08:00
|
|
|
|
2023-02-19 21:59:05 +08:00
|
|
|
# print banner
|
|
|
|
print('Super Script Decorator')
|
|
|
|
print('Homepage: https://github.com/yyc12345/SuperScriptMaterializer')
|
|
|
|
print('Report bug: https://github.com/yyc12345/SuperScriptMaterializer/issues')
|
|
|
|
print('')
|
|
|
|
|
|
|
|
# try get args
|
2021-09-08 21:28:09 +08:00
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "hi:o:e:c:fd")
|
|
|
|
except getopt.GetoptError:
|
|
|
|
print('Wrong arguments!')
|
|
|
|
print('python SuperScriptViewer.py -i <import.txt> -o <decorated.db> -c <codec_name> -d')
|
|
|
|
sys.exit(1)
|
2023-02-19 21:59:05 +08:00
|
|
|
|
|
|
|
# analyze args
|
|
|
|
cfg: CustomConfig.CustomConfig = CustomConfig.CustomConfig()
|
2021-09-08 21:28:09 +08:00
|
|
|
for opt, arg in opts:
|
|
|
|
if opt == '-h':
|
|
|
|
print('python SuperScriptViewer.py -i <import.txt> -o <decorated.db> -c <codec_name> -d')
|
|
|
|
sys.exit(0)
|
|
|
|
elif opt == '-i':
|
2023-02-19 21:59:05 +08:00
|
|
|
cfg.m_ImportTxt = arg
|
2021-09-08 21:28:09 +08:00
|
|
|
elif opt == '-o':
|
2023-02-19 21:59:05 +08:00
|
|
|
cfg.m_DecoratedDb = arg
|
2021-09-08 21:28:09 +08:00
|
|
|
elif opt == '-c':
|
2023-02-19 21:59:05 +08:00
|
|
|
cfg.m_DatabaseEncoding = arg
|
2021-09-08 21:28:09 +08:00
|
|
|
elif opt == '-d':
|
2023-02-19 21:59:05 +08:00
|
|
|
cfg.m_DebugMode = True
|
2021-09-08 21:28:09 +08:00
|
|
|
|
2023-02-19 21:59:05 +08:00
|
|
|
# regulate data
|
|
|
|
if not cfg.Regulate():
|
|
|
|
# failed. exit program
|
2021-09-08 21:28:09 +08:00
|
|
|
sys.exit(1)
|
|
|
|
|
2023-02-19 21:59:05 +08:00
|
|
|
# if in debug mode, run directly
|
|
|
|
# otherwise, run with a try wrapper.
|
|
|
|
if cfg.m_DebugMode:
|
2023-02-20 20:54:11 +08:00
|
|
|
DecoratorCore.Run(cfg)
|
2021-09-08 21:28:09 +08:00
|
|
|
else:
|
|
|
|
try:
|
2023-02-20 20:54:11 +08:00
|
|
|
DecoratorCore.Run(cfg)
|
2023-02-19 21:59:05 +08:00
|
|
|
except Exception as ex:
|
2021-09-08 21:28:09 +08:00
|
|
|
print("!!! An error occurs. Please report follwoing error output and reproduce file to developer. !!!")
|
|
|
|
logging.exception(ex)
|
|
|
|
sys.exit(1)
|
2023-02-19 21:59:05 +08:00
|
|
|
|
|
|
|
print('Decorated database generation done.')
|
2021-09-08 21:28:09 +08:00
|
|
|
|