Skip to content
Permalink
Browse files

Bunch of refactoring to clean up various code smell issues

  • Loading branch information...
Ebag333 committed May 26, 2017
1 parent 6344997 commit 0894e6096eebfce7f9b25f1aec7c66673f8abbda
@@ -144,11 +144,11 @@ def insert(self, index, mod):
i += 1
HandledList.insert(self, index, mod)

def remove(self, mod):
HandledList.remove(self, mod)
oldPos = mod.position
def remove(self, thing):
HandledList.remove(self, thing)
oldPos = thing.position

mod.position = None
thing.position = None
for i in xrange(oldPos, len(self)):
self[i].position -= 1

@@ -240,7 +240,8 @@ def clear(self):
self.__miningyield = None
self.itemModifiedAttributes.clear()
self.chargeModifiedAttributes.clear()
[x.clear() for x in self.abilities]
for x in self.abilities:
x.clear()

def canBeApplied(self, projectedOnto):
"""Check if fighter can engage specific fitting"""
@@ -30,7 +30,7 @@ def __init__(self):
self.armorReps = None
self.mainFrame = gui.mainFrame.MainFrame.getInstance()

def getFields(self):
def getGraphFields(self):
# return self.defaults
return None

@@ -30,7 +30,7 @@ def __init__(self):
self.capWarfare = None
self.mainFrame = gui.mainFrame.MainFrame.getInstance()

def getFields(self):
def getGraphFields(self):
# return self.defaults
return None

@@ -49,7 +49,7 @@ def __init__(self):
self.fitDps = None
self.mainFrame = gui.mainFrame.MainFrame.getInstance()

def getFields(self):
def getGraphFields(self):
return self.defaults

def getLabels(self):
@@ -30,7 +30,7 @@ def __init__(self):
self.hullReps = None
self.mainFrame = gui.mainFrame.MainFrame.getInstance()

def getFields(self):
def getGraphFields(self):
# return self.defaults
return None

@@ -30,7 +30,7 @@ def __init__(self):
self.shieldReps = None
self.mainFrame = gui.mainFrame.MainFrame.getInstance()

def getFields(self):
def getGraphFields(self):
# return self.defaults
return None

@@ -33,7 +33,7 @@ def __init__(self, fittingView, params):
self.mask = wx.LIST_MASK_IMAGE
self.columnText = ""

def getColumnText(self, mod):
def getColumnText(self, stuff):
return ""

def getImageId(self, mod):
@@ -70,20 +70,20 @@ def refresh(stuff):

fittingView.refresh = refresh

def getColumnText(self, mod):
if hasattr(mod, "item"):
attr = mod.getModifiedItemAttr(self.info.name)
def getColumnText(self, stuff):
if hasattr(stuff, "item"):
attr = stuff.getModifiedItemAttr(self.info.name)
else:
if self.direct:
info = self.directInfo
attr = info.get(mod.ID, "") if info else ""
attr = info.get(stuff.ID, "") if info else ""
else:
attr = mod.getAttribute(self.info.name)
attr = stuff.getAttribute(self.info.name)

if self.info.name == "volume":
str_ = (formatAmount(attr, 3, 0, 3))
if hasattr(mod, "amount"):
str_ += u"m\u00B3 (%s m\u00B3)" % (formatAmount(attr * mod.amount, 3, 0, 3))
if hasattr(stuff, "amount"):
str_ += u"m\u00B3 (%s m\u00B3)" % (formatAmount(attr * stuff.amount, 3, 0, 3))
attr = str_

if isinstance(attr, (float, int)):
@@ -94,7 +94,7 @@ def getColumnText(self, mod):
def getImageId(self, mod):
return -1

def getToolTip(self, stuff):
def getToolTip(self, mod):
if self.info.name == "cpu":
return "CPU"
else:
@@ -39,11 +39,11 @@ def __init__(self, fittingView, params):
self.imageId = fittingView.imageList.GetImageIndex("capacitorRecharge_small", "gui")
self.bitmap = BitmapLoader.getBitmap("capacitorRecharge_small", "gui")

def getColumnText(self, mod):
if isinstance(mod, Mode):
def getColumnText(self, stuff):
if isinstance(stuff, Mode):
return ""

capUse = mod.capUse
capUse = stuff.capUse
if capUse:
return "%s%s" % ("+" if capUse < 0 else "", (formatAmount(-capUse, 3, 0, 3)))
else:
@@ -41,7 +41,7 @@ def __init__(self, fittingView, params):
self.maxsize = self.size
self.mask = wx.LIST_MASK_IMAGE

def getColumnText(self, mod):
def getColumnText(self, stuff):
return ""

def getToolTip(self, mod):
@@ -297,7 +297,6 @@ def fitRemoved(self, event):
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.activeFitID))
except wx._core.PyDeadObjectError:
pyfalog.error("Caught dead object on fit removed")
pass

event.Skip()

@@ -28,7 +28,7 @@ def register(cls):
def __init__(self):
self.name = ""

def getFields(self):
def getGraphFields(self):
raise NotImplementedError()

def getIcons(self):
@@ -195,7 +195,7 @@ def select(self, index):
self.fields.clear()

# Setup textboxes
for field, defaultVal in view.getFields().iteritems():
for field, defaultVal in view.getGraphFields().iteritems():

textBox = wx.TextCtrl(self.gridPanel, wx.ID_ANY, style=0)
self.fields[field] = textBox
@@ -882,7 +882,6 @@ def PopulateList(self):
if effects[name].effectType:
for effectType in effects[name].effectType:
effectTypeText += effectType + " "
pass

if effects[name].runTime and effects[name].isImplemented:
effectRunTime = str(effects[name].runTime)
@@ -448,37 +448,37 @@ def contextMenu(self, event):
menu = ContextMenu.getMenu((item,), (sourceContext, itemContext))
self.PopupMenu(menu)

def populate(self, items):
if len(items) > 0:
def populate(self, stuff):
if len(stuff) > 0:
# Get dictionary with meta level attribute
sAttr = Attribute.getInstance()
attrs = sAttr.getAttributeInfo("metaLevel")
sMkt = self.sMkt
self.metalvls = sMkt.directAttrRequest(items, attrs)
self.metalvls = sMkt.directAttrRequest(stuff, attrs)
# Clear selection
self.deselectItems()
# Perform sorting, using item's meta levels besides other stuff
items.sort(key=self.itemSort)
stuff.sort(key=self.itemSort)
# Mark current item list as active
self.active = items
self.active = stuff
# Show them
Display.populate(self, items)
Display.populate(self, stuff)

def refresh(self, items):
if len(items) > 1:
def refresh(self, stuff):
if len(stuff) > 1:
# Get dictionary with meta level attribute
sAttr = Attribute.getInstance()
attrs = sAttr.getAttributeInfo("metaLevel")
sMkt = self.sMkt
self.metalvls = sMkt.directAttrRequest(items, attrs)
self.metalvls = sMkt.directAttrRequest(stuff, attrs)
# Re-sort stuff
items.sort(key=self.itemSort)
stuff.sort(key=self.itemSort)

for i, item in enumerate(items[:9]):
for i, item in enumerate(stuff[:9]):
# set shortcut info for first 9 modules
item.marketShortcut = i + 1

Display.refresh(self, items)
Display.refresh(self, stuff)

def makeReverseMetaMap(self):
"""
@@ -263,7 +263,7 @@ def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=(0, 16), s
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
self.Bind(wx.EVT_MOTION, self.OnMotion)

def Refresh(self, **kwargs):
def Refresh(self):
self.RenderBackground()
wx.Window.Refresh(self)

@@ -68,7 +68,6 @@ def run(self):
FILE.close()
except IOError:
pyfalog.error("Failed to write to {0}", settings.getPath())
pass

if self.callback:
wx.CallAfter(self.callback, -1)
@@ -46,7 +46,7 @@ def register(cls):
def getColumn(cls, name):
return ViewColumn.columns[name]

def getColumnText(self, mod):
def getColumnText(self, stuff):
return ""

def getToolTip(self, mod):
@@ -380,7 +380,7 @@ def apiFetchCallback(guiCallback, e=None):
wx.CallAfter(guiCallback, e)

@staticmethod
def apiUpdateCharSheet(charID, skills, securitystatus):
def apiUpdateCharSheet(charID, skills, securitystatus=0):
char = eos.db.getCharacter(charID)
char.apiUpdateCharSheet(skills, securitystatus)
eos.db.commit()
@@ -991,11 +991,11 @@ def _bind(self):
def copy(self):
return FilterRowset(self._cols[:], None, self.key, self.key2, dict_=copy.deepcopy(self._items))

def get(self, key, default=_unspecified):
def get(self, key, default=None):
try:
return self[key]
except KeyError:
if default is _unspecified:
if default is None:
raise
return default

@@ -142,7 +142,6 @@ def fetchPrices(cls, prices):
except:
# all other errors will pass and continue onward to the REREQUEST delay
pyfalog.warning("Caught exception in fetchPrices")
pass

# if we get to this point, then we've got an error. Set to REREQUEST delay
for typeID in priceMap.keys():
@@ -129,7 +129,6 @@ def get_request(self):
return sock, addr
except socket.timeout:
pyfalog.warning("Server timed out waiting for connection")
pass

def stop(self):
pyfalog.warning("Setting CREST server to stop.")
@@ -88,7 +88,6 @@ def run(self):
except Exception as e:
pyfalog.error("Caught exception in run")
pyfalog.error(e)
pass

@staticmethod
def versiontuple(v):
@@ -34,4 +34,3 @@ def __enter__(self):

def __exit__(self, exit_type, value, traceback):
self.checkpoint('finished')
pass

0 comments on commit 0894e60

Please sign in to comment.
You can’t perform that action at this time.