Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFenX committed Feb 20, 2024
2 parents b959d9d + 2c2455a commit e0a7175
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 19 deletions.
2 changes: 1 addition & 1 deletion eos/db/migrations/upgrade1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
loaded as they no longer exist in the database. We therefore replace these
modules with their new replacements
Based on http://community.eveonline.com/news/patch-notes/patch-notes-for-oceanus/
Based on https://www.eveonline.com/news/view/patch-notes-for-oceanus
and output of itemDiff.py
"""

Expand Down
6 changes: 3 additions & 3 deletions eos/db/migrations/upgrade25.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Migration 25
- Converts T3C fitting configurations based on the spreadsheet noted here:
https://community.eveonline.com/news/patch-notes/patch-notes-for-july-2017-release
https://www.eveonline.com/news/view/patch-notes-for-july-2017-release
(csv copies can be found on the pyfa repo in case the official documents are deleted)
Expand Down Expand Up @@ -4228,8 +4228,8 @@ def upgrade(saveddata_engine):
# We don't have a conversion for this. I don't think this will ever happen, but who knows
continue

# It doesn't actully matter which old module is replaced with which new module, so we don't have to worry
# about module position or anything like that. Just doe a straight up record UPDATE
# It doesn't actually matter which old module is replaced with which new module, so we don't have to worry
# about module position or anything like that. Just do a straight up record UPDATE
for i, old in enumerate(oldModules[:4]):
saveddata_engine.execute("UPDATE modules SET itemID = ? WHERE ID = ?", (newModules[i], old[0]))

Expand Down
2 changes: 1 addition & 1 deletion eos/db/migrations/upgrade4.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from database), which causes pyfa to crash. We therefore replace these
modules with their new replacements
Based on http://community.eveonline.com/news/patch-notes/patch-notes-for-proteus/
Based on https://www.eveonline.com/news/view/patch-notes-for-proteus
and output of itemDiff.py
"""

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matplotlib==3.8.2
python-dateutil==2.8.2
requests==2.31.0
sqlalchemy==1.4.50
cryptography==41.0.7
cryptography==42.0.2
markdown2==2.4.11
packaging==23.2
roman==4.1
Expand Down
22 changes: 15 additions & 7 deletions service/port/muta.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@

def renderMutant(mutant, firstPrefix='', prefix=''):
exportLines = []
exportLines.append('{}{}'.format(firstPrefix, mutant.baseItem.name))
exportLines.append('{}{}'.format(prefix, mutant.mutaplasmid.item.name))
exportLines.append('{}{}'.format(prefix, renderMutantAttrs(mutant)))
return '\n'.join(exportLines)


def renderMutantAttrs(mutant):
mutatedAttrs = {}
for attrID, mutator in mutant.mutators.items():
attrName = getAttributeInfo(attrID).name
mutatedAttrs[attrName] = mutator.value
exportLines.append('{}{}'.format(firstPrefix, mutant.baseItem.name))
exportLines.append('{}{}'.format(prefix, mutant.mutaplasmid.item.name))
customAttrsLine = ', '.join(
return ', '.join(
'{} {}'.format(a, floatUnerr(mutatedAttrs[a]))
for a in sorted(mutatedAttrs))
exportLines.append('{}{}'.format(prefix, customAttrsLine))
return '\n'.join(exportLines)


def parseMutant(lines):
Expand All @@ -64,8 +67,13 @@ def parseMutant(lines):
mutationsLine = lines[2]
except IndexError:
return baseItem, mutaplasmidItem, {}
mutations = parseMutantAttrs(mutationsLine)
return baseItem, mutaplasmidItem, mutations


def parseMutantAttrs(line):
mutations = {}
pairs = [p.strip() for p in mutationsLine.split(',')]
pairs = [p.strip() for p in line.split(',')]
for pair in pairs:
try:
attrName, value = pair.split(' ')
Expand All @@ -79,7 +87,7 @@ def parseMutant(lines):
if attrInfo is None:
continue
mutations[attrInfo.ID] = value
return baseItem, mutaplasmidItem, mutations
return mutations


def parseDynamicItemString(text):
Expand Down
58 changes: 52 additions & 6 deletions service/port/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from logbook import Logger

from eos.const import FittingModuleState, FittingSlot
from eos.db import getDynamicItem
from eos.saveddata.cargo import Cargo
from eos.saveddata.citadel import Citadel
from eos.saveddata.drone import Drone
Expand All @@ -34,7 +35,8 @@
from gui.fitCommands.helpers import activeStateLimit
from service.fit import Fit as svcFit
from service.market import Market
from service.port.shared import IPortUser, processing_notify
from service.port.muta import renderMutantAttrs, parseMutantAttrs
from service.port.shared import IPortUser, processing_notify, fetchItem
from utils.strfunctions import replace_ltgt, sequential_rep


Expand Down Expand Up @@ -115,7 +117,7 @@ def _resolve_ship(fitting, sMkt, b_localized):

def _resolve_module(hardware, sMkt, b_localized):
# type: (xml.dom.minidom.Element, service.market.Market, bool) -> eos.saveddata.module.Module
moduleName = hardware.getAttribute("type")
moduleName = hardware.getAttribute("base_type") or hardware.getAttribute("type")
emergency = None
if b_localized:
try:
Expand All @@ -142,7 +144,14 @@ def _resolve_module(hardware, sMkt, b_localized):
must_retry = True
if not must_retry:
break
return item

mutaplasmidName = hardware.getAttribute("mutaplasmid")
mutaplasmidItem = fetchItem(mutaplasmidName) if mutaplasmidName else None

mutatedAttrsText = hardware.getAttribute("mutated_attrs")
mutatedAttrs = parseMutantAttrs(mutatedAttrsText) if mutatedAttrsText else None

return item, mutaplasmidItem, mutatedAttrs


def importXml(text, iportuser):
Expand Down Expand Up @@ -185,12 +194,25 @@ def importXml(text, iportuser):
moduleList = []
for hardware in hardwares:
try:
item = _resolve_module(hardware, sMkt, b_localized)
item, mutaItem, mutaAttrs = _resolve_module(hardware, sMkt, b_localized)
if not item or not item.published:
continue

if item.category.name == "Drone":
d = Drone(item)
d = None
if mutaItem:
mutaplasmid = getDynamicItem(mutaItem.ID)
if mutaplasmid:
try:
d = Drone(mutaplasmid.resultingItem, item, mutaplasmid)
except ValueError:
pass
else:
for attrID, mutator in d.mutators.items():
if attrID in mutaAttrs:
mutator.value = mutaAttrs[attrID]
if d is None:
d = Drone(item)
d.amount = int(hardware.getAttribute("qty"))
fitobj.drones.append(d)
elif item.category.name == "Fighter":
Expand All @@ -205,8 +227,21 @@ def importXml(text, iportuser):
c.amount = int(hardware.getAttribute("qty"))
fitobj.cargo.append(c)
else:
m = None
try:
m = Module(item)
if mutaItem:
mutaplasmid = getDynamicItem(mutaItem.ID)
if mutaplasmid:
try:
m = Module(mutaplasmid.resultingItem, item, mutaplasmid)
except ValueError:
pass
else:
for attrID, mutator in m.mutators.items():
if attrID in mutaAttrs:
mutator.value = mutaAttrs[attrID]
if m is None:
m = Module(item)
# When item can't be added to any slot (unknown item or just charge), ignore it
except ValueError:
pyfalog.warning("item can't be added to any slot (unknown item or just charge), ignore it")
Expand Down Expand Up @@ -254,6 +289,11 @@ def exportXml(fits, iportuser, callback):
fittings.setAttribute("count", "%s" % fit_count)
doc.appendChild(fittings)

def addMutantAttributes(node, mutant):
node.setAttribute("base_type", mutant.baseItem.name)
node.setAttribute("mutaplasmid", mutant.mutaplasmid.item.name)
node.setAttribute("mutated_attrs", renderMutantAttrs(mutant))

for i, fit in enumerate(fits):
try:
fitting = doc.createElement("fitting")
Expand Down Expand Up @@ -303,6 +343,9 @@ def exportXml(fits, iportuser, callback):
slotName = FittingSlot(slot).name.lower()
slotName = slotName if slotName != "high" else "hi"
hardware.setAttribute("slot", "%s slot %d" % (slotName, slotId))
if module.isMutated:
addMutantAttributes(hardware, module)

fitting.appendChild(hardware)

if module.charge:
Expand All @@ -316,6 +359,9 @@ def exportXml(fits, iportuser, callback):
hardware.setAttribute("qty", "%d" % drone.amount)
hardware.setAttribute("slot", "drone bay")
hardware.setAttribute("type", drone.item.name)
if drone.isMutated:
addMutantAttributes(hardware, drone)

fitting.appendChild(hardware)

for fighter in fit.fighters:
Expand Down

0 comments on commit e0a7175

Please sign in to comment.