mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
Merge branch 'dev'
This commit is contained in:
commit
5884fcfc0c
1 changed files with 12 additions and 9 deletions
|
@ -28,6 +28,7 @@ try:
|
||||||
with open('config.json') as infile:
|
with open('config.json') as infile:
|
||||||
config = jsn.load(infile)
|
config = jsn.load(infile)
|
||||||
print('LOADED : config.json')
|
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,
|
||||||
|
@ -37,28 +38,30 @@ except FileNotFoundError:
|
||||||
|
|
||||||
|
|
||||||
def setdefault(filename, default=None, json=False):
|
def setdefault(filename, default=None, json=False):
|
||||||
if not json:
|
if json:
|
||||||
try:
|
|
||||||
with open(filename, 'rb') as infile:
|
|
||||||
print('LOADED : {}'.format(filename))
|
|
||||||
return pkl.load(infile)
|
|
||||||
except FileNotFoundError:
|
|
||||||
with open(filename, 'wb+') as iofile:
|
|
||||||
print('FILE NOT FOUND : {} created and loaded with default values'.format(filename))
|
|
||||||
pkl.dump(default, iofile)
|
|
||||||
iofile.seek(0)
|
|
||||||
return pkl.load(iofile)
|
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
with open(filename, 'rb') as infile:
|
with open(filename, 'rb') as infile:
|
||||||
print(f'LOADED : {filename}')
|
print(f'LOADED : {filename}')
|
||||||
return jsn.load(infile)
|
return jsn.load(infile)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
with open(filename, 'wb+') as iofile:
|
with open(filename, 'wb+') as iofile:
|
||||||
print(f'FILE NOT FOUND : {filename} created and loaded with default values')
|
print(f'FILE NOT FOUND : {filename} created and loaded with default values')
|
||||||
jsn.dump(default, iofile)
|
jsn.dump(default, iofile)
|
||||||
iofile.seek(0)
|
iofile.seek(0)
|
||||||
return jsn.load(iofile)
|
return jsn.load(iofile)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
with open(filename, 'rb') as infile:
|
||||||
|
print(f'LOADED : {filename}')
|
||||||
|
return pkl.load(infile)
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
with open(filename, 'wb+') as iofile:
|
||||||
|
print(f'FILE NOT FOUND : {filename} created and loaded with default values')
|
||||||
|
pkl.dump(default, iofile)
|
||||||
|
iofile.seek(0)
|
||||||
|
return pkl.load(iofile)
|
||||||
|
|
||||||
|
|
||||||
def load(filename, *, json=False):
|
def load(filename, *, json=False):
|
||||||
|
|
Loading…
Reference in a new issue