oh god this isn't gonna work
Merge branch 'ebag_importchanges' into test_import Conflicts: config.py eos/db/saveddata/queries.py eos/effects/chargebonuswarfarecharge.py eos/effects/elitebonuscommandshipinformationhiddencs3.py eos/effects/elitebonuslogisticremotearmorrepairoptimalfalloff1.py eos/effects/energydestabilizationnew.py eos/effects/iceharvestingdroneoperationdurationbonus.py eos/effects/miningforemanstrengthbonus.py eos/effects/modulebonuswarfarelinkarmor.py eos/effects/modulebonuswarfarelinkinfo.py eos/effects/modulebonuswarfarelinkmining.py eos/effects/modulebonuswarfarelinkshield.py eos/effects/modulebonuswarfarelinkskirmish.py eos/effects/moduletitaneffectgenerator.py eos/effects/remotehullrepair.py eos/effects/rolebonusremotearmorrepairoptimalfalloff.py eos/effects/shipbonusforceauxiliarya4warfarelinksbonus.py eos/effects/shipmodesmallmissiledamagepostdiv.py eos/effects/structureenergyneutralizerfalloff.py eos/effects/structuremoduleeffectstasiswebifier.py eos/effects/structurerigmaxtargets.py eos/effects/subsystembonusamarrdefensiveinformationwarfarehidden.py eos/effects/subsystembonuscaldaridefensiveinformationwarfarehidden.py eos/effects/subsystembonusgallentedefensiveinformationwarfarehidden.py eos/effects/techtwocommandburstbonus.py eos/saveddata/fighter.py eos/saveddata/fit.py eos/saveddata/module.py eve.db gui/bitmapLoader.py gui/builtinContextMenus/itemStats.py gui/builtinStatsViews/miningyieldViewFull.py gui/builtinViewColumns/misc.py gui/builtinViews/__init__.py gui/builtinViews/fittingView.py gui/contextMenu.py gui/graphFrame.py gui/itemStats.py gui/mainFrame.py gui/marketBrowser.py service/__init__.py service/character.py service/fit.py service/port.py service/prefetch.py service/pycrest/eve.py service/settings.py
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#===============================================================================
|
||||
# =============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
@@ -15,11 +15,12 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
#===============================================================================
|
||||
# =============================================================================
|
||||
|
||||
import copy
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
from codecs import open
|
||||
from xml.etree import ElementTree
|
||||
@@ -28,16 +29,18 @@ import gzip
|
||||
|
||||
import wx
|
||||
|
||||
import eos.db
|
||||
import eos.types
|
||||
import service
|
||||
import config
|
||||
import logging
|
||||
import eos.db
|
||||
from service.eveapi import EVEAPIConnection, ParseXML
|
||||
|
||||
from eos.saveddata.implant import Implant as es_Implant
|
||||
from eos.saveddata.character import Character as es_Character
|
||||
from eos.saveddata.module import Slot as es_Slot, Module as es_Module
|
||||
from eos.saveddata.fighter import Fighter as es_Fighter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CharacterImportThread(threading.Thread):
|
||||
def __init__(self, paths, callback):
|
||||
threading.Thread.__init__(self)
|
||||
@@ -57,8 +60,8 @@ class CharacterImportThread(threading.Thread):
|
||||
try:
|
||||
# we try to parse api XML data first
|
||||
with open(path, mode='r') as charFile:
|
||||
sheet = service.ParseXML(charFile)
|
||||
char = sCharacter.new(sheet.name+" (imported)")
|
||||
sheet = ParseXML(charFile)
|
||||
char = sCharacter.new(sheet.name + " (imported)")
|
||||
sCharacter.apiUpdateCharSheet(char.ID, sheet.skills)
|
||||
except:
|
||||
# if it's not api XML data, try this
|
||||
@@ -93,6 +96,7 @@ class CharacterImportThread(threading.Thread):
|
||||
|
||||
wx.CallAfter(self.callback)
|
||||
|
||||
|
||||
class SkillBackupThread(threading.Thread):
|
||||
def __init__(self, path, saveFmt, activeFit, callback):
|
||||
threading.Thread.__init__(self)
|
||||
@@ -104,9 +108,6 @@ class SkillBackupThread(threading.Thread):
|
||||
def run(self):
|
||||
path = self.path
|
||||
sCharacter = Character.getInstance()
|
||||
sFit = service.Fit.getInstance()
|
||||
fit = sFit.getFit(self.activeFit)
|
||||
backupData = ""
|
||||
if self.saveFmt == "xml" or self.saveFmt == "emp":
|
||||
backupData = sCharacter.exportXml()
|
||||
else:
|
||||
@@ -116,11 +117,12 @@ class SkillBackupThread(threading.Thread):
|
||||
with gzip.open(path, mode='wb') as backupFile:
|
||||
backupFile.write(backupData)
|
||||
else:
|
||||
with open(path, mode='w',encoding='utf-8') as backupFile:
|
||||
with open(path, mode='w', encoding='utf-8') as backupFile:
|
||||
backupFile.write(backupData)
|
||||
|
||||
wx.CallAfter(self.callback)
|
||||
|
||||
|
||||
class Character(object):
|
||||
instance = None
|
||||
skillReqsDict = {}
|
||||
@@ -138,7 +140,7 @@ class Character(object):
|
||||
self.all5()
|
||||
|
||||
def exportText(self):
|
||||
data = "Pyfa exported plan for \""+self.skillReqsDict['charname']+"\"\n"
|
||||
data = "Pyfa exported plan for \"" + self.skillReqsDict['charname'] + "\"\n"
|
||||
data += "=" * 79 + "\n"
|
||||
data += "\n"
|
||||
item = ""
|
||||
@@ -154,7 +156,7 @@ class Character(object):
|
||||
|
||||
def exportXml(self):
|
||||
root = ElementTree.Element("plan")
|
||||
root.attrib["name"] = "Pyfa exported plan for "+self.skillReqsDict['charname']
|
||||
root.attrib["name"] = "Pyfa exported plan for " + self.skillReqsDict['charname']
|
||||
root.attrib["revision"] = config.evemonMinVersion
|
||||
|
||||
sorts = ElementTree.SubElement(root, "sorting")
|
||||
@@ -165,9 +167,9 @@ class Character(object):
|
||||
skillsSeen = set()
|
||||
|
||||
for s in self.skillReqsDict['skills']:
|
||||
skillKey = str(s["skillID"])+"::"+s["skill"]+"::"+str(int(s["level"]))
|
||||
skillKey = str(s["skillID"]) + "::" + s["skill"] + "::" + str(int(s["level"]))
|
||||
if skillKey in skillsSeen:
|
||||
pass # Duplicate skills confuse EVEMon
|
||||
pass # Duplicate skills confuse EVEMon
|
||||
else:
|
||||
skillsSeen.add(skillKey)
|
||||
entry = ElementTree.SubElement(root, "entry")
|
||||
@@ -179,7 +181,7 @@ class Character(object):
|
||||
notes = ElementTree.SubElement(entry, "notes")
|
||||
notes.text = entry.attrib["skill"]
|
||||
|
||||
tree = ElementTree.ElementTree(root)
|
||||
# tree = ElementTree.ElementTree(root)
|
||||
data = ElementTree.tostring(root, 'utf-8')
|
||||
prettydata = minidom.parseString(data).toprettyxml(indent=" ")
|
||||
|
||||
@@ -194,13 +196,13 @@ class Character(object):
|
||||
thread.start()
|
||||
|
||||
def all0(self):
|
||||
return eos.types.Character.getAll0()
|
||||
return es_Character.getAll0()
|
||||
|
||||
def all0ID(self):
|
||||
return self.all0().ID
|
||||
|
||||
def all5(self):
|
||||
return eos.types.Character.getAll5()
|
||||
return es_Character.getAll5()
|
||||
|
||||
def all5ID(self):
|
||||
return self.all5().ID
|
||||
@@ -246,7 +248,7 @@ class Character(object):
|
||||
group = eos.db.getGroup(groupID)
|
||||
skills = []
|
||||
for skill in group.items:
|
||||
if skill.published == True:
|
||||
if skill.published is True:
|
||||
skills.append((skill.ID, skill.name))
|
||||
return skills
|
||||
|
||||
@@ -267,7 +269,7 @@ class Character(object):
|
||||
return eos.db.getCharacter(charID).name
|
||||
|
||||
def new(self, name="New Character"):
|
||||
char = eos.types.Character(name)
|
||||
char = es_Character(name)
|
||||
eos.db.save(char)
|
||||
return char
|
||||
|
||||
@@ -295,8 +297,8 @@ class Character(object):
|
||||
return (char.apiID or "", char.apiKey or "", char.defaultChar or "", chars or [])
|
||||
|
||||
def apiEnabled(self, charID):
|
||||
id, key, default, _ = self.getApiDetails(charID)
|
||||
return id is not "" and key is not "" and default is not ""
|
||||
id_, key, default, _ = self.getApiDetails(charID)
|
||||
return id_ is not "" and key is not "" and default is not ""
|
||||
|
||||
def apiCharList(self, charID, userID, apiKey):
|
||||
char = eos.db.getCharacter(charID)
|
||||
@@ -304,7 +306,7 @@ class Character(object):
|
||||
char.apiID = userID
|
||||
char.apiKey = apiKey
|
||||
|
||||
api = service.EVEAPIConnection()
|
||||
api = EVEAPIConnection()
|
||||
auth = api.auth(keyID=userID, vCode=apiKey)
|
||||
apiResult = auth.account.Characters()
|
||||
charList = map(lambda c: unicode(c.name), apiResult.characters)
|
||||
@@ -316,7 +318,7 @@ class Character(object):
|
||||
dbChar = eos.db.getCharacter(charID)
|
||||
dbChar.defaultChar = charName
|
||||
|
||||
api = service.EVEAPIConnection()
|
||||
api = EVEAPIConnection()
|
||||
auth = api.auth(keyID=dbChar.apiID, vCode=dbChar.apiKey)
|
||||
apiResult = auth.account.Characters()
|
||||
charID = None
|
||||
@@ -324,7 +326,7 @@ class Character(object):
|
||||
if char.name == charName:
|
||||
charID = char.characterID
|
||||
|
||||
if charID == None:
|
||||
if charID is None:
|
||||
return
|
||||
|
||||
sheet = auth.character(charID).CharacterSheet()
|
||||
@@ -366,7 +368,7 @@ class Character(object):
|
||||
logger.error("Trying to add implant to read-only character")
|
||||
return
|
||||
|
||||
implant = eos.types.Implant(eos.db.getItem(itemID))
|
||||
implant = es_Implant(eos.db.getItem(itemID))
|
||||
char.implants.append(implant)
|
||||
eos.db.commit()
|
||||
|
||||
@@ -380,20 +382,20 @@ class Character(object):
|
||||
return char.implants
|
||||
|
||||
def checkRequirements(self, fit):
|
||||
toCheck = []
|
||||
# toCheck = []
|
||||
reqs = {}
|
||||
for thing in itertools.chain(fit.modules, fit.drones, fit.fighters, (fit.ship,)):
|
||||
if isinstance(thing, eos.types.Module) and thing.slot == eos.types.Slot.RIG:
|
||||
if isinstance(thing, es_Module) and thing.slot == es_Slot.RIG:
|
||||
continue
|
||||
for attr in ("item", "charge"):
|
||||
if attr == "charge" and isinstance(thing, eos.types.Fighter):
|
||||
if attr == "charge" and isinstance(thing, es_Fighter):
|
||||
# Fighter Bombers are automatically charged with micro bombs.
|
||||
# These have skill requirements attached, but aren't used in EVE.
|
||||
continue
|
||||
subThing = getattr(thing, attr, None)
|
||||
subReqs = {}
|
||||
if subThing is not None:
|
||||
if isinstance(thing, eos.types.Fighter) and attr == "charge":
|
||||
if isinstance(thing, es_Fighter) and attr == "charge":
|
||||
continue
|
||||
self._checkRequirements(fit, fit.character, subThing, subReqs)
|
||||
if subReqs:
|
||||
|
||||
Reference in New Issue
Block a user