示例#1
0
 def on_enter(self, *args):
     store = JsonStore(DATA_DIR)
     if not os.path.exists(DATA_DIR) or store.count() == 0:
         store.put("latest_game_id", id=None)
     App.get_running_app().game_id = None
     self.rv.data = []
     self.populate()
示例#2
0
 def load_data(self):
     store = JsonStore(storage)
     if store.count() > 0:
         for key in store:
             item = ListItemWithCheckbox(text=store[key]['text'])
             item.children[0].children[0].active = store[key]['checkbox']
             self.style.get_screen('StartScreen').ids.my_list.add_widget(
                 item)
示例#3
0
class addStory(object):
    '''
    This class is used for adding story to the game

    Syntax for the story is a key based dictionary, these keys are hexadacimal numbers
    that will be used to track progress. Starting point is 1, so if scenario 1 had 3
    possible options then there would be 11, 12, and 13. If 13 had 2 options then it would
    be 131, and 132. This will continue until there is a string of 16 characters

    basic syntax: {key
    '''

    def __init__(self):
        self.File = raw_input("Which story would you like to edit?\n\n").lower()
        self.data = JsonStore(self.File + '.json')
        self.start = 1 #default start code
        if self.data.count(): #If file has been started
            print '\nLooking for where you left off...\n'
            keys = self.data.keys()
            leftOff = int(keys[len(keys) - 1])
            print ('It seems like you left off at event number'
                    ' %d, so let\'s move on to number %d.'
                    % (leftOff, leftOff + 1)
                    )
            self.start = leftOff
        self.addToDBLoop(self.start)

    def addToDBLoop(self, number):
        event = raw_input('What is event number %d?\n' % number).lower()
        optionsStr = raw_input(('What are the available options for player?\n'
            'If none just type \'none\'.\n')).lower().split()
        c = 0
        options = {}
        for o in optionsStr:
            c += 1
            options[o] = str(number) + str(c)
        self.data.put(str(number), event = event, options = options)
示例#4
0
# Returns a list of running jobs for your character, up to 90 days or 10000 rows. (cache: 15 minutes)
charIndustry = 'char/IndustryJobs.xml.aspx?keyID=%s&vCode=%s&characterID=%s'

# Defaults that will be replaced by the API returned data.
# ['Server Online', Players, Cache Expire]
# serverStatus = ['', '0', serverTime]

# Global variables to store the cacheUtil time and table rows.
jobsCachedUntil = serverTime
starbaseCachedUntil = serverTime

# This is where we are storing our API keys.
pilotRows = []

if pilotCache.count() > 0:
    print('Character Data Already Exists: %s Entries' % (len(pilotCache)))
    for key in pilotCache:
        print(key)  # Using characterID as key
        print(pilotCache.get(key)['characterName'])
        # keyID, vCode, characterID, characterName, corporationID, corporationName, keyType, keyExpires, skills, isActive
        pilotRows.append(
            Character(
                pilotCache.get(key)['keyID'],
                pilotCache.get(key)['vCode'],
                pilotCache.get(key)['characterID'],
                pilotCache.get(key)['characterName'],
                pilotCache.get(key)['corporationID'],
                pilotCache.get(key)['corporationName'],
                pilotCache.get(key)['keyType'],
                pilotCache.get(key)['keyExpires'],
示例#5
0
文件: config.py 项目: EluOne/Nesi
charIndustry = 'char/IndustryJobs.xml.aspx?keyID=%s&vCode=%s&characterID=%s'


# Defaults that will be replaced by the API returned data.
# ['Server Online', Players, Cache Expire]
# serverStatus = ['', '0', serverTime]

# Global variables to store the cacheUtil time and table rows.
jobsCachedUntil = serverTime
starbaseCachedUntil = serverTime


# This is where we are storing our API keys.
pilotRows = []

if pilotCache.count() > 0:
    print('Character Data Already Exists: %s Entries' % (len(pilotCache)))
    for key in pilotCache:
        print(key)  # Using characterID as key
        print(pilotCache.get(key)['characterName'])
        # keyID, vCode, characterID, characterName, corporationID, corporationName, keyType, keyExpires, skills, isActive
        pilotRows.append(Character(pilotCache.get(key)['keyID'], pilotCache.get(key)['vCode'],
                                   pilotCache.get(key)['characterID'], pilotCache.get(key)['characterName'],
                                   pilotCache.get(key)['corporationID'], pilotCache.get(key)['corporationName'],
                                   pilotCache.get(key)['keyType'], pilotCache.get(key)['keyExpires'],
                                   pilotCache.get(key)['skills'], pilotCache.get(key)['isActive']))
else:
    # No Pilot data.
    print('No Pilot data.')

示例#6
0
# verificanco se existe
if store.exists('tito'):
    print('tite exists:', store.get('tito'))

# deletando valor
store.delete('tito')

# trz todas ocorrencia em que nome é igual Gabriel
for item in store.find(name='Gabriel'):
    print('tshirtmans index key is', item[0])
    print('his key value pairs are', str(item[1]))

entries = list(
    store.find(name='Mathieu'))  #pode ser usado convertido em uma lista

store.clear()  # Limpe todo o armazenamento.
store.count()  # Retorna o número de entradas armazenadas.
store.keys()  #Retorna uma lista com todas as chaves armazenadas.

# ==========================================================
# ASSINCRONA
# se definir o callback a funcao torna se assincrona


def my_callback(store, key, result):
    print('the key', key, 'has a value of', result)


mystore.get('plop', callback=my_callback)