mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 14:27:27 +00:00
Added "LOADED :"
This commit is contained in:
parent
22afd87d8b
commit
e927ccca9d
1 changed files with 4 additions and 4 deletions
|
@ -22,23 +22,23 @@ print('\nPID : {}\n'.format(os.getpid()))
|
||||||
try:
|
try:
|
||||||
with open('config.json') as infile:
|
with open('config.json') as infile:
|
||||||
config = jsn.load(infile)
|
config = jsn.load(infile)
|
||||||
print('config.json loaded.')
|
print('LOADED : config.json')
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
with open('config.json', 'w') as outfile:
|
with open('config.json', 'w') as outfile:
|
||||||
jsn.dump({'client_id': 0, 'info_channel': 0, 'owner_id': 0, 'permissions': 126016,
|
jsn.dump({'client_id': 0, 'info_channel': 0, 'owner_id': 0, 'permissions': 126016,
|
||||||
'playing': 'a game', 'prefix': [',', 'm,'], 'token': 'str'}, outfile, indent=4, sort_keys=True)
|
'playing': 'a game', 'prefix': [',', 'm,'], 'token': 'str'}, outfile, indent=4, sort_keys=True)
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
'Config file not found: config.json created with abstract values. Restart run.py with correct values.')
|
'FILE NOT FOUND : config.json created with abstract values. Restart run.py with correct values')
|
||||||
|
|
||||||
|
|
||||||
def setdefault(filename, default=None):
|
def setdefault(filename, default=None):
|
||||||
try:
|
try:
|
||||||
with open(filename, 'rb') as infile:
|
with open(filename, 'rb') as infile:
|
||||||
print('{} loaded.'.format(filename))
|
print('LOADED : {}'.format(filename))
|
||||||
return pkl.load(infile)
|
return pkl.load(infile)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
with open(filename, 'wb+') as iofile:
|
with open(filename, 'wb+') as iofile:
|
||||||
print('File not found: {} created and loaded with default values.'.format(filename))
|
print('FILE NOT FOUND : {} created and loaded with default values'.format(filename))
|
||||||
pkl.dump(default, iofile)
|
pkl.dump(default, iofile)
|
||||||
iofile.seek(0)
|
iofile.seek(0)
|
||||||
return pkl.load(iofile)
|
return pkl.load(iofile)
|
||||||
|
|
Loading…
Reference in a new issue