def lazy_load_dict(dict_path, dictionary_name, source_path, mapper=lambda x: x): if file_exists(dict_path, dictionary_name): dictionary = load(dict_path, dictionary_name) else: dictionary = create_dict(source_path) save(dictionary, dict_path, dictionary_name) return {mapper(k): v for k, v in dictionary.items()}
def add(self): self.verify() yield self.is_owner() yield files.save(self.request.files['file'][0]['body'], 'avatar', set_id=self['avatar'], name=self['name'])
def add(self): self.verify() published = yield self.is_owner() if published: raise Stink("can't add an image to a published page") yield files.save(self.request.files['file'][0]['body'], 'page', set_id=self['page'])
def save_level_info(level_info): save(level_info, level_info_path, level_info_file)
def save_transitions(transitions): log.debug("Saving transitions") save(transitions, transition_path)
def save(self): import files import links print("Saving network ...") files.save(self.network, self.links)
def reset(): data = 'HISTORY\n' FILES.save(FILENAME, data)
def saveEvent(type, seconds=0): print("HISTORY - SAVE EVENT") data = FILES.load(FILENAME) record = type + "|" + TIMES.now() + "|" + str(seconds) + "\n" data.append(record) FILES.save(FILENAME, data)