Merge branch 'master' into fit_export_options
This commit is contained in:
@@ -239,7 +239,7 @@ class Item(EqBase):
|
|||||||
self.__offensive = None
|
self.__offensive = None
|
||||||
self.__assistive = None
|
self.__assistive = None
|
||||||
self.__overrides = None
|
self.__overrides = None
|
||||||
self.__price = None
|
self.__priceObj = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def attributes(self):
|
def attributes(self):
|
||||||
@@ -446,37 +446,47 @@ class Item(EqBase):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def price(self):
|
def price(self):
|
||||||
|
priceObj = self.priceObj
|
||||||
|
if not priceObj:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
return priceObj.price
|
||||||
|
|
||||||
|
@property
|
||||||
|
def priceObj(self):
|
||||||
|
if not self.marketGroupID:
|
||||||
|
return None
|
||||||
|
|
||||||
# todo: use `from sqlalchemy import inspect` instead (mac-deprecated doesn't have inspect(), was imp[lemented in 0.8)
|
# todo: use `from sqlalchemy import inspect` instead (mac-deprecated doesn't have inspect(), was imp[lemented in 0.8)
|
||||||
if self.__price is not None and getattr(self.__price, '_sa_instance_state', None) and self.__price._sa_instance_state.deleted:
|
if self.__priceObj is not None and getattr(self.__priceObj, '_sa_instance_state', None) and self.__priceObj._sa_instance_state.deleted:
|
||||||
pyfalog.debug("Price data for {} was deleted (probably from a cache reset), resetting object".format(self.ID))
|
pyfalog.debug("Price data for {} was deleted (probably from a cache reset), resetting object".format(self.ID))
|
||||||
self.__price = None
|
self.__priceObj = None
|
||||||
|
|
||||||
if self.__price is None:
|
if self.__priceObj is None:
|
||||||
db_price = eos.db.getPrice(self.ID)
|
db_price = eos.db.getPrice(self.ID)
|
||||||
# do not yet have a price in the database for this item, create one
|
# do not yet have a price in the database for this item, create one
|
||||||
if db_price is None:
|
if db_price is None:
|
||||||
pyfalog.debug("Creating a price for {}".format(self.ID))
|
pyfalog.debug("Creating a price for {}".format(self.ID))
|
||||||
self.__price = types_Price(self.ID)
|
self.__priceObj = types_Price(self.ID)
|
||||||
eos.db.add(self.__price)
|
eos.db.add(self.__priceObj)
|
||||||
# Commented out by DarkPhoenix: it caused issues when opening stats for item with many
|
# Commented out by DarkPhoenix: it caused issues when opening stats for item with many
|
||||||
# variations, as each commit takes ~50 ms, for items with 30 variations time to open stats
|
# variations, as each commit takes ~50 ms, for items with 30 variations time to open stats
|
||||||
# window could reach 2 seconds. Hopefully just adding it is sufficient.
|
# window could reach 2 seconds. Hopefully just adding it is sufficient.
|
||||||
# eos.db.commit()
|
# eos.db.commit()
|
||||||
else:
|
else:
|
||||||
self.__price = db_price
|
self.__priceObj = db_price
|
||||||
|
|
||||||
return self.__price
|
return self.__priceObj
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def isAbyssal(self):
|
def isAbyssal(self):
|
||||||
if Item.ABYSSAL_TYPES is None:
|
if Item.ABYSSAL_TYPES is None:
|
||||||
Item.getAbyssalYypes()
|
Item.getAbyssalTypes()
|
||||||
|
|
||||||
return self.ID in Item.ABYSSAL_TYPES
|
return self.ID in Item.ABYSSAL_TYPES
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getAbyssalYypes(cls):
|
def getAbyssalTypes(cls):
|
||||||
cls.ABYSSAL_TYPES = eos.db.getAbyssalTypes()
|
cls.ABYSSAL_TYPES = eos.db.getAbyssalTypes()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class ItemCompare(wx.Panel):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
# Price
|
# Price
|
||||||
if sort == len(self.attrs) + 1:
|
if sort == len(self.attrs) + 1:
|
||||||
func = lambda i: i.price.price if i.price.price != 0 else float("Inf")
|
func = lambda i: i.price if i.price != 0 else float("Inf")
|
||||||
# Something else
|
# Something else
|
||||||
else:
|
else:
|
||||||
self.sortReverse = False
|
self.sortReverse = False
|
||||||
@@ -168,7 +168,7 @@ class ItemCompare(wx.Panel):
|
|||||||
self.paramList.SetItem(i, x + 1, valueUnit)
|
self.paramList.SetItem(i, x + 1, valueUnit)
|
||||||
|
|
||||||
# Add prices
|
# Add prices
|
||||||
self.paramList.SetItem(i, len(self.attrs) + 1, formatAmount(item.price.price, 3, 3, 9, currency=True))
|
self.paramList.SetItem(i, len(self.attrs) + 1, formatAmount(item.price, 3, 3, 9, currency=True) if item.price else "")
|
||||||
|
|
||||||
self.paramList.RefreshRows()
|
self.paramList.RefreshRows()
|
||||||
self.Layout()
|
self.Layout()
|
||||||
|
|||||||
@@ -100,32 +100,32 @@ class PriceViewFull(StatsView):
|
|||||||
implant_price = 0
|
implant_price = 0
|
||||||
|
|
||||||
if fit:
|
if fit:
|
||||||
ship_price = fit.ship.item.price.price
|
ship_price = fit.ship.item.price
|
||||||
|
|
||||||
if fit.modules:
|
if fit.modules:
|
||||||
for module in fit.modules:
|
for module in fit.modules:
|
||||||
if not module.isEmpty:
|
if not module.isEmpty:
|
||||||
module_price += module.item.price.price
|
module_price += module.item.price
|
||||||
|
|
||||||
if fit.drones:
|
if fit.drones:
|
||||||
for drone in fit.drones:
|
for drone in fit.drones:
|
||||||
drone_price += drone.item.price.price * drone.amount
|
drone_price += drone.item.price * drone.amount
|
||||||
|
|
||||||
if fit.fighters:
|
if fit.fighters:
|
||||||
for fighter in fit.fighters:
|
for fighter in fit.fighters:
|
||||||
fighter_price += fighter.item.price.price * fighter.amountActive
|
fighter_price += fighter.item.price * fighter.amountActive
|
||||||
|
|
||||||
if fit.cargo:
|
if fit.cargo:
|
||||||
for cargo in fit.cargo:
|
for cargo in fit.cargo:
|
||||||
cargo_price += cargo.item.price.price * cargo.amount
|
cargo_price += cargo.item.price * cargo.amount
|
||||||
|
|
||||||
if fit.boosters:
|
if fit.boosters:
|
||||||
for booster in fit.boosters:
|
for booster in fit.boosters:
|
||||||
booster_price += booster.item.price.price
|
booster_price += booster.item.price
|
||||||
|
|
||||||
if fit.implants:
|
if fit.implants:
|
||||||
for implant in fit.implants:
|
for implant in fit.implants:
|
||||||
implant_price += implant.item.price.price
|
implant_price += implant.item.price
|
||||||
|
|
||||||
total_price = 0
|
total_price = 0
|
||||||
|
|
||||||
|
|||||||
@@ -94,32 +94,32 @@ class PriceViewMinimal(StatsView):
|
|||||||
implant_price = 0
|
implant_price = 0
|
||||||
|
|
||||||
if fit:
|
if fit:
|
||||||
ship_price = fit.ship.item.price.price
|
ship_price = fit.ship.item.price
|
||||||
|
|
||||||
if fit.modules:
|
if fit.modules:
|
||||||
for module in fit.modules:
|
for module in fit.modules:
|
||||||
if not module.isEmpty:
|
if not module.isEmpty:
|
||||||
module_price += module.item.price.price
|
module_price += module.item.price
|
||||||
|
|
||||||
if fit.drones:
|
if fit.drones:
|
||||||
for drone in fit.drones:
|
for drone in fit.drones:
|
||||||
drone_price += drone.item.price.price * drone.amount
|
drone_price += drone.item.price * drone.amount
|
||||||
|
|
||||||
if fit.fighters:
|
if fit.fighters:
|
||||||
for fighter in fit.fighters:
|
for fighter in fit.fighters:
|
||||||
fighter_price += fighter.item.price.price * fighter.amountActive
|
fighter_price += fighter.item.price * fighter.amountActive
|
||||||
|
|
||||||
if fit.cargo:
|
if fit.cargo:
|
||||||
for cargo in fit.cargo:
|
for cargo in fit.cargo:
|
||||||
cargo_price += cargo.item.price.price * cargo.amount
|
cargo_price += cargo.item.price * cargo.amount
|
||||||
|
|
||||||
if fit.boosters:
|
if fit.boosters:
|
||||||
for booster in fit.boosters:
|
for booster in fit.boosters:
|
||||||
booster_price += booster.item.price.price
|
booster_price += booster.item.price
|
||||||
|
|
||||||
if fit.implants:
|
if fit.implants:
|
||||||
for implant in fit.implants:
|
for implant in fit.implants:
|
||||||
implant_price += implant.item.price.price
|
implant_price += implant.item.price
|
||||||
|
|
||||||
fitting_price = module_price
|
fitting_price = module_price
|
||||||
|
|
||||||
|
|||||||
@@ -45,13 +45,19 @@ class Price(ViewColumn):
|
|||||||
if stuff.isEmpty:
|
if stuff.isEmpty:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
price = stuff.item.price
|
priceObj = stuff.item.priceObj
|
||||||
|
|
||||||
if not price or not price.isValid:
|
if not priceObj:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
if not priceObj.isValid:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Fetch actual price as float to not modify its value on Price object
|
# Fetch actual price as float to not modify its value on Price object
|
||||||
price = price.price
|
price = priceObj.price
|
||||||
|
|
||||||
|
if price == 0:
|
||||||
|
return ""
|
||||||
|
|
||||||
if isinstance(stuff, Drone) or isinstance(stuff, Cargo):
|
if isinstance(stuff, Drone) or isinstance(stuff, Cargo):
|
||||||
price *= stuff.amount
|
price *= stuff.amount
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ from service.price import Price, VALIDITY
|
|||||||
pyfalog = Logger(__name__)
|
pyfalog = Logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class EveCentral(object):
|
class EveMarketer(object):
|
||||||
|
|
||||||
name = "evemarketer"
|
name = "evemarketer"
|
||||||
|
|
||||||
@@ -67,4 +67,4 @@ class EveCentral(object):
|
|||||||
del priceMap[typeID]
|
del priceMap[typeID]
|
||||||
|
|
||||||
|
|
||||||
Price.register(EveCentral)
|
Price.register(EveMarketer)
|
||||||
|
|||||||
@@ -167,15 +167,16 @@ class Price(object):
|
|||||||
sMkt = Market.getInstance()
|
sMkt = Market.getInstance()
|
||||||
item = sMkt.getItem(objitem)
|
item = sMkt.getItem(objitem)
|
||||||
|
|
||||||
return item.price.price
|
return item.price
|
||||||
|
|
||||||
def getPrices(self, objitems, callback, waitforthread=False):
|
def getPrices(self, objitems, callback, waitforthread=False):
|
||||||
"""Get prices for multiple typeIDs"""
|
"""Get prices for multiple typeIDs"""
|
||||||
requests = []
|
requests = []
|
||||||
sMkt = Market.getInstance()
|
sMkt = Market.getInstance()
|
||||||
for objitem in objitems:
|
for objitem in objitems:
|
||||||
item = sMkt.getItem(objitem)
|
priceobj = sMkt.getItem(objitem).priceObj
|
||||||
requests.append(item.price)
|
if priceobj:
|
||||||
|
requests.append(priceobj)
|
||||||
|
|
||||||
def cb():
|
def cb():
|
||||||
try:
|
try:
|
||||||
@@ -197,6 +198,7 @@ class Price(object):
|
|||||||
|
|
||||||
|
|
||||||
class PriceWorkerThread(threading.Thread):
|
class PriceWorkerThread(threading.Thread):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.name = "PriceWorker"
|
self.name = "PriceWorker"
|
||||||
|
|||||||
Reference in New Issue
Block a user