pyCharm inspection fixes. Mostly variable refernce issues

This commit is contained in:
Ebag333
2017-02-08 17:55:20 -08:00
parent de87c992d7
commit 3e916e42f2
24 changed files with 70 additions and 51 deletions

View File

@@ -62,6 +62,8 @@ if saveddata_connectionstring is not None:
saveddata_meta = MetaData()
saveddata_meta.bind = saveddata_engine
saveddata_session = sessionmaker(bind=saveddata_engine, autoflush=False, expire_on_commit=False)()
else:
saveddata_meta = None
# Lock controlling any changes introduced to session
sd_lock = threading.Lock()

View File

@@ -68,6 +68,7 @@ if configVal is True:
def checkAndReturn(*args, **kwargs):
useCache = kwargs.pop("useCache", True)
cacheKey = []
items = None
cacheKey.extend(args)
for keyword in keywords:
cacheKey.append(kwargs.get(keyword))

View File

@@ -17,12 +17,7 @@
# along with eos. If not, see <http://www.gnu.org/licenses/>.
# ===============================================================================
# from sqlalchemy.orm.attributes import flag_modified
import logging
# TODO: This can't point to es_Module, cyclical import loop
# from eos.saveddata.module import Module as es_Module, State as es_State
import eos.db
logger = logging.getLogger(__name__)

View File

@@ -27,7 +27,6 @@ from sqlalchemy.orm import validates, reconstructor
import eos.db
from eos import capSim
from eos.effectHandlerHelpers import *
from eos.effectHandlerHelpers import HandledModuleList, HandledDroneCargoList, HandledImplantBoosterList, HandledProjectedDroneList, HandledProjectedModList
from eos.enum import Enum
from eos.saveddata.ship import Ship
@@ -39,15 +38,10 @@ import logging
logger = logging.getLogger(__name__)
try:
from collections import OrderedDict
except ImportError:
from utils.compat import OrderedDict
class ImplantLocation(Enum):
def __init__(self):
pass
Enum.__init__(self)
FIT = 0
CHARACTER = 1
@@ -727,7 +721,7 @@ class Fit(object):
self.register(item)
item.calculateModifiedAttributes(self, runTime, False)
if projected is True and item not in chain.from_iterable(r):
if projected is True and projectionInfo and item not in chain.from_iterable(r):
# apply effects onto target fit
for _ in xrange(projectionInfo.amount):
targetFit.register(item, origin=self)

View File

@@ -27,7 +27,8 @@ from service.fit import Fit
class BoosterViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
def __init__(self, dropFn, *args, **kwargs):
super(BoosterViewDrop, self).__init__(*args, **kwargs)
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID

View File

@@ -157,7 +157,7 @@ class ModuleAmmoPicker(ContextMenu):
item = self.addCharge(rootMenu if msw else m, charge)
items.append(item)
else:
if sub is None:
if sub is None and item and base:
sub = wx.Menu()
sub.Bind(wx.EVT_MENU, self.handleAmmoSwitch)
self.addSeperator(sub, "Less Damage")

View File

@@ -9,6 +9,7 @@ from service.fit import Fit
class ModuleGlobalAmmoPicker(ModuleAmmoPicker):
def __init__(self):
super(ModuleGlobalAmmoPicker, self).__init__()
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
def getText(self, itmContext, selection):

View File

@@ -216,52 +216,61 @@ class ResourcesViewFull(StatsView):
("label%sTotalCargoBay", lambda: fit.ship.getModifiedItemAttr("capacity"), 3, 0, 9),
)
panel = "Full"
usedTurretHardpoints = 0
labelUTH = ""
totalTurretHardpoints = 0
labelTTH = ""
usedLauncherHardpoints = 0
labelULH = ""
totalLauncherHardPoints = 0
labelTLH = ""
usedDronesActive = 0
labelUDA = ""
totalDronesActive = 0
labelTDA = ""
usedFighterTubes = 0
labelUFT = ""
totalFighterTubes = 0
labelTFT = ""
usedCalibrationPoints = 0
labelUCP = ""
totalCalibrationPoints = 0
labelTCP = ""
for labelName, value, prec, lowest, highest in stats:
label = getattr(self, labelName % panel)
value = value() if fit is not None else 0
value = value if value is not None else 0
if labelName % panel == "label%sUsedTurretHardpoints" % panel:
usedTurretHardpoints = value
labelUTH = label
if labelName % panel == "label%sTotalTurretHardpoints" % panel:
elif labelName % panel == "label%sTotalTurretHardpoints" % panel:
totalTurretHardpoints = value
labelTTH = label
if labelName % panel == "label%sUsedLauncherHardpoints" % panel:
elif labelName % panel == "label%sUsedLauncherHardpoints" % panel:
usedLauncherHardpoints = value
labelULH = label
if labelName % panel == "label%sTotalLauncherHardpoints" % panel:
elif labelName % panel == "label%sTotalLauncherHardpoints" % panel:
totalLauncherHardPoints = value
labelTLH = label
if labelName % panel == "label%sUsedDronesActive" % panel:
elif labelName % panel == "label%sUsedDronesActive" % panel:
usedDronesActive = value
labelUDA = label
if labelName % panel == "label%sTotalDronesActive" % panel:
elif labelName % panel == "label%sTotalDronesActive" % panel:
totalDronesActive = value
labelTDA = label
if labelName % panel == "label%sUsedFighterTubes" % panel:
elif labelName % panel == "label%sUsedFighterTubes" % panel:
usedFighterTubes = value
labelUFT = label
if labelName % panel == "label%sTotalFighterTubes" % panel:
elif labelName % panel == "label%sTotalFighterTubes" % panel:
totalFighterTubes = value
labelTFT = label
if labelName % panel == "label%sUsedCalibrationPoints" % panel:
elif labelName % panel == "label%sUsedCalibrationPoints" % panel:
usedCalibrationPoints = value
labelUCP = label
if labelName % panel == "label%sTotalCalibrationPoints" % panel:
elif labelName % panel == "label%sTotalCalibrationPoints" % panel:
totalCalibrationPoints = value
labelTCP = label
@@ -316,6 +325,8 @@ class ResourcesViewFull(StatsView):
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"),
lambda: fit.ship.getModifiedItemAttr("capacity"),
)
else:
resMax = None
i = 0
for resourceType in ("cpu", "pg", "droneBay", "fighterBay", "droneBandwidth", "cargoBay"):

View File

@@ -97,7 +97,8 @@ FitSpawner.register()
# Drag'n'drop handler
class FittingViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
def __init__(self, dropFn, *args, **kwargs):
super(FittingViewDrop, self).__init__(*args, **kwargs)
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID

View File

@@ -27,7 +27,8 @@ from service.market import Market
class CargoViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
def __init__(self, dropFn, *args, **kwargs):
super(CargoViewDrop, self).__init__(*args, **kwargs)
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID

View File

@@ -1268,6 +1268,7 @@ class PFTabsContainer(wx.Panel):
pos = tabsWidth
selected = None
selpos = None
for i in range(len(self.tabs) - 1, -1, -1):
tab = self.tabs[i]
width = tab.tabWidth - self.inclination * 2

View File

@@ -40,7 +40,8 @@ class DummyEntry:
class CommandViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
def __init__(self, dropFn, *args, **kwargs):
super(CommandViewDrop, self).__init__(*args, **kwargs)
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID

View File

@@ -144,10 +144,10 @@ class CrestFittings(wx.Frame):
self.updateCacheStatus(None)
self.cacheTimer.Start(1000)
self.fitTree.populateSkillTree(fittings)
del waitDialog
except requests.exceptions.ConnectionError:
self.statusbar.SetStatusText("Connection error, please check your internet connection")
finally:
del waitDialog
def importFitting(self, event):
selection = self.fitView.fitSelection

View File

@@ -29,7 +29,8 @@ from service.market import Market
class DroneViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
def __init__(self, dropFn, *args, **kwargs):
super(DroneViewDrop, self).__init__(*args, **kwargs)
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID

View File

@@ -31,7 +31,8 @@ from service.market import Market
class FighterViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
def __init__(self, dropFn, *args, **kwargs):
super(FighterViewDrop, self).__init__(*args, **kwargs)
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID

View File

@@ -55,7 +55,7 @@ from gui.graphFrame import GraphFrame
from gui.copySelectDialog import CopySelectDialog
from gui.utils.clipboard import toClipboard, fromClipboard
from gui.updateDialog import UpdateDialog
from gui.builtinViews import emptyView, entityEditor, fittingView, implantEditor
from gui.builtinViews import emptyView, entityEditor, fittingView, implantEditor # noqa: F401
from gui import graphFrame
from service.settings import SettingsProvider
@@ -136,7 +136,7 @@ class MainFrame(wx.Frame):
@classmethod
def getInstance(cls):
return cls.__instance if cls.__instance is not None else MainFrame()
return cls.__instance if cls.__instance is not None else MainFrame("")
def __init__(self, title):
self.title = title

View File

@@ -82,6 +82,7 @@ class MarketBrowser(wx.Panel):
p.SetSizer(box)
vbox.Add(p, 0, wx.EXPAND)
self.metaButtons = []
btn = None
for name in self.sMkt.META_MAP.keys():
btn = MetaButton(p, wx.ID_ANY, name.capitalize(), style=wx.BU_EXACTFIT)
setattr(self, name, btn)

View File

@@ -42,7 +42,8 @@ class DummyEntry:
class ProjectedViewDrop(wx.PyDropTarget):
def __init__(self, dropFn):
def __init__(self, dropFn, *args, **kwargs):
super(ProjectedViewDrop, self).__init__(*args, **kwargs)
wx.PyDropTarget.__init__(self)
self.dropFn = dropFn
# this is really transferring an EVE itemID

View File

@@ -197,6 +197,8 @@ class ResistsEditorDlg(wx.Dialog):
if self.block:
return
editObj = None
try:
p = self.entityEditor.getActiveEntity()

View File

@@ -31,6 +31,7 @@ class OrderedDict(dict):
because their insertion order is arbitrary.
'''
super(OrderedDict, self).__init__(**kwds)
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
@@ -194,8 +195,10 @@ class OrderedDict(dict):
self[key] = default
return default
def __repr__(self, _repr_running={}):
def __repr__(self, _repr_running=None):
'od.__repr__() <==> repr(od)'
if _repr_running is None:
_repr_running = {}
call_key = id(self), _get_ident()
if call_key in _repr_running:
return '...'

View File

@@ -421,9 +421,7 @@ class Fit(object):
return False
if m.item.category.name == "Subsystem":
slot = m.getModifiedItemAttr("subSystemSlot")
dummy_module = es_Module.buildEmpty(fit.modules[slot])
fit.modules.freeSlot(slot, dummy_module)
fit.modules.freeSlot(m.getModifiedItemAttr("subSystemSlot"), es_Module.buildEmpty(m.slot))
if m.fits(fit):
m.owner = fit
@@ -450,7 +448,7 @@ class Fit(object):
return None
numSlots = len(fit.modules)
dummy_module = es_Module.buildEmpty(fit.modules[position].slot)
dummy_module = es_Module.buildEmpty(fit.modules[position].slot)
fit.modules.toDummy(position, dummy_module)
self.recalc(fit)
self.checkStates(fit, None)

View File

@@ -736,8 +736,6 @@ class Market():
"""Get ships for given group id"""
grp = self.getGroup(grpid, eager=("items", "items.group", "items.marketGroup"))
ships = self.getItemsByGroup(grp)
for ship in ships:
ship.race
return ships
def getShipListDelayed(self, id_, callback):

View File

@@ -115,6 +115,8 @@ class Port(object):
# codepage then fallback to utf-16, cp1252
if isinstance(srcString, str):
savebom = None
encoding_map = (
('\xef\xbb\xbf', 'utf-8'),
('\xff\xfe\0\0', 'utf-32'),

View File

@@ -30,6 +30,7 @@ class OrderedDict(dict):
because their insertion order is arbitrary.
'''
super(OrderedDict, self).__init__(**kwds)
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
@@ -193,8 +194,10 @@ class OrderedDict(dict):
self[key] = default
return default
def __repr__(self, _repr_running={}):
def __repr__(self, _repr_running=None):
'od.__repr__() <==> repr(od)'
if _repr_running is None:
_repr_running = {}
call_key = id(self), _get_ident()
if call_key in _repr_running:
return '...'