# HG changeset patch # User Dennis Fink # Date 2015-07-11 22:26:13 # Node ID baeecfacba3a7b86fd8a8590d33cd9c1b7ff2c6e # Parent 3e571d06ecc985141359e41b4505ef95d9bcacbd Remove active.py as it is not needed anymore diff --git a/spaceapi/active.py b/spaceapi/active.py deleted file mode 100644 --- a/spaceapi/active.py +++ /dev/null @@ -1,46 +0,0 @@ -import json -import os.path - -from .utils import ActiveStatus - -default_json_file = os.path.abspath('default.json') -last_state_file = os.path.abspath('laststate.json') - -if not os.path.exists(default_json_file): - raise RuntimeError('default.json does not exists!') -elif not os.path.isfile(default_json_file): - raise RuntimeError('defaul.json is not a file!') - - -default_json = {} -active_json = ActiveStatus() - - -def _reload_json(): - global default_json - global active_json - - with open(default_json_file, encoding='utf-8') as f: - default_json = json.load(f) - - if os.path.exists(last_state_file) and os.path.isfile(last_state_file): - with open(last_state_file, encoding='utf-8') as f: - active_json.update(json.load(f)) - - if os.path.getmtime(last_state_file) \ - < os.path.getmtime(default_json_file): - backup_state_open = active_json['state']['open'] - backup_state_lastchange = active_json['state']['lastchange'] - active_json.update(default_json) - active_json['state']['open'] = backup_state_open - active_json['state']['lastchange'] = backup_state_lastchange - else: - active_json.update(default_json) - -_reload_json() - - -def save_last_state(): - - with open(last_state_file, mode='w', encoding='utf-8') as f: - json.dump(active_json, f, sort_keys=True)