本文整理汇总了Python中eos.types.Fit.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Fit.clear方法的具体用法?Python Fit.clear怎么用?Python Fit.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eos.types.Fit
的用法示例。
在下文中一共展示了Fit.clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: importFittingWindow
# 需要导入模块: from eos.types import Fit [as 别名]
# 或者: from eos.types.Fit import clear [as 别名]
def importFittingWindow(string, activeFit):
sMkt = service.Market.getInstance()
sFit = service.Fit.getInstance()
activeFit = sFit.getFit(activeFit)
# if the current fit has mods, do not mess with it. Instead, make new fit
if activeFit.modCount > 0:
fit = Fit()
fit.ship = Ship(sMkt.getItem(activeFit.ship.item.ID))
fit.name = "%s (copy)" % activeFit.name
else:
fit = activeFit
lines = re.split('[\n\r]+', string)
droneMap = {}
cargoMap = {}
modules = []
for i in range(1, len(lines)):
line = lines[i].strip()
if not line:
continue
try:
amount, modName = line.split("x ")
amount = int(amount)
item = sMkt.getItem(modName, eager="group.category")
except:
# if no data can be found (old names)
continue
if item.category.name == "Drone":
if not modName in droneMap:
droneMap[modName] = 0
droneMap[modName] += amount
elif item.category.name == "Charge":
if not modName in cargoMap:
cargoMap[modName] = 0
cargoMap[modName] += amount
else:
for _ in xrange(amount):
try:
m = Module(item)
except ValueError:
continue
# If we are importing T3 ship, we must apply subsystems first, then
# calcModAttr() to get the ship slots
if m.slot == Slot.SUBSYSTEM and m.fits(fit):
fit.modules.append(m)
else:
modules.append(m)
fit.clear()
fit.calculateModifiedAttributes()
for m in modules:
# we check to see if module fits as a basic sanity check
# if it doesn't then the imported fit is most likely invalid
# (ie: user tried to import Legion fit to a Rifter)
if m.fits(fit):
fit.modules.append(m)
if m.isValidState(State.ACTIVE):
m.state = State.ACTIVE
m.owner = fit # not sure why this is required when it's not for other import methods, but whatever
else:
return
for droneName in droneMap:
d = Drone(sMkt.getItem(droneName))
d.amount = droneMap[droneName]
fit.drones.append(d)
for cargoName in cargoMap:
c = Cargo(sMkt.getItem(cargoName))
c.amount = cargoMap[cargoName]
fit.cargo.append(c)
return fit