Add ability to import modules from ESI directly into pyfa
This commit is contained in:
@@ -18,9 +18,12 @@
|
||||
# =============================================================================
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from eos.db.gamedata.queries import getAttributeInfo, getDynamicItem
|
||||
from eos.utils.float import floatUnerr
|
||||
from service.port.shared import fetchItem
|
||||
from service.esiAccess import EsiAccess
|
||||
|
||||
|
||||
def renderMutant(mutant, firstPrefix='', prefix=''):
|
||||
@@ -77,3 +80,23 @@ def parseMutant(lines):
|
||||
continue
|
||||
mutations[attrInfo.ID] = value
|
||||
return baseItem, mutaplasmidItem, mutations
|
||||
|
||||
|
||||
def parseDynamicItemString(text):
|
||||
m = re.search(r'<url=showinfo:(?P<typeid>\d+)//(?P<itemid>\d+)>.+</url>', text)
|
||||
if m:
|
||||
typeID = int(m.group('typeid'))
|
||||
itemID = int(m.group('itemid'))
|
||||
return typeID, itemID
|
||||
return None
|
||||
|
||||
|
||||
def fetchDynamicItem(dynamicItemData):
|
||||
typeID, itemID = dynamicItemData
|
||||
esiData = EsiAccess().getDynamicItem(typeID, itemID).json()
|
||||
baseItemID = esiData['source_type_id']
|
||||
mutaplasmidID = esiData['mutator_type_id']
|
||||
attrs = {i['attribute_id']: i['value'] for i in esiData['dogma_attributes']}
|
||||
baseItem = fetchItem(baseItemID)
|
||||
mutaplasmid = getDynamicItem(mutaplasmidID)
|
||||
return baseItem, mutaplasmid, attrs
|
||||
|
||||
@@ -41,7 +41,7 @@ from service.port.multibuy import exportMultiBuy
|
||||
from service.port.shared import IPortUser, UserCancelException, processing_notify
|
||||
from service.port.shipstats import exportFitStats
|
||||
from service.port.xml import importXml, exportXml
|
||||
from service.port.muta import parseMutant
|
||||
from service.port.muta import parseMutant, parseDynamicItemString, fetchDynamicItem
|
||||
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
@@ -255,6 +255,15 @@ class Port:
|
||||
return "DNA", True, (cls.importDnaAlt(m.group("dna")),)
|
||||
|
||||
if activeFit is not None:
|
||||
|
||||
# Try to import mutated item from network
|
||||
dynData = parseDynamicItemString(string)
|
||||
if dynData is not None:
|
||||
itemData = fetchDynamicItem(dynData)
|
||||
if itemData is not None:
|
||||
baseItem, mutaplasmidItem, mutations = itemData
|
||||
return "FittingItem", False, ((baseItem, mutaplasmidItem, mutations),)
|
||||
|
||||
# Try to import mutated module
|
||||
try:
|
||||
baseItem, mutaplasmidItem, mutations = parseMutant(lines)
|
||||
|
||||
Reference in New Issue
Block a user