Merge branch 'master' into efs_port

This commit is contained in:
MaruMaruOO
2018-09-27 02:52:49 -04:00
55 changed files with 372 additions and 253 deletions

View File

@@ -187,11 +187,11 @@ class Fit(object):
# error during the command loop
refreshFits = set()
for projection in list(fit.projectedOnto.values()):
if projection.victim_fit != fit and projection.victim_fit in eos.db.saveddata_session: # GH issue #359
if projection.victim_fit and projection.victim_fit != fit and projection.victim_fit in eos.db.saveddata_session: # GH issue #359
refreshFits.add(projection.victim_fit)
for booster in list(fit.boostedOnto.values()):
if booster.boosted_fit != fit and booster.boosted_fit in eos.db.saveddata_session: # GH issue #359
if booster.boosted_fit and booster.boosted_fit != fit and booster.boosted_fit in eos.db.saveddata_session: # GH issue #359
refreshFits.add(booster.boosted_fit)
eos.db.remove(fit)
@@ -626,12 +626,11 @@ class Fit(object):
def changeModule(self, fitID, position, newItemID):
fit = eos.db.getFit(fitID)
module = fit.modules[position]
# We're trying to add a charge to a slot, which won't work. Instead, try to add the charge to the module in that slot.
if self.isAmmo(newItemID):
module = fit.modules[position]
if not module.isEmpty:
self.setAmmo(fitID, newItemID, [module])
if self.isAmmo(newItemID) and not module.isEmpty:
self.setAmmo(fitID, newItemID, [module])
return True
pyfalog.debug("Changing position of module from position ({0}) for fit ID: {1}", position, fitID)
@@ -640,14 +639,17 @@ class Fit(object):
# Dummy it out in case the next bit fails
fit.modules.toDummy(position)
ret = None
try:
m = es_Module(item)
except ValueError:
pyfalog.warning("Invalid item: {0}", newItemID)
return False
if m.fits(fit):
if m.slot != module.slot:
fit.modules.toModule(position, module)
# Fits, but we selected wrong slot type, so don't want to overwrite because we will append on failure (none)
ret = None
elif m.fits(fit):
m.owner = fit
fit.modules.toModule(position, m)
if m.isValidState(State.ACTIVE):
@@ -661,9 +663,8 @@ class Fit(object):
fit.fill()
eos.db.commit()
return True
else:
return None
ret = True
return ret
def moveCargoToModule(self, fitID, moduleIdx, cargoIdx, copyMod=False):
"""

View File

@@ -277,15 +277,8 @@ class Market(object):
# Dictionary of items with forced market group (service assumes they have no
# market group assigned in db, otherwise they'll appear in both original and forced groups)
self.ITEMS_FORCEDMARKETGROUP = {
"Advanced Cerebral Accelerator" : 977, # Implants & Boosters > Booster
"Civilian Damage Control" : 615, # Ship Equipment > Hull & Armor > Damage Controls
"Civilian EM Ward Field" : 1695,
# Ship Equipment > Shield > Shield Hardeners > EM Shield Hardeners
"Civilian Explosive Deflection Field" : 1694,
# Ship Equipment > Shield > Shield Hardeners > Explosive Shield Hardeners
"Advanced Cerebral Accelerator" : 2487, # Implants & Boosters > Booster > Cerebral Accelerators
"Civilian Hobgoblin" : 837, # Drones > Combat Drones > Light Scout Drones
"Civilian Kinetic Deflection Field" : 1693,
# Ship Equipment > Shield > Shield Hardeners > Kinetic Shield Hardeners
"Civilian Light Missile Launcher" : 640,
# Ship Equipment > Turrets & Bays > Missile Launchers > Light Missile Launchers
"Civilian Scourge Light Missile" : 920,
@@ -293,8 +286,6 @@ class Market(object):
"Civilian Small Remote Armor Repairer" : 1059,
# Ship Equipment > Hull & Armor > Remote Armor Repairers > Small
"Civilian Small Remote Shield Booster" : 603, # Ship Equipment > Shield > Remote Shield Boosters > Small
"Civilian Stasis Webifier" : 683, # Ship Equipment > Electronic Warfare > Stasis Webifiers
"Civilian Warp Disruptor" : 1935, # Ship Equipment > Electronic Warfare > Warp Disruptors
"Hardwiring - Zainou 'Sharpshooter' ZMX10" : 1493,
# Implants & Boosters > Implants > Skill Hardwiring > Missile Implants > Implant Slot 06
"Hardwiring - Zainou 'Sharpshooter' ZMX100" : 1493,
@@ -307,11 +298,9 @@ class Market(object):
# Implants & Boosters > Implants > Skill Hardwiring > Missile Implants > Implant Slot 06
"Hardwiring - Zainou 'Sharpshooter' ZMX1100": 1493,
# Implants & Boosters > Implants > Skill Hardwiring > Missile Implants > Implant Slot 06
"Nugoehuvi Synth Blue Pill Booster" : 977, # Implants & Boosters > Booster
"Prototype Cerebral Accelerator" : 977, # Implants & Boosters > Booster
"Prototype Cerebral Accelerator" : 2487, # Implants & Boosters > Booster > Cerebral Accelerators
"Prototype Iris Probe Launcher" : 712, # Ship Equipment > Turrets & Bays > Scan Probe Launchers
"Shadow" : 1310, # Drones > Combat Drones > Fighter Bombers
"Standard Cerebral Accelerator" : 977, # Implants & Boosters > Booster
"Standard Cerebral Accelerator" : 2487, # Implants & Boosters > Booster > Cerebral Accelerators
}
self.ITEMS_FORCEDMARKETGROUP_R = self.__makeRevDict(self.ITEMS_FORCEDMARKETGROUP)
@@ -538,7 +527,7 @@ class Market(object):
categories = ['Drone', 'Fighter', 'Implant']
for item in items:
if item.category.ID == 20: # Implants and Boosters
if item.category.ID == 20 and item.group.ID != 303: # Implants not Boosters
implant_remove_list = set()
implant_remove_list.add("Low-Grade ")
implant_remove_list.add("Low-grade ")
@@ -552,15 +541,6 @@ class Market(object):
implant_remove_list.add(" - Elite")
implant_remove_list.add(" - Improved")
implant_remove_list.add(" - Standard")
implant_remove_list.add("Copper ")
implant_remove_list.add("Gold ")
implant_remove_list.add("Silver ")
implant_remove_list.add("Advanced ")
implant_remove_list.add("Improved ")
implant_remove_list.add("Prototype ")
implant_remove_list.add("Standard ")
implant_remove_list.add("Strong ")
implant_remove_list.add("Synth ")
for implant_prefix in ("-6", "-7", "-8", "-9", "-10"):
for i in range(50):
@@ -596,6 +576,16 @@ class Market(object):
if trimmed_variations_list:
variations_list = trimmed_variations_list
# If the items are boosters then filter variations to only include boosters for the same slot.
BOOSTER_GROUP_ID = 303
if all(map(lambda i: i.group.ID == BOOSTER_GROUP_ID, items)) and len(items) > 0:
# 'boosterness' is the database's attribute name for Booster Slot
reqSlot = next(items.__iter__()).getAttribute('boosterness')
# If the item and it's variation both have a marketGroupID it should match for the variation to be considered valid.
marketGroupID = [next(filter(None, map(lambda i: i.marketGroupID, items)), None), None]
matchSlotAndMktGrpID = lambda v: v.getAttribute('boosterness') == reqSlot and v.marketGroupID in marketGroupID
variations_list = list(filter(matchSlotAndMktGrpID, variations_list))
variations.update(variations_list)
return variations
@@ -657,6 +647,12 @@ class Market(object):
def marketGroupHasTypesCheck(self, mg):
"""If market group has any items, return true"""
if mg and mg.ID in self.ITEMS_FORCEDMARKETGROUP_R:
# This shouldn't occur normally but makes errors more mild when ITEMS_FORCEDMARKETGROUP is outdated.
if len(mg.children) > 0 and len(mg.items) == 0:
pyfalog.error(("Market group \"{0}\" contains no items and has children. "
"ITEMS_FORCEDMARKETGROUP is likely outdated and will need to be "
"updated for {1} to display correctly.").format(mg, self.ITEMS_FORCEDMARKETGROUP_R[mg.ID]))
return False
return True
elif len(mg.items) > 0:
return True

View File

@@ -24,7 +24,6 @@ from logbook import Logger
import collections
import json
import threading
import locale
from bs4 import UnicodeDammit
@@ -33,6 +32,7 @@ from codecs import open
import xml.parsers.expat
from eos import db
from eos.db.gamedata.queries import getAttributeInfo
from service.fit import Fit as svcFit
# noinspection PyPackageRequirements
@@ -1064,85 +1064,104 @@ class Port(object):
return fit_list
@staticmethod
def _exportEftBase(fit):
"""Basically EFT format does not require blank lines
also, it's OK to arrange modules randomly?
"""
offineSuffix = " /OFFLINE"
export = "[%s, %s]\n" % (fit.ship.item.name, fit.name)
stuff = {}
@classmethod
def exportEft(cls, fit, mutations=False, implants=False):
# EFT formatted export is split in several sections, each section is
# separated from another using 2 blank lines. Sections might have several
# sub-sections, which are separated by 1 blank line
sections = []
header = '[{}, {}]'.format(fit.ship.item.name, fit.name)
# Section 1: modules, rigs, subsystems, services
def formatAttrVal(val):
if int(val) == val:
return int(val)
return val
offineSuffix = ' /OFFLINE'
modsBySlotType = {}
sFit = svcFit.getInstance()
for module in fit.modules:
slot = module.slot
if slot not in stuff:
stuff[slot] = []
curr = module.item.name if module.item \
else ("[Empty %s slot]" % Slot.getName(slot).capitalize() if slot is not None else "")
if module.charge and sFit.serviceFittingOptions["exportCharges"]:
curr += ", %s" % module.charge.name
if module.state == State.OFFLINE:
curr += offineSuffix
curr += "\n"
stuff[slot].append(curr)
slotTypeMods = modsBySlotType.setdefault(slot, [])
if module.item:
mutatedMod = bool(module.mutators)
# if module was mutated, use base item name for export
if mutatedMod:
modName = module.baseItem.name
else:
modName = module.item.name
modOfflineSuffix = offineSuffix if module.state == State.OFFLINE else ''
if module.charge and sFit.serviceFittingOptions['exportCharges']:
slotTypeMods.append('{}, {}{}'.format(modName, module.charge.name, modOfflineSuffix))
else:
slotTypeMods.append('{}{}'.format(modName, modOfflineSuffix))
if mutatedMod and mutations:
mutationGrade = module.mutaplasmid.item.name.split(' ', 1)[0].lower()
mutatedAttrs = {}
for attrID, mutator in module.mutators.items():
attrName = getAttributeInfo(attrID).name
mutatedAttrs[attrName] = mutator.value
customAttrsLine = ', '.join('{} {}'.format(a, formatAttrVal(mutatedAttrs[a])) for a in sorted(mutatedAttrs))
slotTypeMods.append(' {}: {}'.format(mutationGrade, customAttrsLine))
else:
slotTypeMods.append('[Empty {} slot]'.format(Slot.getName(slot).capitalize() if slot is not None else ''))
modSection = []
for slotType in EFT_SLOT_ORDER:
data = stuff.get(slotType)
if data is not None:
export += "\n"
for curr in data:
export += curr
rackLines = []
data = modsBySlotType.get(slotType, ())
for line in data:
rackLines.append(line)
if rackLines:
modSection.append('\n'.join(rackLines))
if modSection:
sections.append('\n\n'.join(modSection))
if len(fit.drones) > 0:
export += "\n\n"
for drone in fit.drones:
export += "%s x%s\n" % (drone.item.name, drone.amount)
# Section 2: drones, fighters
minionSection = []
droneLines = []
for drone in sorted(fit.drones, key=lambda d: d.item.name):
droneLines.append('{} x{}'.format(drone.item.name, drone.amount))
if droneLines:
minionSection.append('\n'.join(droneLines))
fighterLines = []
for fighter in sorted(fit.fighters, key=lambda f: f.item.name):
fighterLines.append('{} x{}'.format(fighter.item.name, fighter.amountActive))
if fighterLines:
minionSection.append('\n'.join(fighterLines))
if minionSection:
sections.append('\n\n'.join(minionSection))
if len(fit.fighters) > 0:
export += "\n\n"
for fighter in fit.fighters:
export += "%s x%s\n" % (fighter.item.name, fighter.amountActive)
# Section 3: implants, boosters
if implants:
charSection = []
implantLines = []
for implant in fit.implants:
implantLines.append(implant.item.name)
if implantLines:
charSection.append('\n'.join(implantLines))
boosterLines = []
for booster in fit.boosters:
boosterLines.append(booster.item.name)
if boosterLines:
charSection.append('\n'.join(boosterLines))
if charSection:
sections.append('\n\n'.join(charSection))
if export[-1] == "\n":
export = export[:-1]
# Section 4: cargo
cargoLines = []
for cargo in sorted(fit.cargo, key=lambda c: (c.item.group.category.name, c.item.group.name, c.item.name)):
cargoLines.append('{} x{}'.format(cargo.item.name, cargo.amount))
if cargoLines:
sections.append('\n'.join(cargoLines))
return export
@classmethod
def exportEft(cls, fit):
export = cls._exportEftBase(fit)
if len(fit.cargo) > 0:
export += "\n\n\n"
for cargo in fit.cargo:
export += "%s x%s\n" % (cargo.item.name, cargo.amount)
if export[-1] == "\n":
export = export[:-1]
return export
return '{}\n\n{}'.format(header, '\n\n\n'.join(sections))
@classmethod
def exportEftImps(cls, fit):
export = cls._exportEftBase(fit)
if len(fit.implants) > 0 or len(fit.boosters) > 0:
export += "\n\n\n"
for implant in fit.implants:
export += "%s\n" % implant.item.name
for booster in fit.boosters:
export += "%s\n" % booster.item.name
if export[-1] == "\n":
export = export[:-1]
if len(fit.cargo) > 0:
export += "\n\n\n"
for cargo in fit.cargo:
export += "%s x%s\n" % (cargo.item.name, cargo.amount)
if export[-1] == "\n":
export = export[:-1]
return export
return cls.exportEft(fit, implants=True)
@staticmethod
def exportDna(fit):

View File

@@ -228,10 +228,11 @@ class PriceWorkerThread(threading.Thread):
def trigger(self, prices, callbacks):
self.queue.put((callbacks, prices))
def setToWait(self, itemID, callback):
if itemID not in self.wait:
self.wait[itemID] = []
self.wait[itemID].append(callback)
def setToWait(self, prices, callback):
for x in prices:
if x.typeID not in self.wait:
self.wait[x.typeID] = []
self.wait[x.typeID].append(callback)
from service.marketSources import evemarketer, evemarketdata # noqa: E402

View File

@@ -248,6 +248,11 @@ class NetworkSettings(object):
proto = "{0}://".format(prefix)
if proxyline[:len(proto)] == proto:
proxyline = proxyline[len(proto):]
# sometimes proxyline contains "user:password@" section before proxy address
# remove it if present, so later split by ":" works
if '@' in proxyline:
userPass, proxyline = proxyline.split("@")
# TODO: do something with user/password?
proxAddr, proxPort = proxyline.split(":")
proxPort = int(proxPort.rstrip("/"))
proxy = (proxAddr, proxPort)