added BufferedJSON.exists() method, use it in get_time/get_data
This commit is contained in:
@ -25,11 +25,20 @@ class BufferedJSON:
|
||||
|
||||
|
||||
def get_time(self):
|
||||
if not self.exists():
|
||||
return -1
|
||||
return os.path.getmtime(self.fname)
|
||||
|
||||
def get_data(self, *args, **kwargs):
|
||||
if not self.exists():
|
||||
return {}
|
||||
return json_load(self.fname, *args, **kwargs)
|
||||
|
||||
def exists(self):
|
||||
if not self.fname:
|
||||
return False
|
||||
return os.path.exists(self.fname)
|
||||
|
||||
|
||||
|
||||
def json_load(filename, *args, **kwargs):
|
||||
|
Reference in New Issue
Block a user