示例#1
0
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()}
示例#2
0
 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'])
示例#3
0
 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'])
示例#4
0
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)
示例#6
0
 def save(self):
     import files
     import links
     print("Saving network ...")
     files.save(self.network, self.links)
示例#7
0
def reset():
    data = 'HISTORY\n'
    FILES.save(FILENAME, data)
示例#8
0
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)
示例#9
0
 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'])
示例#10
0
 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'])