def loadTitleBuffer(buffer, silent=False): firstLine = True map = ['id', 'key', 'name'] for line in buffer.split('\n'): line = line.strip() if len(line) == 0 or line[0] == '#': continue if firstLine: firstLine = False if re.match('[A-Za-z\|\s]+', line, re.I): map = line.split('|') continue t = Title.Title() t.loadCsv(line, map) if not t.id in keys(): titles[t.id] = Title.Title() titleKey = titles[t.id].key titles[t.id].loadCsv(line, map) if not silent and titleKey != titles[t.id].key: Print.info('Added new title key for ' + str(titles[t.id].name) + '[' + str(t.id) + ']')
def main(): #global donePlaying #global titleScreen #global howToPlay #global mainGame #global gameOver #global creditScreen #global startMenu #global menu #global clearSprites while Globals.donePlaying != True: print Globals.donePlaying if Globals.titleScreen == True: Title.title() elif Globals.howToPlay == True: Instructions.instructions() elif Globals.mainGame == True: Game.game() elif Globals.pauseMenu == True: PauseMenu.pausemenu() elif Globals.gameOver == True: GameOver.gameover() elif Globals.creditScreen == True: Credits.credits() elif Globals.winScreen == True: Win.win()
def fileName(self): bt = None if not self.titleId in Titles.keys(): if not Title.getBaseId(self.titleId) in Titles.keys(): Print.info('could not find title key for ' + self.titleId + ' or ' + Title.getBaseId(self.titleId)) return None bt = Titles.get(Title.getBaseId(self.titleId)) t = Title() t.loadCsv(self.titleId + '0000000000000000|0000000000000000|' + bt.name) else: t = Titles.get(self.titleId) if not t: Print.error('could not find title id ' + str(self.titleId)) return None try: if not t.baseId in Titles.keys(): Print.info('could not find baseId for ' + self.path) return None except BaseException as e: print('exception: could not find title id ' + str(self.titleId) + ' ' + str(e)) return None bt = Titles.get(t.baseId) if t.isDLC: format = Config.paths.getTitleDLC(not self.hasValidTicket) elif t.isDemo: if t.idExt != 0: format = Config.paths.getTitleDemoUpdate( not self.hasValidTicket) else: format = Config.paths.getTitleDemo(not self.hasValidTicket) elif t.idExt != 0: format = Config.paths.getTitleUpdate(not self.hasValidTicket) else: format = Config.paths.getTitleBase(not self.hasValidTicket) format = format.replace('{id}', self.cleanFilename(t.id)) format = format.replace('{region}', self.cleanFilename(t.getRegion() or '')) format = format.replace('{name}', self.cleanFilename(t.getName() or '')) format = format.replace('{version}', str(self.getVersion() or 0)) format = format.replace('{baseId}', self.cleanFilename(bt.id)) format = format.replace('{baseName}', self.cleanFilename(bt.getName() or '')) ''' if self.hasValidTicket: format = os.path.splitext(format)[0] + '.nsp' else: format = os.path.splitext(format)[0] + '.nsx' ''' return format
def P2(self): self.score2 += 1 if self.check_winner(): if self.winner() == 'P2': if get_surface == 'fullscreen': img = pygame.image.load('gfx/winp2.GIF') screen.blit(img,(0,0)) pygame.display.update() pygame.time.delay(3000) else: Title.winp2() self.gameend = True
def fileName(self): bt = None if not self.titleId in Titles.keys(): if not Title.getBaseId(self.titleId) in Titles.keys(): Print.info('could not find title key for ' + self.titleId + ' or ' + Title.getBaseId(self.titleId)) return None bt = Titles.get(Title.getBaseId(self.titleId)) t = Title() t.loadCsv(self.titleId + '0000000000000000|0000000000000000|' + bt.name) else: t = Titles.get(self.titleId) if not t: Print.error('could not find title id ' + str(self.titleId)) return None try: if not t.baseId in Titles.keys(): Print.info('could not find baseId for ' + self.path) return None except BaseException as e: print('exception: could not find title id ' + str(self.titleId) + ' ' + str(e)) return None bt = Titles.get(t.baseId) if t.isDLC: format = Config.paths.getTitleDLC(not self.hasValidTicket) elif t.isDemo: if t.idExt != 0: format = Config.paths.getTitleDemoUpdate( not self.hasValidTicket) else: format = Config.paths.getTitleDemo(not self.hasValidTicket) elif t.idExt != 0: format = Config.paths.getTitleUpdate(not self.hasValidTicket) else: format = Config.paths.getTitleBase(not self.hasValidTicket) format = format.replace('{id}', self.cleanFilename(t.id)) format = format.replace('{region}', self.cleanFilename(t.getRegion() or '')) format = format.replace('{name}', self.cleanFilename(t.getName() or '')) format = format.replace('{version}', str(self.getVersion() or 0)) format = format.replace('{baseId}', self.cleanFilename(bt.id)) baseName = self.cleanFilename(bt.getName() or '') result = format.replace('{baseName}', baseName) while (len(os.path.basename(result).encode('utf-8')) > 254 and len(baseName) > 3): baseName = baseName[:-1] result = format.replace('{baseName}', baseName) return result
def get(key, region=None, language=None): key = key.upper() if not key in data(region, language): t = Title.Title() t.setId(key) data(region, language)[key] = t return data(region, language)[key]
def load(): confLock.acquire() global titles if os.path.isfile("titles.json"): timestamp = time.clock() with open('titles.json', encoding="utf-8-sig") as f: for i, k in json.loads(f.read()).items(): #if k['frontBoxArt'] and k['frontBoxArt'].endswith('.jpg'): # k['iconUrl'] = k['frontBoxArt'] # k['frontBoxArt'] = None titles[i] = Title.Title() titles[i].__dict__ = k Print.info('loaded titles.json in ' + str(time.clock() - timestamp) + ' seconds') if os.path.isfile("titles.txt"): loadTitleFile('titles.txt', True) try: files = [ f for f in os.listdir(Config.paths.titleDatabase) if f.endswith('.txt') ] files.sort() for file in files: loadTitleFile(Config.paths.titleDatabase + '/' + file, False) except BaseException as e: Print.error('title load error: ' + str(e)) confLock.release()
def load(): confLock.acquire() global titles titles = {} if os.path.isfile("titledb/titles.json"): timestamp = time.clock() with open('titledb/titles.json', encoding="utf-8-sig") as f: for i, k in json.loads(f.read()).items(): titles[i] = Title.Title() titles[i].__dict__ = k titles[i].setId(i) Print.info('loaded titledb/titles.json in ' + str(time.clock() - timestamp) + ' seconds') ''' if os.path.isfile("titles.txt"): loadTitleFile('titles.txt', True) try: files = [f for f in os.listdir(Config.paths.titleDatabase) if f.endswith('.txt')] files.sort() for file in files: loadTitleFile(Config.paths.titleDatabase + '/' + file, False) except BaseException as e: Print.error('title load error: ' + str(e)) ''' confLock.release() loadTxtDatabases()
def __init__(self, session, parent, project, title_idx): Screen.__init__(self, session) self.parent = parent self.project = project self.title_idx = title_idx self["key_red"] = StaticText(_("Cancel")) self["key_green"] = StaticText(_("OK")) self["key_yellow"] = StaticText(_("Edit Title")) self["key_blue"] = StaticText() self["serviceinfo"] = StaticText() self["thumbnail"] = Pixmap() self.picload = ePicLoad() self.picload.PictureData.get().append(self.paintThumbPixmapCB) self.properties = project.titles[title_idx].properties ConfigListScreen.__init__(self, []) self.properties.crop = Title.ConfigFixedText("crop") self.properties.autochapter.addNotifier(self.initConfigList) self.properties.aspect.addNotifier(self.initConfigList) for audiotrack in self.properties.audiotracks: audiotrack.active.addNotifier(self.initConfigList) self["setupActions"] = ActionMap(["SetupActions", "ColorActions"], { "green": self.exit, "red": self.cancel, "yellow": self.editTitle, "cancel": self.cancel, "ok": self.ok, }, -2) self.onShown.append(self.update) self.onLayoutFinish.append(self.layoutFinished)
def title(self): if not self.titleId: raise IOError('NSP no titleId set') if self.titleId in Titles.keys(): return Titles.get(self.titleId) t = Title.Title() t.setId(self.titleId) Titles.data()[self.titleId] = t return t
def __init__(self, parent, conn): self.parent = parent wx.Panel.__init__(self, parent) # Inicialización Panel Padre PanelSelect = PanelSelect.PanelSelect(self, conn) PanelJoin = PanelJoin.PanelJoin(self, conn) Title1 = Title.Title1(self) Title2 = Title.Title2(self) Title3 = Title.Title3(self) PanelWhere = PanelWhere.PanelWhere(self, conn) PanelCompiler = PanelCompiler.PanelCompiler(self) panelQuery = panelQuery.PanelQuery(self, conn, PanelSelect) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(Title1, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(PanelSelect, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(Title2, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(PanelJoin, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(Title3, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(PanelWhere, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(PanelCompiler, 0, wx.EXPAND | wx.ALL, border=10) sizer.Add(panelQuery, 0, wx.EXPAND | wx.ALL, border=10) topPanela.SetSizer(sizer)
def asteroids(): continuer = True gameState = ["EndScreen", 50] screen = pygame.display.set_mode((600, 600)) while continuer: if gameState[0] == "TitleScreen": gameState = Title.Title(screen) elif gameState[0] == "GameScreen": gameState = Game.Game(screen) elif gameState[0] == "EndScreen": gameState = End.End(screen, gameState[1]) elif gameState[0] == "Quit": continuer = False
def create_titles(titles, all_sprites, mode): title = '' if mode == 1: title = 'SAVE MAP' if mode == 2: title = 'SAVE PIVOTS' if mode == 3: title = PREPARE_AND_RUN_TITLE # Button for saving map button_hight = SCREEN_WIDTH - SCREEN_HEIGHT - 2 * PADDING # (SCREEN_WIDTH + button_hight/2, button_hight/2) button = Title( button_hight, (SCREEN_HEIGHT + button_hight / 2, PADDING + button_hight / 2), title, mode) titles.add(button) all_sprites.add(button) if mode == 3: reset_button = Title(button_hight, (SCREEN_HEIGHT + button_hight / 2, PADDING * 2 + button_hight * 1.5), RESET_TITLE, mode) titles.add(reset_button) all_sprites.add(reset_button)
def getNsuid(id, region, language): id = int(id) map = data(region, language) for t in map: if map[t].nsuId == id: return map[t] title = Title.Title() title.nsuId = id map[id] = title return title
def loadTitleBuffer(buffer, silent = False): firstLine = True map = ['id', 'key', 'name'] for line in buffer.split('\n'): line = line.strip() if len(line) == 0 or line[0] == '#': continue if firstLine: firstLine = False if re.match('[A-Za-z\|\s]+', line, re.I): map = line.split('|') i = 0 while i < len(map): if map[i] == 'RightsID': map[i] = 'id' if map[i] == 'TitleKey': map[i] = 'key' if map[i] == 'Name': map[i] = 'name' i += 1 continue t = Title.Title() t.loadCsv(line, map) if not isinstance(t.id, str): continue if not t.id in keys(None, None): titles[t.id] = Title.Title() titleKey = titles[t.id].key titles[t.id].loadCsv(line, map) if not silent and titleKey != titles[t.id].key: Print.info('Added new title key for ' + str(titles[t.id].name) + '[' + str(t.id) + ']')
def __init__(self, parent, conn): self.parent = parent wx.Panel.__init__(self, parent) # Inicialización Panel Padre self.Box1 = wx.BoxSizer(wx.VERTICAL) self.Title1 = Title.Title1(self) self.PanelSelect = PanelSelect.PanelSelect(self, conn) self.rowsselect = self.PanelSelect.GetRowsValue() pp = pprint.PrettyPrinter(indent=4) pp.pprint(self.rowsselect) self.Box1.Add(self.Title1, 0, wx.ALIGN_CENTER | wx.ALL, border=10) self.Box1.Add(self.PanelSelect, 0, wx.GROW | wx.ALIGN_CENTER | wx.ALL, border=10) self.Title2 = Title.Title2(self) self.PanelJoin = PanelJoin.PanelJoin(self, conn) self.Box1.Add(self.Title2, 0, wx.ALIGN_CENTER | wx.ALL, border=10) self.Box1.Add(self.PanelJoin, 0, wx.ALIGN_CENTER | wx.ALL, border=10) self.Title3 = Title.Title3(self) self.PanelWhere = PanelWhere.PanelWhere(self, conn) self.Box1.Add(self.Title3, 0, wx.ALIGN_CENTER | wx.ALL, border=10) self.Box1.Add(self.PanelWhere, 0, wx.ALIGN_CENTER | wx.ALL, border=10) self.panelShell = PanelShell.PanelShell(self, conn) self.panelQuery = panelQuery.PanelQuery(self, conn, self.rowsselect) self.Box1.Add(self.panelQuery, 0, wx.ALIGN_CENTER | wx.ALL, border=10) self.Box1.Add(self.panelShell, 0, wx.ALIGN_CENTER | wx.ALL, border=10) self.sizer = wx.BoxSizer(wx.VERTICAL) self.gs = wx.GridSizer(1, 1, 1, 1) self.gs.AddMany([(self.Box1, 0, wx.ALIGN_CENTER)]) self.sizer.Add(self.gs, proportion=1, flag=wx.EXPAND) self.SetSizer(self.sizer)
def loadTitlesJson(filePath='titledb/titles.json'): newTitles = {} confLock.acquire() if os.path.isfile(filePath): timestamp = time.clock() with open(filePath, encoding="utf-8-sig") as f: for i, k in json.loads(f.read()).items(): newTitles[i] = Title.Title() newTitles[i].__dict__ = k Print.info('loaded ' + filePath + ' in ' + str(time.clock() - timestamp) + ' seconds') confLock.release() return newTitles
def fileName(self): bt = None if not self.titleId in Titles.keys(): if not Title.getBaseId(self.titleId) in Titles.keys(): Print.info('could not find title key for ' + self.titleId + ' or ' + Title.getBaseId(self.titleId)) return None bt = Titles.get(Title.getBaseId(self.titleId)) t = Title() t.loadCsv(self.titleId + '0000000000000000|0000000000000000|' + bt.name) else: t = Titles.get(self.titleId) if not t.baseId in Titles.keys(): Print.info('could not find baseId for ' + self.path) return None bt = Titles.get(t.baseId) if t.isDLC: format = Config.paths.titleDLC elif t.isDemo: if t.idExt != 0: format = Config.paths.titleDemoUpdate else: format = Config.paths.titleDemo elif t.idExt != 0: format = Config.paths.titleUpdate else: format = Config.paths.titleBase format = format.replace('{id}', self.cleanFilename(t.id)) format = format.replace('{region}', self.cleanFilename(t.region or '')) format = format.replace('{name}', self.cleanFilename(t.name or '')) format = format.replace('{version}', str(self.version or 0)) format = format.replace('{baseId}', self.cleanFilename(bt.id)) format = format.replace('{baseName}', self.cleanFilename(bt.name or '')) if self.hasValidTicket: format = os.path.splitext(format)[0] + '.nsp' else: format = os.path.splitext(format)[0] + '.nsx' return format
def getNsuIds(titleIds, type='title', region='US', shop_id=4): j = ids(titleIds, type, region, shop_id) lst = {} try: for i in j['id_pairs']: titleId = i['title_id'].upper() nsuId = int(['id']) lst[titleId] = nsuId if Titles.contains(titleId): Titles.get(titleId).nsuId = nsuId else: title = Title.Title() title.setId(titleId) title.nsuId = nsuId Titles.set(titleId, title) except BaseException as e: pass return lst
def xmlGetTitleNodeRecursive(self, node, title_idx=-1): print "[xmlGetTitleNodeRecursive]", title_idx, node print node.childNodes for subnode in node.childNodes: print "xmlGetTitleNodeRecursive subnode:", subnode if subnode.nodeType == xml.dom.minidom.Element.nodeType: if subnode.tagName == 'title': title_idx += 1 title = Title.Title(self) self.titles.append(title) self.xmlGetTitleNodeRecursive(subnode, title_idx) if subnode.tagName == 'path': print "path:", subnode.firstChild.data filename = subnode.firstChild.data self.titles[title_idx].addFile(filename.encode("utf-8")) if subnode.tagName == 'properties': self.xmlAttributesToConfig( node, self.titles[title_idx].properties) if subnode.tagName == 'audiotracks': self.xmlGetTitleNodeRecursive(subnode, title_idx) if subnode.tagName == 'audiotrack': print "audiotrack...", subnode.toxml()
def load(): global regionTitles for region in cdn.regions(): filePath = 'titledb/%s.json' % region if os.path.isfile(filePath): regionTitles[region] = loadTitlesJson(filePath) else: regionTitles[region] = {} confLock.acquire() global titles if os.path.isfile("titledb/titles.json"): timestamp = time.clock() with open('titledb/titles.json', encoding="utf-8-sig") as f: for i, k in json.loads(f.read()).items(): titles[i] = Title.Title() titles[i].__dict__ = k Print.info('loaded titledb/titles.json in ' + str(time.clock() - timestamp) + ' seconds') if os.path.isfile("titles.txt"): loadTitleFile('titles.txt', True) try: files = [ f for f in os.listdir(Config.paths.titleDatabase) if f.endswith('.txt') ] files.sort() for file in files: loadTitleFile(Config.paths.titleDatabase + '/' + file, False) except BaseException as e: Print.error('title load error: ' + str(e)) confLock.release()
def getAddOns(titleId): url = 'https://superfly.hac.%s.d4c.nintendo.net/v1/a/%s/dv' % ( Config.cdn.environment, titleId) j = makeJsonRequest('GET', url, {}, '%d/a/%s/dv.json' % (shop_id, titleId)) lst = [] if not j: return lst for i in j: id = i['title_id'].upper() if Titles.contains(id): Titles.get(id).setVersion(int(i['version'])) else: Print.info('New DLC found: ' + id) title = Title.Title() title.setId(id) title.setVersion(int(i['version'])) Titles.set(id, title) lst.append(id) return lst
def addService(self, service): title = Title.Title(self) title.addService(service) self.titles.append(title) return title
def scrapeTitles(region='US', shop_id=4): Print.info('Scraping %s' % region) pageSize = 50 offset = 0 total = 1 c = 0 while offset < total: url = 'https://bugyo.hac.%s.eshop.nintendo.net/shogun/v1/titles?shop_id=%d&lang=%s&country=%s&sort=new&limit=%d&offset=%d' % ( Config.cdn.environment, shop_id, countryLanguage(region), region, pageSize, offset) #print(url) j = makeJsonRequest( 'GET', url, {}, '%d/%s/%s/titles/index/%d-%d.json' % (shop_id, countryLanguage(region), region, pageSize, offset)) if not j: break total = int(j['total']) try: for i in j['contents']: title = Titles.getNsuid(i['id']) n = getTitleByNsuid(i['id'], region) if title: for x in cdn.Superfly.getAddOns(title.id): getNsuIds(x, 'aoc', region) title.parseShogunJson(n) rt = Title.Title() rt.setId(title.id) rt.setRegion(region) rt.parseShogunJson(n) Titles.set(title.id, rt, region) scrapeDlc(i['id'], region) else: try: if n and len(n["applications"]) > 0: titleId = n["applications"][0]["id"].upper() for x in cdn.Superfly.getAddOns(titleId): getNsuIds(x, 'aoc', region) if titleId: if Titles.contains(titleId): title = Titles.get(titleId) title.setId(titleId) title.parseShogunJson(n) #print('existing title found!') else: title = Title.Title() title.setId(titleId) title.parseShogunJson(n) Titles.set(titleId, title) print('added new title %s %s' % (title.id, title.name)) rt = Title.Title() rt.setId(titleId) rt.setRegion(region) rt.parseShogunJson(n) Titles.set(titleId, rt, region) scrapeDlc(i['id'], region) else: print('Could not get title json!') else: #print('no title id found in json!') pass except Exception as e: #print(str(e)) pass except Exception as e: print(str(e)) raise break offset = offset + len(j['contents']) #c = c + 1 #if c % 100 == 0: # Print.info('.') # Titles.save() Titles.save()
#along with this program. If not, see <http://www.gnu.org/licenses/>. #------------------------------------------------------------------------------# #Basic Classes and Game Objects #Includes The Game Loop import pygame from pygame.locals import * import random import fullscreen from Settings import * from Sounds import * import Title import easygui pygame.init() get_surface = Title.title() screen = pygame.display.set_mode((800,600),SWSURFACE) clock = pygame.time.Clock() settings = Settings() if get_surface == 'fullscreen': screen = fullscreen.fullscreen() class Bat(pygame.sprite.Sprite): def __init__(self,p2 = False,pos = 1): self.p2 = p2 self.pos = pos self.mode = settings.get_mode() if self.mode == 'space': image = 'spacebat.PNG' elif self.mode == 'grass': image = 'grassbat.PNG'
#!/usr/bin/env python3 import sys import os try: import pygame except: print("Erro: este aplicativo precisa da biblioteca externa `pygame' para ser executado.\nPor favor, instale-a antes de executar este programa.") sys.exit(1) sys.path.append(os.path.abspath("src")) os.chdir(os.path.abspath("src")) import Title Title.main()
for i in range(0, len(result["results"])): # results loop indicatorsLength = len( result["results"][i]["indicators"]) # indicators loop for j in range(0, indicatorsLength): if outFormat == 1: Writer.jsonWriter(i, j, result) # json output else: Writer.csvWriter(i, j, result) # csv output if r.json()["next"] is None: #next page control print("IOC Hunter Finished") #finish break else: url = r.json()["next"] # go to next page else: print("IOC Hunter Finished") #finish break #----------------------------------------------------------------------------------------------------------------- if __name__ == "__main__": ScreenClear.clear() Title.ScreenStarter() outFormat = Selection() PathControl.PathControl() CollectIOC(outFormat)
def PreparePiece(self, name): self.circle = Circle.Circle(self.current_position[0], self.current_position[1]) self.title = Title.Title(name, self.current_position[0], self.current_position[1])
def scrapeDlc(baseNsuid, region='US', shop_id=3): pageSize = 50 offset = 0 total = 1 while offset < total: url = 'https://bugyo.hac.%s.eshop.nintendo.net/shogun/v1/titles/%d/aocs?shop_id=%d&lang=%s&country=%s' % ( Config.cdn.environment, baseNsuid, shop_id, countryLanguage(region), region) #print(url) #exit(0) j = makeJsonRequest( 'GET', url, {}, '%d/%s/%s/titles/aocs/%d.json' % (shop_id, countryLanguage(region), region, baseNsuid)) if not j: break total = int(j['total']) if total == 0: break try: for i in j['contents']: title = Titles.getNsuid(i['id']) n = getDlcByNsuid(i['id']) if title: title.parseShogunJson(n, region) rt = Title.Title() rt.setId(title.id) rt.setRegion(region) rt.parseShogunJson(n) Titles.set(title.id, rt, region) else: try: if n and len(n["applications"]) > 0: titleId = n["applications"][0]["id"].upper() if titleId: if Titles.contains(titleId): title = Titles.get(titleId) title.setId(titleId) title.parseShogunJson(n, region) #print('existing title found!') else: title = Title.Title() title.setId(titleId) title.parseShogunJson(n, region) Titles.set(titleId, title) print('added new DLC %s %s' % (title.id, title.name)) rt = Title.Title() rt.setId(titleId) rt.setRegion(region) rt.parseShogunJson(n, region) Titles.set(titleId, rt, region) else: print('Could not get title json!') else: #print('no title id found in json!') pass except Exception as e: #print(str(e)) pass except Exception as e: print(str(e)) raise break offset = offset + len(j['contents'])
def changeTitle(id): pagenum = request.args.get("pagenum") return Title.getTemp(id,int(pagenum));