def importFitFromBuffer(self, bufferStr, activeFit=None): _, fits = Port.importAuto(bufferStr, activeFit=activeFit) for fit in fits: fit.character = self.character fit.damagePattern = self.pattern fit.targetResists = self.targetResists eds_queries.save(fit) return fits
def getAll0(cls): all0 = getCharacter("All 0") if all0 is None: all0 = Character("All 0") eds_queries.save(all0) return all0
def setOverride(self, attr, value): from eos.saveddata.override import Override if attr.name in self.__overrides: override = self.__overrides.get(attr.name) override.value = value else: override = Override(self, attr, value) self.__overrides[attr.name] = override eds_queries.save(override)
def saveCharacterAs(self, charID, newName): """Save edited skills as a new character""" char = getCharacter(charID) newChar = copy.deepcopy(char) newChar.name = newName eds_queries.save(newChar) # revert old char char.revertLevels()
def makeLinearFleet(self, fit): f = Fleet_() w = Fleet_() s = Fleet_() f.wings.append(w) w.squads.append(s) s.members.append(fit) fit.fleet = f eds_queries.save(f)
def importRequiredDefaults(cls): damageProfileList = [["Uniform", "25", "25", "25", "25"]] for damageProfileRow in damageProfileList: name, em, therm, kin, exp = damageProfileRow damageProfile = getDamagePatternList(name) if damageProfile is None: damageProfile = es_DamagePattern(em, therm, kin, exp) damageProfile.name = name eds_queries.save(damageProfile)
def getAll5(cls): all5 = getCharacter("All 5") if all5 is None: # We do not have to be afraid of committing here and saving # edited character data. If this ever runs, it will be during the # get character list phase when pyfa first starts all5 = Character("All 5", 5) eds_queries.save(all5) return all5
def handleLogin(self, message): if not message: return if message['state'][0] != self.state: logger.warn("OAUTH state mismatch") return logger.debug("Handling CREST login with: %s", message) if 'access_token' in message: # implicit eve = copy.deepcopy(self.eve) eve.temptoken_authorize(access_token=message['access_token'][0], expires_in=int(message['expires_in'][0])) self.ssoTimer = threading.Timer(int(message['expires_in'][0]), self.logout) self.ssoTimer.start() eve() info = eve.whoami() logger.debug("Got character info: %s", info) self.implicitCharacter = CrestChar(info['CharacterID'], info['CharacterName']) self.implicitCharacter.eve = eve # self.implicitCharacter.fetchImage() wx.PostEvent(self.mainFrame, GE.SsoLogin(type=CrestModes.IMPLICIT)) elif 'code' in message: eve = copy.deepcopy(self.eve) eve.authorize(message['code'][0]) eve() info = eve.whoami() logger.debug("Got character info: %s", info) # check if we have character already. If so, simply replace refresh_token char = self.getCrestCharacter(int(info['CharacterID'])) if char: char.refresh_token = eve.refresh_token else: char = CrestChar(info['CharacterID'], info['CharacterName'], eve.refresh_token) char.eve = eve self.charCache[int(info['CharacterID'])] = char eds_queries.save(char) wx.PostEvent(self.mainFrame, GE.SsoLogin(type=CrestModes.USER)) self.stopServer()
def newFit(self, shipID, name=None): try: ship = es_Ship(getItem(shipID)) except ValueError: ship = es_Citadel(getItem(shipID)) fit = es_Fit(ship) fit.name = name if name is not None else "New %s" % fit.ship.item.name fit.damagePattern = self.pattern fit.targetResists = self.targetResists fit.character = self.character fit.booster = self.booster eds_queries.save(fit) self.recalc(fit) return fit.ID
def importSets(self, text): sMkt = Market.getInstance() lines = text.splitlines() newSets = [] errors = 0 current = None lookup = {} for i, line in enumerate(lines): line = line.strip() try: if line == '' or line[0] == "#": # comments / empty string continue if line[:1] == "[" and line[-1:] == "]": current = es_ImplantSet(line[1:-1]) newSets.append(current) else: item = sMkt.getItem(line) current.implants.append(es_Implant(item)) except: errors += 1 continue for implant_set in self.getImplantSetList(): lookup[implant_set.name] = implant_set for implant_set in newSets: if implant_set.name in lookup: match = lookup[implant_set.name] for implant in implant_set.implants: match.implants.append(es_Implant(implant.item)) else: eds_queries.save(implant_set) eds_queries.commit() lenImports = len(newSets) if lenImports == 0: raise ImportError("No patterns found for import") if errors > 0: raise ImportError("%d sets imported from clipboard; %d errors" % (lenImports, errors))
def importPatterns(self, text): lookup = {} current = getDamagePatternList() for pattern in current: lookup[pattern.name] = pattern imports, num = es_DamagePattern.importPatterns(text) for pattern in imports: if pattern.name in lookup: match = lookup[pattern.name] match.__dict__.update(pattern.__dict__) else: eds_queries.save(pattern) eds_queries.commit() lenImports = len(imports) if lenImports == 0: raise ImportError("No patterns found for import") if lenImports != num: raise ImportError( "%d patterns imported from clipboard; %d had errors" % (num, num - lenImports))
def saveChanges(self, p): eds_queries.save(p)
def importFitFromFiles(self, paths, callback=None): """ Imports fits from file(s). First processes all provided paths and stores assembled fits into a list. This allows us to call back to the GUI as fits are processed as well as when fits are being saved. returns """ defcodepage = locale.getpreferredencoding() fits = [] for path in paths: if callback: # Pulse wx.CallAfter(callback, 1, "Processing file:\n%s" % path) file = open(path, "r") srcString = file.read() if len(srcString) == 0: # ignore blank files continue codec_found = None # If file had ANSI encoding, decode it to unicode using detection # of BOM header or if there is no header try default # codepage then fallback to utf-16, cp1252 if isinstance(srcString, str): encoding_map = (('\xef\xbb\xbf', 'utf-8'), ('\xff\xfe\0\0', 'utf-32'), ('\0\0\xfe\xff', 'UTF-32BE'), ('\xff\xfe', 'utf-16'), ('\xfe\xff', 'UTF-16BE')) for bom, encoding in encoding_map: if srcString.startswith(bom): codec_found = encoding savebom = bom if codec_found is None: logger.info("Unicode BOM not found in file %s.", path) attempt_codecs = (defcodepage, "utf-8", "utf-16", "cp1252") for page in attempt_codecs: try: logger.info( "Attempting to decode file %s using %s page.", path, page) srcString = unicode(srcString, page) codec_found = page logger.info("File %s decoded using %s page.", path, page) except UnicodeDecodeError: logger.info( "Error unicode decoding %s from page %s, trying next codec", path, page) else: break else: logger.info("Unicode BOM detected in %s, using %s page.", path, codec_found) srcString = unicode(srcString[len(savebom):], codec_found) else: # nasty hack to detect other transparent utf-16 loading if srcString[0] == '<' and 'utf-16' in srcString[:128].lower(): codec_found = "utf-16" else: codec_found = "utf-8" if codec_found is None: return False, "Proper codec could not be established for %s" % path try: _, fitsImport = Port.importAuto(srcString, path, callback=callback, encoding=codec_found) fits += fitsImport except xml.parsers.expat.ExpatError: return False, "Malformed XML in %s" % path except Exception: logger.exception("Unknown exception processing: %s", path) return False, "Unknown Error while processing %s" % path IDs = [] numFits = len(fits) for i, fit in enumerate(fits): # Set some more fit attributes and save fit.character = self.character fit.damagePattern = self.pattern fit.targetResists = self.targetResists eds_queries.save(fit) IDs.append(fit.ID) if callback: # Pulse wx.CallAfter( callback, 1, "Processing complete, saving fits to database\n(%d/%d)" % (i + 1, numFits)) return True, fits
def renamePattern(self, p, newName): p.name = newName eds_queries.save(p)
def copyPattern(self, p): newP = copy.deepcopy(p) eds_queries.save(newP) return newP
def newPattern(self, name): p = es_TargetResists(0.0, 0.0, 0.0, 0.0) p.name = name eds_queries.save(p) return p
def newPattern(self, name): p = es_DamagePattern(0, 0, 0, 0) p.name = name eds_queries.save(p) return p
def copySet(self, implant_set): newS = copy.deepcopy(implant_set) eds_queries.save(newS) return newS
def saveChanges(self, implant_set): eds_queries.save(implant_set)
def newSet(self, name): implant_set = es_ImplantSet() implant_set.name = name eds_queries.save(implant_set) return implant_set
def renameSet(self, implant_set, newName): implant_set.name = newName eds_queries.save(implant_set)
def new(self, name="New Character"): char = es_Character(name) eds_queries.save(char) return char
def copyFleet(self, fleet): newFleet = copy.deepcopy(fleet) eds_queries.save(newFleet) return newFleet
def copy(self, char): newChar = copy.deepcopy(char) eds_queries.save(newChar) return newChar
def importResistProfileDefaults(cls): targetResistProfileList = [ ["Uniform (25%)", "0.25", "0.25", "0.25", "0.25"], ["Uniform (50%)", "0.50", "0.50", "0.50", "0.50"], ["Uniform (75%)", "0.75", "0.75", "0.75", "0.75"], ["Uniform (90%)", "0.90", "0.90", "0.90", "0.90"], ["[T1 Resist]Shield", "0.0", "0.20", "0.40", "0.50"], ["[T1 Resist]Armor", "0.50", "0.45", "0.25", "0.10"], ["[T1 Resist]Hull", "0.33", "0.33", "0.33", "0.33"], ["[T1 Resist]Shield (+T2 DCU)", "0.125", "0.30", "0.475", "0.562"], ["[T1 Resist]Armor (+T2 DCU)", "0.575", "0.532", "0.363", "0.235"], ["[T1 Resist]Hull (+T2 DCU)", "0.598", "0.598", "0.598", "0.598"], ["[T2 Resist]Amarr (Shield)", "0.0", "0.20", "0.70", "0.875"], ["[T2 Resist]Amarr (Armor)", "0.50", "0.35", "0.625", "0.80"], ["[T2 Resist]Caldari (Shield)", "0.20", "0.84", "0.76", "0.60"], ["[T2 Resist]Caldari (Armor)", "0.50", "0.8625", "0.625", "0.10"], ["[T2 Resist]Gallente (Shield)", "0.0", "0.60", "0.85", "0.50"], ["[T2 Resist]Gallente (Armor)", "0.50", "0.675", "0.8375", "0.10"], ["[T2 Resist]Minmatar (Shield)", "0.75", "0.60", "0.40", "0.50"], ["[T2 Resist]Minmatar (Armor)", "0.90", "0.675", "0.25", "0.10"], ["[NPC][Asteroid] Angel Cartel", "0.54", "0.42", "0.37", "0.32"], ["[NPC][Asteroid] Blood Raiders", "0.34", "0.39", "0.45", "0.52"], ["[NPC][Asteroid] Guristas", "0.55", "0.35", "0.3", "0.48"], ["[NPC][Asteroid] Rogue Drones", "0.35", "0.38", "0.44", "0.49"], ["[NPC][Asteroid] Sanshas Nation", "0.35", "0.4", "0.47", "0.53"], ["[NPC][Asteroid] Serpentis", "0.49", "0.38", "0.29", "0.51"], ["[NPC][Deadspace] Angel Cartel", "0.59", "0.48", "0.4", "0.32"], ["[NPC][Deadspace] Blood Raiders", "0.31", "0.39", "0.47", "0.56"], ["[NPC][Deadspace] Guristas", "0.57", "0.39", "0.31", "0.5"], ["[NPC][Deadspace] Rogue Drones", "0.42", "0.42", "0.47", "0.49"], [ "[NPC][Deadspace] Sanshas Nation", "0.31", "0.39", "0.47", "0.56" ], ["[NPC][Deadspace] Serpentis", "0.49", "0.38", "0.29", "0.56"], ["[NPC][Mission] Amarr Empire", "0.34", "0.38", "0.42", "0.46"], ["[NPC][Mission] Caldari State", "0.51", "0.38", "0.3", "0.51"], ["[NPC][Mission] CONCORD", "0.47", "0.46", "0.47", "0.47"], [ "[NPC][Mission] Gallente Federation", "0.51", "0.38", "0.31", "0.52" ], ["[NPC][Mission] Khanid", "0.51", "0.42", "0.36", "0.4"], [ "[NPC][Mission] Minmatar Republic", "0.51", "0.46", "0.41", "0.35" ], ["[NPC][Mission] Mordus Legion", "0.32", "0.48", "0.4", "0.62"], ["[NPC][Other] Sleeper", "0.61", "0.61", "0.61", "0.61"], ["[NPC][Other] Sansha Incursion", "0.65", "0.63", "0.64", "0.65"], [ "[NPC][Burner] Cruor (Blood Raiders)", "0.8", "0.73", "0.69", "0.67" ], ["[NPC][Burner] Dramiel (Angel)", "0.35", "0.48", "0.61", "0.68"], [ "[NPC][Burner] Daredevil (Serpentis)", "0.69", "0.59", "0.59", "0.43" ], [ "[NPC][Burner] Succubus (Sanshas Nation)", "0.35", "0.48", "0.61", "0.68" ], ["[NPC][Burner] Worm (Guristas)", "0.48", "0.58", "0.69", "0.74"], ["[NPC][Burner] Enyo", "0.58", "0.72", "0.86", "0.24"], ["[NPC][Burner] Hawk", "0.3", "0.86", "0.79", "0.65"], ["[NPC][Burner] Jaguar", "0.78", "0.65", "0.48", "0.56"], ["[NPC][Burner] Vengeance", "0.66", "0.56", "0.75", "0.86"], [ "[NPC][Burner] Ashimmu (Blood Raiders)", "0.8", "0.76", "0.68", "0.7" ], ["[NPC][Burner] Talos", "0.68", "0.59", "0.59", "0.43"], ["[NPC][Burner] Sentinel", "0.58", "0.45", "0.52", "0.66"] ] for targetResistProfileRow in targetResistProfileList: name, em, therm, kin, exp = targetResistProfileRow resistsProfile = getTargetResists(name) if resistsProfile is None: resistsProfile = es_TargetResists(em, therm, kin, exp) resistsProfile.name = name eds_queries.save(resistsProfile)
def importDamageProfileDefaults(cls): damageProfileList = [ ["Uniform", "25", "25", "25", "25"], ["[Generic]EM", "100", "0", "0", "0"], ["[Generic]Thermal", "0", "100", "0", "0"], ["[Generic]Kinetic", "0", "0", "100", "0"], ["[Generic]Explosive", "0", "0", "0", "100"], ["[NPC][Asteroid] Blood Raiders", "5067", "4214", "0", "0"], ["[Bombs]Concussion Bomb", "0", "0", "6400", "0"], ["[Bombs]Electron Bomb", "6400", "0", "0", "0"], ["[Bombs]Scorch Bomb", "0", "6400", "0", "0"], ["[Bombs]Shrapnel Bomb", "0", "0", "0", "6400"], ["[Frequency Crystals][T2] Gleam", "56", "56", "0", "0"], ["[Frequency Crystals][T2] Aurora", "40", "24", "0", "0"], ["[Frequency Crystals][T2] Scorch", "72", "16", "0", "0"], [ "[Frequency Crystals][T2] Conflagration", "61.6", "61.6", "0", "0" ], ["[Frequency Crystals]Gamma", "61.6", "35.2", "0", "0"], ["[Frequency Crystals]Infrared", "44", "17.6", "0", "0"], ["[Frequency Crystals]Microwave", "35.2", "17.6", "0", "0"], ["[Frequency Crystals]Multifrequency", "61.6", "44", "0", "0"], ["[Frequency Crystals]Radio", "44", "0", "0", "0"], ["[Frequency Crystals]Standard", "44", "26.4", "0", "0"], ["[Frequency Crystals]Ultraviolet", "52.8", "26.4", "0", "0"], ["[Frequency Crystals]Xray", "52.8", "35.2", "0", "0"], ["[Hybrid Charges][T2] Void", "0", "61.6", "61.6", "0"], ["[Hybrid Charges][T2] Null", "0", "48", "40", "0"], ["[Hybrid Charges][T2] Javelin", "0", "64", "48", "0"], ["[Hybrid Charges][T2] Spike", "0", "32", "32", "0"], ["[Hybrid Charges]Antimatter", "0", "48", "67.2", "0"], ["[Hybrid Charges]Iridium", "0", "28.8", "38.4", "0"], ["[Hybrid Charges]Iron", "0", "19.2", "28.8", "0"], ["[Hybrid Charges]Lead", "0", "28.8", "48", "0"], ["[Hybrid Charges]Plutonium", "0", "48", "57.6", "0"], ["[Hybrid Charges]Thorium", "0", "38.4", "48", "0"], ["[Hybrid Charges]Tungsten", "0", "19.2", "38.4", "0"], ["[Hybrid Charges]Uranium", "0", "38.4", "57.6", "0"], ["[Missiles]Mjolnir", "100", "0", "0", "0"], ["[Missiles]Inferno", "0", "100", "0", "0"], ["[Missiles]Scourge", "0", "0", "100", "0"], ["[Missiles]Nova", "0", "0", "0", "100"], [ "[Missiles][Structure) Standup Missile", "100", "100", "100", "100" ], ["[Projectile Ammo][T2] Tremor", "0", "0", "24", "40"], ["[Projectile Ammo][T2] Quake", "0", "0", "40", "72"], ["[Projectile Ammo][T2] Hail", "0", "0", "26.4", "96.8"], ["[Projectile Ammo][T2] Barrage", "0", "0", "40", "48"], ["[Projectile Ammo]Carbonized Lead", "0", "0", "35.2", "8.8"], ["[Projectile Ammo]Depleted Uranium", "0", "26.4", "17.6", "26.4"], ["[Projectile Ammo]EMP", "79.2", "0", "8.8", "17.6"], ["[Projectile Ammo]Fusion", "0", "0", "17.6", "88"], ["[Projectile Ammo]Nuclear", "0", "0", "8.8", "35.2"], ["[Projectile Ammo]Phased Plasma", "0", "88", "17.6", "0"], ["[Projectile Ammo]Proton", "26.4", "0", "17.6", "0"], ["[Projectile Ammo]Titanium Sabot", "0", "0", "52.8", "176"], ["[NPC][Burner] Cruor (Blood Raiders)", "90", "90", "0", "0"], ["[NPC][Burner] Dramiel (Angel)", "55", "0", "20", "96"], ["[NPC][Burner] Daredevil (Serpentis)", "0", "110", "154", "0"], ["[NPC][Burner] Succubus (Sanshas Nation)", "135", "30", "0", "0"], ["[NPC][Burner] Worm (Guristas)", "0", "0", "228", "0"], ["[NPC][Burner] Enyo", "0", "147", "147", "0"], ["[NPC][Burner] Hawk", "0", "0", "247", "0"], ["[NPC][Burner] Jaguar", "36", "0", "50", "182"], ["[NPC][Burner] Vengeance", "232", "0", "0", "0"], ["[NPC][Burner] Ashimmu (Blood Raiders)", "260", "100", "0", "0"], ["[NPC][Burner] Talos", "0", "413", "413", "0"], ["[NPC][Burner] Sentinel", "0", "75", "0", "90"], ["[NPC][Asteroid] Angel Cartel", "1838", "562", "2215", "3838"], ["[NPC][Deadspace] Angel Cartel", "369", "533", "1395", "3302"], ["[NPC][Deadspace] Blood Raiders", "6040", "5052", "10", "15"], ["[NPC][Asteroid] Guristas", "0", "1828", "7413", "0"], ["[NPC][Deadspace] Guristas", "0", "1531", "9680", "0"], ["[NPC][Asteroid] Rogue Drone", "394", "666", "1090", "1687"], ["[NPC][Deadspace] Rogue Drone", "276", "1071", "1069", "871"], ["[NPC][Asteroid] Sanshas Nation", "5586", "4112", "0", "0"], ["[NPC][Deadspace] Sanshas Nation", "3009", "2237", "0", "0"], ["[NPC][Asteroid] Serpentis", "0", "5373", "4813", "0"], ["[NPC][Deadspace] Serpentis", "0", "3110", "1929", "0"], ["[NPC][Mission] Amarr Empire", "4464", "3546", "97", "0"], ["[NPC][Mission] Caldari State", "0", "2139", "4867", "0"], ["[NPC][Mission] CONCORD", "336", "134", "212", "412"], ["[NPC][Mission] Gallente Federation", "9", "3712", "2758", "0"], ["[NPC][Mission] Khanid", "612", "483", "43", "6"], [ "[NPC][Mission] Minmatar Republic", "1024", "388", "1655", "4285" ], ["[NPC][Mission] Mordus Legion", "25", "262", "625", "0"], ["[NPC][Mission] Thukker", "0", "52", "10", "79"], ["[NPC][Other] Sleepers", "1472", "1472", "1384", "1384"], ["[NPC][Other] Sansha Incursion", "1682", "1347", "3678", "3678"] ] for damageProfileRow in damageProfileList: name, em, therm, kin, exp = damageProfileRow damageProfile = getDamagePatternList(name) if damageProfile is None: damageProfile = es_DamagePattern(em, therm, kin, exp) damageProfile.name = name eds_queries.save(damageProfile)
def copyFit(self, fitID): fit = getFit(fitID) newFit = copy.deepcopy(fit) eds_queries.save(newFit) return newFit.ID
def addFleet(self): f = Fleet_() eds_queries.save(f) return f