From be66ff1eecae8493f7d60e58fd633ef49c7f0e6b Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 5 Feb 2017 15:39:07 -0800 Subject: [PATCH 1/5] Tox fixes --- eos/db/gamedata/alphaClones.py | 22 +++++++++++-------- eos/db/saveddata/databaseRepair.py | 2 +- eos/db/saveddata/queries.py | 3 --- eos/effects/chargebonuswarfarecharge.py | 3 ++- ...itebonuscommandshipinformationhiddencs3.py | 2 ++ ...ogisticremotearmorrepairoptimalfalloff1.py | 2 ++ eos/effects/energydestabilizationnew.py | 3 +-- ...ceharvestingdroneoperationdurationbonus.py | 2 ++ eos/effects/miningforemanstrengthbonus.py | 4 +++- eos/effects/modulebonuswarfarelinkarmor.py | 4 ++-- eos/effects/modulebonuswarfarelinkinfo.py | 4 +++- eos/effects/modulebonuswarfarelinkmining.py | 4 +++- eos/effects/modulebonuswarfarelinkshield.py | 4 +++- eos/effects/modulebonuswarfarelinkskirmish.py | 4 +++- eos/effects/moduletitaneffectgenerator.py | 6 ++--- eos/effects/remotehullrepair.py | 3 ++- ...olebonusremotearmorrepairoptimalfalloff.py | 2 ++ ...pbonusforceauxiliarya4warfarelinksbonus.py | 2 ++ .../shipmodesmallmissiledamagepostdiv.py | 2 +- eos/effects/structurerigmaxtargets.py | 1 - eos/saveddata/fighter.py | 4 ---- eos/saveddata/fit.py | 11 ++++------ .../pyfaCrestPreferences.py | 6 ++--- gui/builtinStatsViews/miningyieldViewFull.py | 2 +- gui/builtinViews/fittingView.py | 6 ++--- gui/crestFittings.py | 6 ++--- gui/graphFrame.py | 4 +++- gui/itemStats.py | 1 - gui/marketBrowser.py | 2 ++ pyfa.py | 2 +- requirements_test.txt | 1 + service/character.py | 2 +- service/port.py | 7 +++--- service/pycrest/eve.py | 3 --- tox.ini | 2 +- 35 files changed, 75 insertions(+), 63 deletions(-) diff --git a/eos/db/gamedata/alphaClones.py b/eos/db/gamedata/alphaClones.py index 602f8070c..184ec1538 100644 --- a/eos/db/gamedata/alphaClones.py +++ b/eos/db/gamedata/alphaClones.py @@ -23,16 +23,20 @@ from sqlalchemy.orm import relation, mapper, synonym from eos.db import gamedata_meta from eos.types import AlphaClone, AlphaCloneSkill -alphaclones_table = Table("alphaClones", gamedata_meta, - Column("alphaCloneID", Integer, primary_key=True), - Column("alphaCloneName", String), - ) +alphaclones_table = Table( + "alphaClones", + gamedata_meta, + Column("alphaCloneID", Integer, primary_key=True), + Column("alphaCloneName", String), +) -alphacloneskskills_table = Table("alphaCloneSkills", gamedata_meta, - Column("alphaCloneID", Integer, ForeignKey("alphaClones.alphaCloneID"), primary_key=True), - Column("typeID", Integer, primary_key=True), - Column("level", Integer), - ) +alphacloneskskills_table = Table( + "alphaCloneSkills", + gamedata_meta, + Column("alphaCloneID", Integer, ForeignKey("alphaClones.alphaCloneID"), primary_key=True), + Column("typeID", Integer, primary_key=True), + Column("level", Integer), +) mapper(AlphaClone, alphaclones_table, properties={ diff --git a/eos/db/saveddata/databaseRepair.py b/eos/db/saveddata/databaseRepair.py index d2654d67b..2644fd507 100644 --- a/eos/db/saveddata/databaseRepair.py +++ b/eos/db/saveddata/databaseRepair.py @@ -33,7 +33,7 @@ class DatabaseCleanup: results = saveddata_engine.execute(query) return results except sqlalchemy.exc.DatabaseError: - logger.error("Failed to connect to database or error executing query:\n%s",query) + logger.error("Failed to connect to database or error executing query:\n%s", query) return None @staticmethod diff --git a/eos/db/saveddata/queries.py b/eos/db/saveddata/queries.py index 287e83d5a..484ea7a45 100644 --- a/eos/db/saveddata/queries.py +++ b/eos/db/saveddata/queries.py @@ -22,11 +22,8 @@ from sqlalchemy.sql import and_ from eos.db import saveddata_session, sd_lock from eos.db.saveddata.fit import projectedFits_table from eos.db.util import processEager, processWhere -from eos.db import saveddata_session, sd_lock from eos.types import * -from eos.db.saveddata.fit import projectedFits_table -from sqlalchemy.sql import and_ import eos.config configVal = getattr(eos.config, "saveddataCache", None) diff --git a/eos/effects/chargebonuswarfarecharge.py b/eos/effects/chargebonuswarfarecharge.py index 6b3c5f3f2..600379c44 100644 --- a/eos/effects/chargebonuswarfarecharge.py +++ b/eos/effects/chargebonuswarfarecharge.py @@ -4,7 +4,8 @@ # Items from market group: Ammunition & Charges > Command Burst Charges (15 of 15) type = "active" + def handler(fit, module, context): for x in xrange(1, 4): value = module.getModifiedChargeAttr("warfareBuff{}Multiplier".format(x)) - module.multiplyItemAttr("warfareBuff{}Value".format(x), value) \ No newline at end of file + module.multiplyItemAttr("warfareBuff{}Value".format(x), value) diff --git a/eos/effects/elitebonuscommandshipinformationhiddencs3.py b/eos/effects/elitebonuscommandshipinformationhiddencs3.py index 27148ebec..eeee692ed 100644 --- a/eos/effects/elitebonuscommandshipinformationhiddencs3.py +++ b/eos/effects/elitebonuscommandshipinformationhiddencs3.py @@ -1,5 +1,7 @@ # Not used by any item type = "passive" + + def handler(fit, module, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Information Command Specialist"), "commandBonusHidden", module.getModifiedItemAttr("eliteBonusCommandShips3"), skill="Command Ships") diff --git a/eos/effects/elitebonuslogisticremotearmorrepairoptimalfalloff1.py b/eos/effects/elitebonuslogisticremotearmorrepairoptimalfalloff1.py index f95cfd6f6..7f8e9fec3 100644 --- a/eos/effects/elitebonuslogisticremotearmorrepairoptimalfalloff1.py +++ b/eos/effects/elitebonuslogisticremotearmorrepairoptimalfalloff1.py @@ -3,6 +3,8 @@ # Used by: # Ship: Rabisu type = "passive" + + def handler(fit, src, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Remote Armor Repair Systems"), "falloffEffectiveness", src.getModifiedItemAttr("eliteBonusLogistics1"), skill="Logistics Cruisers") fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Remote Armor Repair Systems"), "maxRange", src.getModifiedItemAttr("eliteBonusLogistics1"), skill="Logistics Cruisers") diff --git a/eos/effects/energydestabilizationnew.py b/eos/effects/energydestabilizationnew.py index 6cf82afa5..52a6b40ee 100644 --- a/eos/effects/energydestabilizationnew.py +++ b/eos/effects/energydestabilizationnew.py @@ -5,8 +5,7 @@ type = "active", "projected" def handler(fit, src, context): - if "projected" in context and ( - (hasattr(src, "state") and src.state >= State.ACTIVE) or hasattr(src, "amountActive")): + if "projected" in context and ((hasattr(src, "state") and src.state >= State.ACTIVE) or hasattr(src, "amountActive")): multiplier = src.amountActive if hasattr(src, "amountActive") else 1 amount = src.getModifiedItemAttr("energyNeutralizerAmount") time = src.getModifiedItemAttr("duration") diff --git a/eos/effects/iceharvestingdroneoperationdurationbonus.py b/eos/effects/iceharvestingdroneoperationdurationbonus.py index 970c8c0d1..9cd10d66a 100644 --- a/eos/effects/iceharvestingdroneoperationdurationbonus.py +++ b/eos/effects/iceharvestingdroneoperationdurationbonus.py @@ -4,6 +4,8 @@ # Modules named like: Drone Mining Augmentor (8 of 8) # Skill: Ice Harvesting Drone Operation type = "passive" + + def handler(fit, src, context): lvl = src.level if "skill" in context else 1 fit.drones.filteredItemBoost(lambda mod: mod.item.requiresSkill("Ice Harvesting Drone Operation"), "duration", src.getModifiedItemAttr("rofBonus") * lvl) diff --git a/eos/effects/miningforemanstrengthbonus.py b/eos/effects/miningforemanstrengthbonus.py index ac280eb87..e7af57839 100644 --- a/eos/effects/miningforemanstrengthbonus.py +++ b/eos/effects/miningforemanstrengthbonus.py @@ -3,9 +3,11 @@ # Used by: # Skill: Mining Director type = "passive" + + def handler(fit, src, context): lvl = src.level fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining Foreman"), "warfareBuff4Value", src.getModifiedItemAttr("commandStrengthBonus") * lvl) fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining Foreman"), "warfareBuff3Value", src.getModifiedItemAttr("commandStrengthBonus") * lvl) fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining Foreman"), "warfareBuff2Value", src.getModifiedItemAttr("commandStrengthBonus") * lvl) - fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining Foreman"), "warfareBuff1Value", src.getModifiedItemAttr("commandStrengthBonus") * lvl) \ No newline at end of file + fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Mining Foreman"), "warfareBuff1Value", src.getModifiedItemAttr("commandStrengthBonus") * lvl) diff --git a/eos/effects/modulebonuswarfarelinkarmor.py b/eos/effects/modulebonuswarfarelinkarmor.py index f39ae8a1b..2c792da83 100644 --- a/eos/effects/modulebonuswarfarelinkarmor.py +++ b/eos/effects/modulebonuswarfarelinkarmor.py @@ -13,6 +13,8 @@ which warfareBuffID to run (shouldn't need this right now, but better safe than ''' type = "active", "gang" + + def handler(fit, module, context, **kwargs): for x in xrange(1, 5): if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)): @@ -21,5 +23,3 @@ def handler(fit, module, context, **kwargs): if id: fit.addCommandBonus(id, value, module, kwargs['effect']) - - diff --git a/eos/effects/modulebonuswarfarelinkinfo.py b/eos/effects/modulebonuswarfarelinkinfo.py index 2951cc9db..491d824ad 100644 --- a/eos/effects/modulebonuswarfarelinkinfo.py +++ b/eos/effects/modulebonuswarfarelinkinfo.py @@ -4,6 +4,8 @@ # Variations of module: Information Command Burst I (2 of 2) type = "active", "gang" + + def handler(fit, module, context, **kwargs): for x in xrange(1, 5): if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)): @@ -11,4 +13,4 @@ def handler(fit, module, context, **kwargs): id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x)) if id: - fit.addCommandBonus(id, value, module, kwargs['effect']) \ No newline at end of file + fit.addCommandBonus(id, value, module, kwargs['effect']) diff --git a/eos/effects/modulebonuswarfarelinkmining.py b/eos/effects/modulebonuswarfarelinkmining.py index 494495873..fa28fcf4d 100644 --- a/eos/effects/modulebonuswarfarelinkmining.py +++ b/eos/effects/modulebonuswarfarelinkmining.py @@ -4,6 +4,8 @@ # Variations of module: Mining Foreman Burst I (2 of 2) type = "active", "gang" + + def handler(fit, module, context, **kwargs): for x in xrange(1, 5): if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)): @@ -11,4 +13,4 @@ def handler(fit, module, context, **kwargs): id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x)) if id: - fit.addCommandBonus(id, value, module, kwargs['effect']) \ No newline at end of file + fit.addCommandBonus(id, value, module, kwargs['effect']) diff --git a/eos/effects/modulebonuswarfarelinkshield.py b/eos/effects/modulebonuswarfarelinkshield.py index 08b19b3a3..f8d3130e0 100644 --- a/eos/effects/modulebonuswarfarelinkshield.py +++ b/eos/effects/modulebonuswarfarelinkshield.py @@ -4,6 +4,8 @@ # Variations of module: Shield Command Burst I (2 of 2) type = "active", "gang" + + def handler(fit, module, context, **kwargs): for x in xrange(1, 5): if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)): @@ -11,4 +13,4 @@ def handler(fit, module, context, **kwargs): id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x)) if id: - fit.addCommandBonus(id, value, module, kwargs['effect']) \ No newline at end of file + fit.addCommandBonus(id, value, module, kwargs['effect']) diff --git a/eos/effects/modulebonuswarfarelinkskirmish.py b/eos/effects/modulebonuswarfarelinkskirmish.py index 53f1d0a06..84b0cea3e 100644 --- a/eos/effects/modulebonuswarfarelinkskirmish.py +++ b/eos/effects/modulebonuswarfarelinkskirmish.py @@ -4,6 +4,8 @@ # Variations of module: Skirmish Command Burst I (2 of 2) type = "active", "gang" + + def handler(fit, module, context, **kwargs): for x in xrange(1, 5): if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)): @@ -11,4 +13,4 @@ def handler(fit, module, context, **kwargs): id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x)) if id: - fit.addCommandBonus(id, value, module, kwargs['effect']) \ No newline at end of file + fit.addCommandBonus(id, value, module, kwargs['effect']) diff --git a/eos/effects/moduletitaneffectgenerator.py b/eos/effects/moduletitaneffectgenerator.py index 64e21857a..901a0e89e 100644 --- a/eos/effects/moduletitaneffectgenerator.py +++ b/eos/effects/moduletitaneffectgenerator.py @@ -3,6 +3,8 @@ # Used by: # Modules from group: Titan Phenomena Generator (4 of 4) type = "active", "gang" + + def handler(fit, module, context, **kwargs): for x in xrange(1, 5): if module.getModifiedItemAttr("warfareBuff{}ID".format(x)): @@ -11,7 +13,3 @@ def handler(fit, module, context, **kwargs): if id: fit.addCommandBonus(id, value, module, kwargs['effect']) - - - - diff --git a/eos/effects/remotehullrepair.py b/eos/effects/remotehullrepair.py index 099e0c2ac..508b5684e 100644 --- a/eos/effects/remotehullrepair.py +++ b/eos/effects/remotehullrepair.py @@ -4,7 +4,8 @@ runTime = "late" def handler(fit, module, context): - if "projected" not in context: return + if "projected" not in context: + return bonus = module.getModifiedItemAttr("structureDamageAmount") duration = module.getModifiedItemAttr("duration") / 1000.0 fit.extraAttributes.increase("hullRepair", bonus / duration) diff --git a/eos/effects/rolebonusremotearmorrepairoptimalfalloff.py b/eos/effects/rolebonusremotearmorrepairoptimalfalloff.py index 86acf05b0..c286514f2 100644 --- a/eos/effects/rolebonusremotearmorrepairoptimalfalloff.py +++ b/eos/effects/rolebonusremotearmorrepairoptimalfalloff.py @@ -3,6 +3,8 @@ # Used by: # Ship: Rabisu type = "passive" + + def handler(fit, src, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Remote Armor Repair Systems"), "falloffEffectiveness", src.getModifiedItemAttr("roleBonusRepairRange")) fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Remote Armor Repair Systems"), "maxRange", src.getModifiedItemAttr("roleBonusRepairRange")) diff --git a/eos/effects/shipbonusforceauxiliarya4warfarelinksbonus.py b/eos/effects/shipbonusforceauxiliarya4warfarelinksbonus.py index 363c6bd96..a8378046b 100644 --- a/eos/effects/shipbonusforceauxiliarya4warfarelinksbonus.py +++ b/eos/effects/shipbonusforceauxiliarya4warfarelinksbonus.py @@ -3,6 +3,8 @@ # Used by: # Ship: Apostle type = "passive" + + def handler(fit, src, context): fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Armored Command") or mod.item.requiresSkill("Information Command"), "warfareBuff4Value", src.getModifiedItemAttr("shipBonusForceAuxiliaryA4"), skill="Amarr Carrier") fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Armored Command") or mod.item.requiresSkill("Information Command"), "warfareBuff3Value", src.getModifiedItemAttr("shipBonusForceAuxiliaryA4"), skill="Amarr Carrier") diff --git a/eos/effects/shipmodesmallmissiledamagepostdiv.py b/eos/effects/shipmodesmallmissiledamagepostdiv.py index 85a4cb534..31df33c3a 100644 --- a/eos/effects/shipmodesmallmissiledamagepostdiv.py +++ b/eos/effects/shipmodesmallmissiledamagepostdiv.py @@ -11,5 +11,5 @@ def handler(fit, module, context): fit.modules.filteredChargeMultiply(lambda mod: mod.charge.requiresSkill("Rockets") or mod.charge.requiresSkill("Light Missiles"), "{}Damage".format(type), 1 / module.getModifiedItemAttr("modeDamageBonusPostDiv"), - stackingPenalties = True, + stackingPenalties=True, penaltyGroup="postDiv") diff --git a/eos/effects/structurerigmaxtargets.py b/eos/effects/structurerigmaxtargets.py index 49506515f..47e2ce5d2 100644 --- a/eos/effects/structurerigmaxtargets.py +++ b/eos/effects/structurerigmaxtargets.py @@ -4,4 +4,3 @@ type = "passive" def handler(fit, src, context): fit.extraAttributes.increase("maxTargetsLockedFromSkills", src.getModifiedItemAttr("structureRigMaxTargetBonus")) - diff --git a/eos/saveddata/fighter.py b/eos/saveddata/fighter.py index d46b1a6fe..94e7e93c6 100644 --- a/eos/saveddata/fighter.py +++ b/eos/saveddata/fighter.py @@ -148,10 +148,6 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): def item(self): return self.__item - @property - def charge(self): - return self.__charge - @property def hasAmmo(self): return self.charge is not None diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index f338564f2..26bac09ea 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -487,11 +487,9 @@ class Fit(object): self.ship.boostItemAttr("armor%sDamageResonance" % damageType, value) if warfareBuffID == 14: # Armor Burst: Rapid Repair: Repair Duration/Capacitor - self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill( - "Remote Armor Repair Systems") or mod.item.requiresSkill("Repair Systems"), + self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Remote Armor Repair Systems") or mod.item.requiresSkill("Repair Systems"), "capacitorNeed", value) - self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill( - "Remote Armor Repair Systems") or mod.item.requiresSkill("Repair Systems"), "duration", + self.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill("Remote Armor Repair Systems") or mod.item.requiresSkill("Repair Systems"), "duration", value) if warfareBuffID == 15: # Armor Burst: Armor Reinforcement: Armor HP @@ -512,9 +510,8 @@ class Fit(object): "scan%sStrengthBonus" % scanType, value, stackingPenalties=True) - for attr in ( - "missileVelocityBonus", "explosionDelayBonus", "aoeVelocityBonus", "falloffBonus", - "maxRangeBonus", "aoeCloudSizeBonus", "trackingSpeedBonus"): + for attr in ("missileVelocityBonus", "explosionDelayBonus", "aoeVelocityBonus", "falloffBonus", + "maxRangeBonus", "aoeCloudSizeBonus", "trackingSpeedBonus"): self.modules.filteredItemBoost(lambda mod: mod.item.group.name == "Weapon Disruptor", attr, value) diff --git a/gui/builtinPreferenceViews/pyfaCrestPreferences.py b/gui/builtinPreferenceViews/pyfaCrestPreferences.py index 6e73f4ce6..7a54dbc83 100644 --- a/gui/builtinPreferenceViews/pyfaCrestPreferences.py +++ b/gui/builtinPreferenceViews/pyfaCrestPreferences.py @@ -5,13 +5,13 @@ from gui.bitmapLoader import BitmapLoader import gui.mainFrame -if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)): - from service.crest import Crest - from service.settings import CRESTSettings from wx.lib.intctrl import IntCtrl +if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)): + from service.crest import Crest + class PFCrestPref(PreferenceView): title = "CREST" diff --git a/gui/builtinStatsViews/miningyieldViewFull.py b/gui/builtinStatsViews/miningyieldViewFull.py index eed6e5d85..545b47c88 100644 --- a/gui/builtinStatsViews/miningyieldViewFull.py +++ b/gui/builtinStatsViews/miningyieldViewFull.py @@ -127,7 +127,7 @@ class MiningYieldViewFull(StatsView): def refreshPanel(self, fit): # If we did anything intresting, we'd update our labels to reflect the new fit's stats here - stats = (("labelFullminingyieldMiner", lambda: fit.minerYield, 3, 0, 0, u"%s m\u00B3/s",None), + stats = (("labelFullminingyieldMiner", lambda: fit.minerYield, 3, 0, 0, u"%s m\u00B3/s", None), ("labelFullminingyieldDrone", lambda: fit.droneYield, 3, 0, 0, u"%s m\u00B3/s", None), ("labelFullminingyieldTotal", lambda: fit.totalYield, 3, 0, 0, u"%s m\u00B3/s", None)) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index dae6fe86e..3260ab116 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -230,7 +230,7 @@ class FittingView(d.Display): if row != -1 and row not in self.blanks: data = wx.PyTextDataObject() - data.SetText("fitting:"+str(self.mods[row].modPosition)) + data.SetText("fitting:" + str(self.mods[row].modPosition)) dropSource = wx.DropSource(self) dropSource.SetData(data) @@ -403,7 +403,7 @@ class FittingView(d.Display): return if clone and mod2.isEmpty: - sFit.cloneModule(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition) + sFit.cloneModule(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition) else: sFit.swapModules(self.mainFrame.getActiveFit(), srcIdx, mod2.modPosition) @@ -503,7 +503,7 @@ class FittingView(d.Display): itemContext = "Tactical Mode" fullContext = (srcContext, itemContext) - if not srcContext in tuple(fCtxt[0] for fCtxt in contexts): + if srcContext not in tuple(fCtxt[0] for fCtxt in contexts): contexts.append(fullContext) selection.append(mod) diff --git a/gui/crestFittings.py b/gui/crestFittings.py index e51c0cd26..6b62f3d5e 100644 --- a/gui/crestFittings.py +++ b/gui/crestFittings.py @@ -4,9 +4,6 @@ import json import wx import requests -if not 'wxMac' in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3,0)): - from service.crest import Crest, CrestModes - from service.port import Port from service.fit import Fit @@ -16,6 +13,9 @@ from eos.db import getItem import gui.display as d import gui.globalEvents as GE +if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)): + from service.crest import Crest, CrestModes + class CrestFittings(wx.Frame): def __init__(self, parent): diff --git a/gui/graphFrame.py b/gui/graphFrame.py index 1a538f01d..9b6520a5f 100644 --- a/gui/graphFrame.py +++ b/gui/graphFrame.py @@ -19,7 +19,6 @@ import os import logging -logger = logging.getLogger(__name__) import wx @@ -39,6 +38,9 @@ try: mplImported = False except ImportError: enabled = False + +logger = logging.getLogger(__name__) +if not enabled: logger.info("Problems importing matplotlib; continuing without graphs") diff --git a/gui/itemStats.py b/gui/itemStats.py index b51b4e38c..97adfb32d 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -834,7 +834,6 @@ class ItemEffects(wx.Panel): If effect file does not exist, create it """ - import os file_ = config.getPyfaPath(os.path.join("eos", "effects", "%s.py" % event.GetText().lower())) if not os.path.isfile(file_): diff --git a/gui/marketBrowser.py b/gui/marketBrowser.py index 0a4b9c25f..213e0520d 100644 --- a/gui/marketBrowser.py +++ b/gui/marketBrowser.py @@ -31,6 +31,7 @@ ItemSelected, ITEM_SELECTED = wx.lib.newevent.NewEvent() RECENTLY_USED_MODULES = -2 MAX_RECENTLY_USED_MODULES = 20 + class MetaButton(wx.ToggleButton): def __init__(self, *args, **kwargs): super(MetaButton, self).__init__(*args, **kwargs) @@ -50,6 +51,7 @@ class MetaButton(wx.ToggleButton): self.Enable(True) self.SetValue(self.userSelected) + class MarketBrowser(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) diff --git a/pyfa.py b/pyfa.py index d5d8ad842..e465b0d5a 100755 --- a/pyfa.py +++ b/pyfa.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python # ============================================================================== # Copyright (C) 2010 Diego Duclos # diff --git a/requirements_test.txt b/requirements_test.txt index 1bbef8b92..33f8973cd 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -5,3 +5,4 @@ pytest-capturelog==0.7 coverage==4.2 coveralls==1.1 codecov +tox diff --git a/service/character.py b/service/character.py index 33cd4c765..25333edd6 100644 --- a/service/character.py +++ b/service/character.py @@ -88,7 +88,7 @@ class CharacterImportThread(threading.Thread): skill.getAttribute("typeID"), skill.getAttribute("level"), ) - char = sCharacter.new(name+" (EVEMon)") + char = sCharacter.new(name + " (EVEMon)") sCharacter.apiUpdateCharSheet(char.ID, skills) except Exception, e: logger.error("Exception on character import:") diff --git a/service/port.py b/service/port.py index cbd24007d..c64293c1b 100644 --- a/service/port.py +++ b/service/port.py @@ -34,14 +34,13 @@ from eos import db from service.fit import Fit as svcFit import wx +from service.market import Market from eos.types import State, Slot, Module, Cargo, Ship, Drone, Implant, Booster, Citadel, Fighter, Fit if 'wxMac' not in wx.PlatformInfo or ('wxMac' in wx.PlatformInfo and wx.VERSION >= (3, 0)): from service.crest import Crest -from service.market import Market - logger = logging.getLogger("pyfa.service.port") try: @@ -65,7 +64,7 @@ INV_FLAG_FIGHTER = 158 class Port(object): instance = None - + @classmethod def getInstance(cls): if cls.instance is None: @@ -685,7 +684,7 @@ class Port(object): elif entityState == "Inactive": d.amountActive = 0 f.drones.append(d) - elif droneItem.category.name == "Fighter": # EFT saves fighter as drones + elif droneItem.category.name == "Fighter": # EFT saves fighter as drones ft = Fighter(droneItem) ft.amount = int(droneAmount) if ft.amount <= ft.fighterSquadronMaxSize else ft.fighterSquadronMaxSize f.fighters.append(ft) diff --git a/service/pycrest/eve.py b/service/pycrest/eve.py index 5f6fa9ffc..b4ab03cd6 100644 --- a/service/pycrest/eve.py +++ b/service/pycrest/eve.py @@ -26,9 +26,6 @@ try: from urllib.parse import quote except ImportError: # pragma: no cover from urllib import quote -import logging -import re -import config logger = logging.getLogger("pycrest.eve") cache_re = re.compile(r'max-age=([0-9]+)') diff --git a/tox.ini b/tox.ini index ad49d6c5b..2274602e3 100644 --- a/tox.ini +++ b/tox.ini @@ -12,4 +12,4 @@ commands = py.test -vv --cov Pyfa tests/ [testenv:pep8] deps = flake8 -commands = flake8 --exclude=.svn,CVS,.bzr,.hg,.git,__pycache__,venv,tests,.tox,build,dist,__init__.py --ignore=E127,E501,E731,F401,F403,F405 service gui eos utils config.py pyfa.py --max-line-length=130 +commands = flake8 --exclude=.svn,CVS,.bzr,.hg,.git,__pycache__,venv,tests,.tox,build,dist,__init__.py --ignore=E126,E127,E128,E501,E731,F401,F403,F405 service gui eos utils config.py pyfa.py --max-line-length=130 From d67dbaa0ae448c6954bf7ae01e01c37cce50385d Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 5 Feb 2017 15:39:23 -0800 Subject: [PATCH 2/5] .gitattributes fixing line endings --- gui/builtinGraphs/fitDps.py | 190 ++++++++++++------------- gui/builtinViewColumns/ammo.py | 116 +++++++-------- gui/builtinViewColumns/ammoIcon.py | 112 +++++++-------- gui/builtinViewColumns/capacitorUse.py | 116 +++++++-------- gui/cachingImageList.py | 74 +++++----- 5 files changed, 304 insertions(+), 304 deletions(-) diff --git a/gui/builtinGraphs/fitDps.py b/gui/builtinGraphs/fitDps.py index fcbfa68fa..ae03c180b 100644 --- a/gui/builtinGraphs/fitDps.py +++ b/gui/builtinGraphs/fitDps.py @@ -1,95 +1,95 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - -from gui.graph import Graph -from gui.bitmapLoader import BitmapLoader -from eos.graph.fitDps import FitDpsGraph as FitDps -from eos.graph import Data -import gui.mainFrame -from service.attribute import Attribute - - -class FitDpsGraph(Graph): - propertyAttributeMap = {"angle": "maxVelocity", - "distance": "maxRange", - "signatureRadius": "signatureRadius", - "velocity": "maxVelocity"} - - propertyLabelMap = {"angle": "Target Angle (degrees)", - "distance": "Distance to Target (km)", - "signatureRadius": "Target Signature Radius (m)", - "velocity": "Target Velocity (m/s)"} - - defaults = FitDps.defaults.copy() - - def __init__(self): - Graph.__init__(self) - self.defaults["distance"] = "0-20" - self.name = "DPS" - self.fitDps = None - self.mainFrame = gui.mainFrame.MainFrame.getInstance() - - def getFields(self): - return self.defaults - - def getLabels(self): - return self.propertyLabelMap - - def getIcons(self): - icons = {} - sAttr = Attribute.getInstance() - for key, attrName in self.propertyAttributeMap.iteritems(): - iconFile = sAttr.getAttributeInfo(attrName).icon.iconFile - bitmap = BitmapLoader.getBitmap(iconFile, "icons") - if bitmap: - icons[key] = bitmap - - return icons - - def getPoints(self, fit, fields): - fitDps = getattr(self, "fitDps", None) - if fitDps is None or fitDps.fit != fit: - fitDps = self.fitDps = FitDps(fit) - - fitDps.clearData() - variable = None - for fieldName, value in fields.iteritems(): - d = Data(fieldName, value) - if not d.isConstant(): - if variable is None: - variable = fieldName - else: - # We can't handle more then one variable atm, OOPS FUCK OUT - return False, "Can only handle 1 variable" - - fitDps.setData(d) - - if variable is None: - return False, "No variable" - - x = [] - y = [] - for point, val in fitDps.getIterator(): - x.append(point[variable]) - y.append(val) - - return x, y - - -FitDpsGraph.register() +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + +from gui.graph import Graph +from gui.bitmapLoader import BitmapLoader +from eos.graph.fitDps import FitDpsGraph as FitDps +from eos.graph import Data +import gui.mainFrame +from service.attribute import Attribute + + +class FitDpsGraph(Graph): + propertyAttributeMap = {"angle": "maxVelocity", + "distance": "maxRange", + "signatureRadius": "signatureRadius", + "velocity": "maxVelocity"} + + propertyLabelMap = {"angle": "Target Angle (degrees)", + "distance": "Distance to Target (km)", + "signatureRadius": "Target Signature Radius (m)", + "velocity": "Target Velocity (m/s)"} + + defaults = FitDps.defaults.copy() + + def __init__(self): + Graph.__init__(self) + self.defaults["distance"] = "0-20" + self.name = "DPS" + self.fitDps = None + self.mainFrame = gui.mainFrame.MainFrame.getInstance() + + def getFields(self): + return self.defaults + + def getLabels(self): + return self.propertyLabelMap + + def getIcons(self): + icons = {} + sAttr = Attribute.getInstance() + for key, attrName in self.propertyAttributeMap.iteritems(): + iconFile = sAttr.getAttributeInfo(attrName).icon.iconFile + bitmap = BitmapLoader.getBitmap(iconFile, "icons") + if bitmap: + icons[key] = bitmap + + return icons + + def getPoints(self, fit, fields): + fitDps = getattr(self, "fitDps", None) + if fitDps is None or fitDps.fit != fit: + fitDps = self.fitDps = FitDps(fit) + + fitDps.clearData() + variable = None + for fieldName, value in fields.iteritems(): + d = Data(fieldName, value) + if not d.isConstant(): + if variable is None: + variable = fieldName + else: + # We can't handle more then one variable atm, OOPS FUCK OUT + return False, "Can only handle 1 variable" + + fitDps.setData(d) + + if variable is None: + return False, "No variable" + + x = [] + y = [] + for point, val in fitDps.getIterator(): + x.append(point[variable]) + y.append(val) + + return x, y + + +FitDpsGraph.register() diff --git a/gui/builtinViewColumns/ammo.py b/gui/builtinViewColumns/ammo.py index 27a742bce..4cd6a0ba7 100644 --- a/gui/builtinViewColumns/ammo.py +++ b/gui/builtinViewColumns/ammo.py @@ -1,58 +1,58 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - -import wx -from eos.types import Fighter -from gui.viewColumn import ViewColumn -from gui.bitmapLoader import BitmapLoader - - -class Ammo(ViewColumn): - name = "Ammo" - - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.mask = wx.LIST_MASK_IMAGE - self.imageId = fittingView.imageList.GetImageIndex("damagePattern_small", "gui") - self.bitmap = BitmapLoader.getBitmap("damagePattern_small", "gui") - - def getText(self, stuff): - if isinstance(stuff, Fighter): - # this is an experiment, not sure I like it. But it saves us from duplicating code. - col = self.columns['Fighter Abilities'](self.fittingView, {}) - text = col.getText(stuff) - del col - return text - if getattr(stuff, "charge", None) is not None: - charges = stuff.numCharges - if charges > 0: - cycles = stuff.numShots - if cycles != 0 and charges != cycles: - return "%s (%d, %d cycles)" % (stuff.charge.name, charges, cycles) - else: - return "%s (%d)" % (stuff.charge.name, charges) - else: - return stuff.charge.name - return "" - - def getImageId(self, mod): - return -1 - - -Ammo.register() +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + +import wx +from eos.types import Fighter +from gui.viewColumn import ViewColumn +from gui.bitmapLoader import BitmapLoader + + +class Ammo(ViewColumn): + name = "Ammo" + + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + self.mask = wx.LIST_MASK_IMAGE + self.imageId = fittingView.imageList.GetImageIndex("damagePattern_small", "gui") + self.bitmap = BitmapLoader.getBitmap("damagePattern_small", "gui") + + def getText(self, stuff): + if isinstance(stuff, Fighter): + # this is an experiment, not sure I like it. But it saves us from duplicating code. + col = self.columns['Fighter Abilities'](self.fittingView, {}) + text = col.getText(stuff) + del col + return text + if getattr(stuff, "charge", None) is not None: + charges = stuff.numCharges + if charges > 0: + cycles = stuff.numShots + if cycles != 0 and charges != cycles: + return "%s (%d, %d cycles)" % (stuff.charge.name, charges, cycles) + else: + return "%s (%d)" % (stuff.charge.name, charges) + else: + return stuff.charge.name + return "" + + def getImageId(self, mod): + return -1 + + +Ammo.register() diff --git a/gui/builtinViewColumns/ammoIcon.py b/gui/builtinViewColumns/ammoIcon.py index 1dc6906e3..f4f6f7af1 100644 --- a/gui/builtinViewColumns/ammoIcon.py +++ b/gui/builtinViewColumns/ammoIcon.py @@ -1,56 +1,56 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - -from gui.viewColumn import ViewColumn -import wx -from eos.types import Module - - -class AmmoIcon(ViewColumn): - name = "Ammo Icon" - - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - self.size = 24 - self.maxsize = self.size - self.mask = wx.LIST_MASK_IMAGE - self.columnText = "" - - def getText(self, mod): - return "" - - def getImageId(self, stuff): - if not isinstance(stuff, Module): - return -1 - - if stuff.charge is None: - return -1 - else: - iconFile = stuff.charge.icon.iconFile if stuff.charge.icon else "" - if iconFile: - return self.fittingView.imageList.GetImageIndex(iconFile, "icons") - else: - return -1 - - def getToolTip(self, mod): - if isinstance(mod, Module) and mod.charge is not None: - return mod.charge.name - - -AmmoIcon.register() +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + +from gui.viewColumn import ViewColumn +import wx +from eos.types import Module + + +class AmmoIcon(ViewColumn): + name = "Ammo Icon" + + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + self.size = 24 + self.maxsize = self.size + self.mask = wx.LIST_MASK_IMAGE + self.columnText = "" + + def getText(self, mod): + return "" + + def getImageId(self, stuff): + if not isinstance(stuff, Module): + return -1 + + if stuff.charge is None: + return -1 + else: + iconFile = stuff.charge.icon.iconFile if stuff.charge.icon else "" + if iconFile: + return self.fittingView.imageList.GetImageIndex(iconFile, "icons") + else: + return -1 + + def getToolTip(self, mod): + if isinstance(mod, Module) and mod.charge is not None: + return mod.charge.name + + +AmmoIcon.register() diff --git a/gui/builtinViewColumns/capacitorUse.py b/gui/builtinViewColumns/capacitorUse.py index cc5efa16c..692911400 100644 --- a/gui/builtinViewColumns/capacitorUse.py +++ b/gui/builtinViewColumns/capacitorUse.py @@ -1,58 +1,58 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - -import wx - -from eos.types import Mode -from service.attribute import Attribute -from gui.utils.numberFormatter import formatAmount -from gui.viewColumn import ViewColumn -from gui.bitmapLoader import BitmapLoader - - -class CapacitorUse(ViewColumn): - name = "Capacitor Usage" - - def __init__(self, fittingView, params): - ViewColumn.__init__(self, fittingView) - - self.mask = wx.LIST_MASK_IMAGE - - Attribute.getInstance().getAttributeInfo("capacitorNeed") - self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "gui") - self.bitmap = BitmapLoader.getBitmap("capacitorRecharge_small", "gui") - - def getText(self, mod): - if isinstance(mod, Mode): - return "" - - capUse = mod.capUse - if capUse: - return "%s%s" % ("+" if capUse < 0 else "", (formatAmount(-capUse, 3, 0, 3))) - else: - return "" - - def getImageId(self, mod): - return -1 - - def getToolTip(self, mod): - return self.name - - -CapacitorUse.register() +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + +import wx + +from eos.types import Mode +from service.attribute import Attribute +from gui.utils.numberFormatter import formatAmount +from gui.viewColumn import ViewColumn +from gui.bitmapLoader import BitmapLoader + + +class CapacitorUse(ViewColumn): + name = "Capacitor Usage" + + def __init__(self, fittingView, params): + ViewColumn.__init__(self, fittingView) + + self.mask = wx.LIST_MASK_IMAGE + + Attribute.getInstance().getAttributeInfo("capacitorNeed") + self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "gui") + self.bitmap = BitmapLoader.getBitmap("capacitorRecharge_small", "gui") + + def getText(self, mod): + if isinstance(mod, Mode): + return "" + + capUse = mod.capUse + if capUse: + return "%s%s" % ("+" if capUse < 0 else "", (formatAmount(-capUse, 3, 0, 3))) + else: + return "" + + def getImageId(self, mod): + return -1 + + def getToolTip(self, mod): + return self.name + + +CapacitorUse.register() diff --git a/gui/cachingImageList.py b/gui/cachingImageList.py index aceff6775..0762d1687 100644 --- a/gui/cachingImageList.py +++ b/gui/cachingImageList.py @@ -1,37 +1,37 @@ -# ============================================================================= -# Copyright (C) 2010 Diego Duclos -# -# This file is part of pyfa. -# -# pyfa is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# pyfa is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with pyfa. If not, see . -# ============================================================================= - - -import wx -from gui.bitmapLoader import BitmapLoader - - -class CachingImageList(wx.ImageList): - def __init__(self, width, height): - wx.ImageList.__init__(self, width, height) - self.map = {} - - def GetImageIndex(self, *loaderArgs): - id_ = self.map.get(loaderArgs) - if id_ is None: - bitmap = BitmapLoader.getBitmap(*loaderArgs) - if bitmap is None: - return -1 - id_ = self.map[loaderArgs] = wx.ImageList.Add(self, bitmap) - return id_ +# ============================================================================= +# Copyright (C) 2010 Diego Duclos +# +# This file is part of pyfa. +# +# pyfa is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pyfa is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyfa. If not, see . +# ============================================================================= + + +import wx +from gui.bitmapLoader import BitmapLoader + + +class CachingImageList(wx.ImageList): + def __init__(self, width, height): + wx.ImageList.__init__(self, width, height) + self.map = {} + + def GetImageIndex(self, *loaderArgs): + id_ = self.map.get(loaderArgs) + if id_ is None: + bitmap = BitmapLoader.getBitmap(*loaderArgs) + if bitmap is None: + return -1 + id_ = self.map[loaderArgs] = wx.ImageList.Add(self, bitmap) + return id_ From a638e991af878f180fb2452723bd0d3846021866 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 5 Feb 2017 16:05:56 -0800 Subject: [PATCH 3/5] Disable test --- tests/test_package.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_package.py b/tests/test_package.py index 74450c866..6b5eb4f8c 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -17,6 +17,7 @@ def test_packages(): assert eos assert utils + def service_modules(): for root, folders, files in os.walk("service"): for file_ in files: @@ -27,6 +28,7 @@ def service_modules(): ) yield mod_name + def eos_modules(): for root, folders, files in os.walk("eos"): for file_ in files: @@ -37,6 +39,9 @@ def eos_modules(): ) yield mod_name +# Disable test +''' @pytest.mark.parametrize("mod_name", eos_modules()) -def test_service_imports(mod_name): +def test_eos_imports(mod_name): assert importlib.import_module(mod_name) +''' From e4cd66be5cf75a6969bb9e039edad51f7e472bd4 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 5 Feb 2017 16:21:07 -0800 Subject: [PATCH 4/5] Add root to python paths --- tests/test_package.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_package.py b/tests/test_package.py index 6b5eb4f8c..8907a2823 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -1,13 +1,23 @@ """import tests.""" import os +import sys import importlib import pytest + +script_dir = os.path.dirname(os.path.abspath(__file__)) +# Add root to python paths, this allows us to import submodules +sys.path.append(os.path.realpath(os.path.join(script_dir, '..'))) + +# noinspection PyPep8 import service +# noinspection PyPep8 import gui +# noinspection PyPep8 import eos +# noinspection PyPep8 import utils @@ -39,9 +49,6 @@ def eos_modules(): ) yield mod_name -# Disable test -''' @pytest.mark.parametrize("mod_name", eos_modules()) def test_eos_imports(mod_name): assert importlib.import_module(mod_name) -''' From 808f070df458e70dcf3ef0f4da99b65a22875058 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 5 Feb 2017 16:28:16 -0800 Subject: [PATCH 5/5] Redisable dynamic import test until eos.types is gone --- tests/test_package.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_package.py b/tests/test_package.py index 8907a2823..19299a942 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -49,6 +49,9 @@ def eos_modules(): ) yield mod_name +# TODO: Disable walk through Eos paths until eos.types is killed. eos.types causes the import to break +''' @pytest.mark.parametrize("mod_name", eos_modules()) def test_eos_imports(mod_name): assert importlib.import_module(mod_name) +'''