def read_config():
global settings
global extensions_map
exist = os.path.isfile(setting_file_name)
if not exist:
print 'Creating config file...'
shutil.copyfile(default_setting_file_name, setting_file_name)
print 'Edit config.json and launch the script again.'
sys.exit()
with open(setting_file_name) as data_file:
settings = json.load(data_file)
####################################################################
#Load default mimetypes and update them with config.json extensions#
####################################################################
if not mimetypes.inited:
mimetypes.init() # try to read system mime.types
extensions_map = mimetypes.types_map.copy()
extensions_map.update({
'': 'application/octet-stream' # Default
})
extensions_map.update(settings['extensions']) # Read extensions from config.json
#####################################################################
return
评论列表
文章目录