Skip to content

Commit

Permalink
pyCharm inspection fixes. Mostly variable refernce issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebag333 committed Feb 9, 2017
1 parent de87c99 commit 3e916e4
Show file tree
Hide file tree
Showing 24 changed files with 70 additions and 51 deletions.
2 changes: 2 additions & 0 deletions eos/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ReadOnlyException(Exception):
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()
Expand Down
1 change: 1 addition & 0 deletions eos/db/saveddata/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def setCache(cacheKey, args, kwargs):
def checkAndReturn(*args, **kwargs):
useCache = kwargs.pop("useCache", True)
cacheKey = []
items = None
cacheKey.extend(args)
for keyword in keywords:
cacheKey.append(kwargs.get(keyword))
Expand Down
5 changes: 0 additions & 5 deletions eos/effectHandlerHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
10 changes: 2 additions & 8 deletions eos/saveddata/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

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
Expand All @@ -39,15 +38,10 @@

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
Expand Down Expand Up @@ -727,7 +721,7 @@ def calculateModifiedAttributes(self, targetFit=None, withBoosters=False, dirtyS
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)
Expand Down
3 changes: 2 additions & 1 deletion gui/boosterView.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@


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
Expand Down
2 changes: 1 addition & 1 deletion gui/builtinContextMenus/moduleAmmoPicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def getSubMenu(self, context, selection, rootMenu, i, pitem):
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")
Expand Down
1 change: 1 addition & 0 deletions gui/builtinContextMenus/moduleGlobalAmmoPicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class ModuleGlobalAmmoPicker(ModuleAmmoPicker):
def __init__(self):
super(ModuleGlobalAmmoPicker, self).__init__()
self.mainFrame = gui.mainFrame.MainFrame.getInstance()

def getText(self, itmContext, selection):
Expand Down
47 changes: 29 additions & 18 deletions gui/builtinStatsViews/resourcesViewFull.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,52 +216,61 @@ def refreshPanel(self, fit):
("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

Expand Down Expand Up @@ -316,6 +325,8 @@ def refreshPanel(self, fit):
lambda: fit.ship.getModifiedItemAttr("droneBandwidth"),
lambda: fit.ship.getModifiedItemAttr("capacity"),
)
else:
resMax = None

i = 0
for resourceType in ("cpu", "pg", "droneBay", "fighterBay", "droneBandwidth", "cargoBay"):
Expand Down
3 changes: 2 additions & 1 deletion gui/builtinViews/fittingView.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def handleDrag(self, type, fitID):

# 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
Expand Down
3 changes: 2 additions & 1 deletion gui/cargoView.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@


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
Expand Down
1 change: 1 addition & 0 deletions gui/chromeTabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,7 @@ def UpdateTabsPosition(self, skipTab=None):

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
Expand Down
3 changes: 2 additions & 1 deletion gui/commandView.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def __init__(self, txt):


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
Expand Down
4 changes: 2 additions & 2 deletions gui/crestFittings.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def fetchFittings(self, event):
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
Expand Down
3 changes: 2 additions & 1 deletion gui/droneView.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@


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
Expand Down
3 changes: 2 additions & 1 deletion gui/fighterView.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@


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
Expand Down
4 changes: 2 additions & 2 deletions gui/mainFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gui/marketBrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(self, parent):
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)
Expand Down
3 changes: 2 additions & 1 deletion gui/projectedView.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __init__(self, txt):


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
Expand Down
2 changes: 2 additions & 0 deletions gui/resistsEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def ValuesUpdated(self, event=None):
if self.block:
return

editObj = None

try:
p = self.entityEditor.getActiveEntity()

Expand Down
5 changes: 4 additions & 1 deletion gui/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, *args, **kwds):
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:
Expand Down Expand Up @@ -194,8 +195,10 @@ def setdefault(self, key, default=None):
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 '...'
Expand Down
6 changes: 2 additions & 4 deletions service/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,7 @@ def appendModule(self, fitID, itemID):
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
Expand All @@ -450,7 +448,7 @@ def removeModule(self, fitID, position):
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)
Expand Down
2 changes: 0 additions & 2 deletions service/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,6 @@ def getShipList(self, grpid):
"""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):
Expand Down
2 changes: 2 additions & 0 deletions service/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def importFitFromFiles(self, paths, callback=None):
# 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'),
Expand Down
5 changes: 4 additions & 1 deletion utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, *args, **kwds):
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:
Expand Down Expand Up @@ -193,8 +194,10 @@ def setdefault(self, key, default=None):
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 '...'
Expand Down

0 comments on commit 3e916e4

Please sign in to comment.