本文整理汇总了Python中eos.types.Module.isValidCharge方法的典型用法代码示例。如果您正苦于以下问题:Python Module.isValidCharge方法的具体用法?Python Module.isValidCharge怎么用?Python Module.isValidCharge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eos.types.Module
的用法示例。
在下文中一共展示了Module.isValidCharge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: importEft
# 需要导入模块: from eos.types import Module [as 别名]
# 或者: from eos.types.Module import isValidCharge [as 别名]
def importEft(eftString):
sMkt = service.Market.getInstance()
offineSuffix = " /OFFLINE"
fit = Fit()
eftString = eftString.strip()
lines = re.split('[\n\r]+', eftString)
info = lines[0][1:-1].split(",", 1)
if len(info) == 2:
shipType = info[0].strip()
fitName = info[1].strip()
else:
shipType = info[0].strip()
fitName = "Imported %s" % shipType
try:
ship = sMkt.getItem(shipType)
fit.ship = Ship(ship)
fit.name = fitName
except:
return
# maintain map of drones and their quantities
droneMap = {}
cargoMap = {}
moduleList = []
for i in range(1, len(lines)):
ammoName = None
extraAmount = None
line = lines[i].strip()
if not line:
continue
setOffline = line.endswith(offineSuffix)
if setOffline is True:
# remove offline suffix from line
line = line[:len(line) - len(offineSuffix)]
modAmmo = line.split(",")
# matches drone and cargo with x{qty}
modExtra = modAmmo[0].split(" x")
if len(modAmmo) == 2:
# line with a module and ammo
ammoName = modAmmo[1].strip()
modName = modAmmo[0].strip()
elif len(modExtra) == 2:
# line with drone/cargo and qty
extraAmount = modExtra[1].strip()
modName = modExtra[0].strip()
else:
# line with just module
modName = modExtra[0].strip()
try:
# get item information. If we are on a Drone/Cargo line, throw out cargo
item = sMkt.getItem(modName, eager="group.category")
except:
# if no data can be found (old names)
continue
if item.category.name == "Drone":
extraAmount = int(extraAmount) if extraAmount is not None else 1
if not modName in droneMap:
droneMap[modName] = 0
droneMap[modName] += extraAmount
if len(modExtra) == 2 and item.category.name != "Drone":
extraAmount = int(extraAmount) if extraAmount is not None else 1
if not modName in cargoMap:
cargoMap[modName] = 0
cargoMap[modName] += extraAmount
elif item.category.name == "Implant":
fit.implants.append(Implant(item))
# elif item.category.name == "Subsystem":
# try:
# subsystem = Module(item)
# except ValueError:
# continue
#
# if subsystem.fits(fit):
# fit.modules.append(subsystem)
else:
try:
m = Module(item)
except ValueError:
continue
# Add subsystems before modules to make sure T3 cruisers have subsystems installed
if item.category.name == "Subsystem":
if m.fits(fit):
fit.modules.append(m)
else:
if ammoName:
try:
ammo = sMkt.getItem(ammoName)
if m.isValidCharge(ammo) and m.charge is None:
m.charge = ammo
except:
pass
#.........这里部分代码省略.........