diff --git a/.gitattributes b/.gitattributes index 880b12415..9344e9905 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,7 +14,7 @@ *.py3 text eol=crlf *.pyw text eol=crlf *.pyx text eol=crlf - +pyfa.py text eol=lf # Denote all files that are truly binary and should not be modified. # Binary files diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..621db8b52 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,32 @@ +# Submit a bug report bug report or feature request + +Here you can inform pyfa developers of potential bugs or suggest features / improvements to the project. Please check +to make sure that the bug hasn't been reported or feature requested before submitting. If you have general questions +about the project and want to reach out to the developers personally, please check out out our [Slack] +(https://pyfainvite.azurewebsites.net/). + +--- + +## Bug Report + + +### Expected behavior: + + +### Actual behavior: + + +### Detailed steps to reproduce: + + +### Fits involved in EFT format (Edit > To Clipboard > EFT): + + +### Release or development git branch? Please note the release version or commit hash: + + +### Operating system and version (eg: Windows 10, OS X 10.9, OS X 10.11, Ubuntu 16.10): + + +### Other relevant information: + 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/eve.db b/eve.db index 035d2f36b..938e8c336 100644 Binary files a/eve.db and b/eve.db differ diff --git a/fun.py b/fun.py deleted file mode 100644 index 5f14c34e6..000000000 --- a/fun.py +++ /dev/null @@ -1,5 +0,0 @@ -problem 15 - -number of moves: XxY - -each block added introduces two possible moves 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/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/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/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/tests/test_package.py b/tests/test_package.py index 74450c866..19299a942 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 @@ -17,6 +27,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 +38,7 @@ def service_modules(): ) yield mod_name + def eos_modules(): for root, folders, files in os.walk("eos"): for file_ in files: @@ -37,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_service_imports(mod_name): +def test_eos_imports(mod_name): assert importlib.import_module(mod_name) +''' 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