本文整理汇总了Python中eos.saveddata.module.Module.state方法的典型用法代码示例。如果您正苦于以下问题:Python Module.state方法的具体用法?Python Module.state怎么用?Python Module.state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eos.saveddata.module.Module
的用法示例。
在下文中一共展示了Module.state方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __makeModule
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def __makeModule(self, itemSpec):
# Mutate item if needed
m = None
if itemSpec.mutationIdx in self.mutations:
mutaItem, mutaAttrs = self.mutations[itemSpec.mutationIdx]
mutaplasmid = getDynamicItem(mutaItem.ID)
if mutaplasmid:
try:
m = Module(mutaplasmid.resultingItem, itemSpec.item, mutaplasmid)
except ValueError:
pass
else:
for attrID, mutator in m.mutators.items():
if attrID in mutaAttrs:
mutator.value = mutaAttrs[attrID]
# If we still don't have item (item is not mutated or we
# failed to construct mutated item), try to make regular item
if m is None:
try:
m = Module(itemSpec.item)
except ValueError:
return None
if itemSpec.charge is not None and m.isValidCharge(itemSpec.charge):
m.charge = itemSpec.charge
if itemSpec.offline and m.isValidState(FittingModuleState.OFFLINE):
m.state = FittingModuleState.OFFLINE
elif m.isValidState(FittingModuleState.ACTIVE):
m.state = activeStateLimit(m.item)
return m
示例2: Do
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def Do(self):
sFit = Fit.getInstance()
fitID = self.fitID
fit = eos.db.getFit(fitID)
if self.baseItem is None:
pyfalog.warning("Unable to build non-mutated module: no base item to build from")
return False
try:
mutaTypeID = self.mutaItem.ID
except AttributeError:
mutaplasmid = None
else:
mutaplasmid = getDynamicItem(mutaTypeID)
# Try to build simple item even though no mutaplasmid found
if mutaplasmid is None:
try:
module = Module(self.baseItem)
except ValueError:
pyfalog.warning("Unable to build non-mutated module: {}", self.baseItem)
return False
# Build mutated module otherwise
else:
try:
module = Module(mutaplasmid.resultingItem, self.baseItem, mutaplasmid)
except ValueError:
pyfalog.warning("Unable to build mutated module: {} {}", self.baseItem, self.mutaItem)
return False
else:
for attrID, mutator in module.mutators.items():
if attrID in self.attrMap:
mutator.value = self.attrMap[attrID]
# this is essentially the same as the FitAddModule command. possibly look into centralizing this functionality somewhere?
if module.fits(fit):
pyfalog.debug("Adding {} as module for fit {}", module, fit)
module.owner = fit
numSlots = len(fit.modules)
fit.modules.append(module)
if module.isValidState(FittingModuleState.ACTIVE):
module.state = FittingModuleState.ACTIVE
# todo: fix these
# As some items may affect state-limiting attributes of the ship, calculate new attributes first
# self.recalc(fit)
# Then, check states of all modules and change where needed. This will recalc if needed
sFit.checkStates(fit, module)
# fit.fill()
eos.db.commit()
self.change = numSlots != len(fit.modules)
self.new_position = module.modPosition
else:
return False
return True
示例3: Do
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def Do(self):
pyfalog.debug("Projecting fit ({0}) onto: {1}", self.fitID, self.itemID)
fit = eos.db.getFit(self.fitID)
item = eos.db.getItem(self.itemID, eager=("attributes", "group.category"))
try:
module = Module(item)
if not module.item.isType("projected"):
return False
except ValueError:
return False
module.state = State.ACTIVE
if not module.canHaveState(module.state, fit):
module.state = State.OFFLINE
fit.projectedModules.append(module)
eos.db.commit()
self.new_index = fit.projectedModules.index(module)
return True
示例4: Do
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def Do(self):
pyfalog.debug("Projecting fit ({0}) onto: {1}", self.fitID, self.itemID)
fit = eos.db.getFit(self.fitID)
item = eos.db.getItem(self.itemID, eager=("attributes", "group.category"))
try:
module = Module(item)
except ValueError:
return False
# todo: thing to check for existing environmental effects
self.old_item = fit.projectedModules.makeRoom(module)
module.state = State.ONLINE
fit.projectedModules.append(module)
eos.db.commit()
self.new_index = fit.projectedModules.index(module)
return True
示例5: Do
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def Do(self):
pyfalog.debug("Projecting fit ({0}) onto: {1}", self.fitID, self.itemID)
fit = eos.db.getFit(self.fitID)
item = eos.db.getItem(self.itemID, eager=("attributes", "group.category"))
try:
module = Module(item)
except ValueError:
return False
# todo: thing to check for existing environmental effects
module.state = FittingModuleState.ONLINE
if module.isExclusiveSystemEffect:
# if this is an exclusive system effect, we need to cache the old one. We make room for the new one here, which returns the old one
self.old_item = fit.projectedModules.makeRoom(module)
fit.projectedModules.append(module)
eos.db.commit()
self.new_index = fit.projectedModules.index(module)
return True
示例6: importESI
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def importESI(str_):
sMkt = Market.getInstance()
fitobj = Fit()
refobj = json.loads(str_)
items = refobj['items']
# "<" and ">" is replace to "<", ">" by EVE client
fitobj.name = refobj['name']
# 2017/03/29: read description
fitobj.notes = refobj['description']
try:
ship = refobj['ship_type_id']
try:
fitobj.ship = Ship(sMkt.getItem(ship))
except ValueError:
fitobj.ship = Citadel(sMkt.getItem(ship))
except:
pyfalog.warning("Caught exception in importESI")
return None
items.sort(key=lambda k: k['flag'])
moduleList = []
for module in items:
try:
item = sMkt.getItem(module['type_id'], eager="group.category")
if not item.published:
continue
if module['flag'] == INV_FLAG_DRONEBAY:
d = Drone(item)
d.amount = module['quantity']
fitobj.drones.append(d)
elif module['flag'] == INV_FLAG_CARGOBAY:
c = Cargo(item)
c.amount = module['quantity']
fitobj.cargo.append(c)
elif module['flag'] == INV_FLAG_FIGHTER:
fighter = Fighter(item)
fitobj.fighters.append(fighter)
else:
try:
m = Module(item)
# When item can't be added to any slot (unknown item or just charge), ignore it
except ValueError:
pyfalog.debug("Item can't be added to any slot (unknown item or just charge)")
continue
# Add subsystems before modules to make sure T3 cruisers have subsystems installed
if item.category.name == "Subsystem":
if m.fits(fitobj):
fitobj.modules.append(m)
else:
if m.isValidState(State.ACTIVE):
m.state = State.ACTIVE
moduleList.append(m)
except:
pyfalog.warning("Could not process module.")
continue
# Recalc to get slot numbers correct for T3 cruisers
svcFit.getInstance().recalc(fitobj)
for module in moduleList:
if module.fits(fitobj):
fitobj.modules.append(module)
return fitobj
示例7: importXml
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def importXml(text, iportuser):
from .port import Port
# type: (str, IPortUser) -> list[eos.saveddata.fit.Fit]
sMkt = Market.getInstance()
doc = xml.dom.minidom.parseString(text)
# NOTE:
# When L_MARK is included at this point,
# Decided to be localized data
b_localized = L_MARK in text
fittings = doc.getElementsByTagName("fittings").item(0)
fittings = fittings.getElementsByTagName("fitting")
fit_list = []
failed = 0
for fitting in fittings:
try:
fitobj = _resolve_ship(fitting, sMkt, b_localized)
except:
failed += 1
continue
# -- 170327 Ignored description --
# read description from exported xml. (EVE client, EFT)
description = fitting.getElementsByTagName("description").item(0).getAttribute("value")
if description is None:
description = ""
elif len(description):
# convert <br> to "\n" and remove html tags.
if Port.is_tag_replace():
description = replace_ltgt(
sequential_rep(description, r"<(br|BR)>", "\n", r"<[^<>]+>", "")
)
fitobj.notes = description
hardwares = fitting.getElementsByTagName("hardware")
moduleList = []
for hardware in hardwares:
try:
item = _resolve_module(hardware, sMkt, b_localized)
if not item or not item.published:
continue
if item.category.name == "Drone":
d = Drone(item)
d.amount = int(hardware.getAttribute("qty"))
fitobj.drones.append(d)
elif item.category.name == "Fighter":
ft = Fighter(item)
ft.amount = int(hardware.getAttribute("qty")) if ft.amount <= ft.fighterSquadronMaxSize else ft.fighterSquadronMaxSize
fitobj.fighters.append(ft)
elif hardware.getAttribute("slot").lower() == "cargo":
# although the eve client only support charges in cargo, third-party programs
# may support items or "refits" in cargo. Support these by blindly adding all
# cargo, not just charges
c = Cargo(item)
c.amount = int(hardware.getAttribute("qty"))
fitobj.cargo.append(c)
else:
try:
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")
continue
# Add subsystems before modules to make sure T3 cruisers have subsystems installed
if item.category.name == "Subsystem":
if m.fits(fitobj):
m.owner = fitobj
fitobj.modules.append(m)
else:
if m.isValidState(FittingModuleState.ACTIVE):
m.state = activeStateLimit(m.item)
moduleList.append(m)
except KeyboardInterrupt:
pyfalog.warning("Keyboard Interrupt")
continue
# Recalc to get slot numbers correct for T3 cruisers
sFit = svcFit.getInstance()
sFit.recalc(fitobj)
sFit.fill(fitobj)
for module in moduleList:
if module.fits(fitobj):
module.owner = fitobj
fitobj.modules.append(module)
fit_list.append(fitobj)
if iportuser: # NOTE: Send current processing status
processing_notify(
iportuser, IPortUser.PROCESS_IMPORT | IPortUser.ID_UPDATE,
"Processing %s\n%s" % (fitobj.ship.name, fitobj.name)
)
return fit_list
示例8: importEftCfg
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
#.........这里部分代码省略.........
if entityState == "Active":
imp.active = True
elif entityState == "Inactive":
imp.active = False
fitobj.implants.append(imp)
elif entityType == "Booster":
# Bail if we can't get item or it's not from implant category
try:
boosterItem = sMkt.getItem(entityData, eager="group.category")
except:
pyfalog.warning("Cannot get item.")
continue
# All boosters have implant category
if boosterItem.category.name != "Implant":
continue
# Add booster to the fitting
b = Booster(boosterItem)
if entityState == "Active":
b.active = True
elif entityState == "Inactive":
b.active = False
fitobj.boosters.append(b)
# If we don't have any prefixes, then it's a module
elif cargo:
cargoData = re.match("(.+),([0-9]+)", cargo.group(1))
cargoName = cargoData.group(1) if cargoData else cargo.group(1)
cargoAmount = int(cargoData.group(2)) if cargoData else 1
# Bail if we can't get item
try:
item = sMkt.getItem(cargoName)
except:
pyfalog.warning("Cannot get item.")
continue
# Add Cargo to the fitting
c = Cargo(item)
c.amount = cargoAmount
fitobj.cargo.append(c)
# 2017/03/27 NOTE: store description from EFT
elif description:
fitobj.notes = description.group(1).replace("|", "\n")
else:
withCharge = re.match("(.+),(.+)", line)
modName = withCharge.group(1) if withCharge else line
chargeName = withCharge.group(2) if withCharge else None
# If we can't get module item, skip it
try:
modItem = sMkt.getItem(modName)
except:
pyfalog.warning("Cannot get item.")
continue
# Create module
m = Module(modItem)
# Add subsystems before modules to make sure T3 cruisers have subsystems installed
if modItem.category.name == "Subsystem":
if m.fits(fitobj):
fitobj.modules.append(m)
else:
m.owner = fitobj
# Activate mod if it is activable
if m.isValidState(FittingModuleState.ACTIVE):
m.state = activeStateLimit(m.item)
# Add charge to mod if applicable, on any errors just don't add anything
if chargeName:
try:
chargeItem = sMkt.getItem(chargeName, eager="group.category")
if chargeItem.category.name == "Charge":
m.charge = chargeItem
except:
pyfalog.warning("Cannot get item.")
pass
# Append module to fit
moduleList.append(m)
# Recalc to get slot numbers correct for T3 cruisers
sFit = svcFit.getInstance()
sFit.recalc(fitobj)
sFit.fill(fitobj)
for module in moduleList:
if module.fits(fitobj):
fitobj.modules.append(module)
# Append fit to list of fits
fits.append(fitobj)
if iportuser: # NOTE: Send current processing status
processing_notify(
iportuser, IPortUser.PROCESS_IMPORT | IPortUser.ID_UPDATE,
"%s:\n%s" % (fitobj.ship.name, fitobj.name)
)
# Skip fit silently if we get an exception
except Exception as e:
pyfalog.error("Caught exception on fit.")
pyfalog.error(e)
pass
return fits
示例9: importDna
# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import state [as 别名]
def importDna(string):
sMkt = Market.getInstance()
ids = list(map(int, re.findall(r'\d+', string)))
for id_ in ids:
try:
try:
try:
Ship(sMkt.getItem(sMkt.getItem(id_)))
except ValueError:
Citadel(sMkt.getItem(sMkt.getItem(id_)))
except ValueError:
Citadel(sMkt.getItem(id_))
string = string[string.index(str(id_)):]
break
except:
pyfalog.warning("Exception caught in importDna")
pass
string = string[:string.index("::") + 2]
info = string.split(":")
f = Fit()
try:
try:
f.ship = Ship(sMkt.getItem(int(info[0])))
except ValueError:
f.ship = Citadel(sMkt.getItem(int(info[0])))
f.name = "{0} - DNA Imported".format(f.ship.item.name)
except UnicodeEncodeError:
def logtransform(s_):
if len(s_) > 10:
return s_[:10] + "..."
return s_
pyfalog.exception("Couldn't import ship data {0}", [logtransform(s) for s in info])
return None
moduleList = []
for itemInfo in info[1:]:
if itemInfo:
itemID, amount = itemInfo.split(";")
item = sMkt.getItem(int(itemID), eager="group.category")
if item.category.name == "Drone":
d = Drone(item)
d.amount = int(amount)
f.drones.append(d)
elif item.category.name == "Fighter":
ft = Fighter(item)
ft.amount = int(amount) if ft.amount <= ft.fighterSquadronMaxSize else ft.fighterSquadronMaxSize
if ft.fits(f):
f.fighters.append(ft)
elif item.category.name == "Charge":
c = Cargo(item)
c.amount = int(amount)
f.cargo.append(c)
else:
for i in range(int(amount)):
try:
m = Module(item)
except:
pyfalog.warning("Exception caught in importDna")
continue
# Add subsystems before modules to make sure T3 cruisers have subsystems installed
if item.category.name == "Subsystem":
if m.fits(f):
f.modules.append(m)
else:
m.owner = f
if m.isValidState(State.ACTIVE):
m.state = State.ACTIVE
moduleList.append(m)
# Recalc to get slot numbers correct for T3 cruisers
svcFit.getInstance().recalc(f)
for module in moduleList:
if module.fits(f):
module.owner = f
if module.isValidState(State.ACTIVE):
module.state = State.ACTIVE
f.modules.append(module)
return f