当前位置: 首页>>代码示例>>Python>>正文


Python module.Module类代码示例

本文整理汇总了Python中eos.saveddata.module.Module的典型用法代码示例。如果您正苦于以下问题:Python Module类的具体用法?Python Module怎么用?Python Module使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Do

    def Do(self):
        pyfalog.debug('Doing change of local module states at position {}/{} to click {} on fit {}'.format(self.mainPosition, self.positions, self.click, self.fitID))
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.fitID)
        mainMod = fit.modules[self.mainPosition]
        if mainMod.isEmpty:
            return False
        positions = [pos for pos in self.positions if not fit.modules[pos].isEmpty]
        if self.mainPosition not in positions:
            positions.append(self.mainPosition)
        self.savedStates = {pos: fit.modules[pos].state for pos in positions}

        changed = False
        mainProposedState = Module.getProposedState(mainMod, self.click)
        pyfalog.debug('Attempting to change modules to {}'.format(mainProposedState))
        if mainProposedState != mainMod.state:
            pyfalog.debug('Toggle {} state: {} for fit ID: {}'.format(mainMod, mainProposedState, self.fitID))
            mainMod.state = mainProposedState
            changed = True
        for position in [pos for pos in positions if pos != self.mainPosition]:
            mod = fit.modules[position]
            proposedState = Module.getProposedState(mod, self.click, mainProposedState)
            if proposedState != mod.state:
                pyfalog.debug('Toggle {} state: {} for fit ID: {}'.format(mod, proposedState, self.fitID))
                mod.state = proposedState
                changed = True
        if not changed:
            return False
        sFit.recalc(fit)
        self.savedStateCheckChanges = sFit.checkStates(fit, mainMod)
        return True
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: __makeModule

    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
开发者ID:,项目名称:,代码行数:30,代码来源:

示例3: __init__

 def __init__(self, fitID, mainItem, items, click):
     wx.Command.__init__(self, True, 'Change Projected Item States')
     self.internalHistory = InternalCommandHistory()
     self.fitID = fitID
     self.pModPositions = []
     self.pDroneItemIDs = []
     self.pFighterPositions = []
     self.pFitIDs = []
     fit = Fit.getInstance().getFit(fitID)
     for item in items:
         if isinstance(item, EosModule):
             if item in fit.projectedModules:
                 self.pModPositions.append(fit.projectedModules.index(item))
         elif isinstance(item, EosDrone):
             self.pDroneItemIDs.append(item.itemID)
         elif isinstance(item, EosFighter):
             if item in fit.projectedFighters:
                 self.pFighterPositions.append(fit.projectedFighters.index(item))
         elif isinstance(item, EosFit):
             self.pFitIDs.append(item.ID)
     self.proposedState = None
     if click == 'right' and isinstance(mainItem, EosModule):
         self.proposedState = 'overheat'
     elif click == 'left':
         if isinstance(mainItem, EosModule):
             modProposedState = EosModule.getProposedState(mainItem, click)
             self.proposedState = 'inactive' if modProposedState == FittingModuleState.OFFLINE else 'active'
         elif isinstance(mainItem, EosDrone):
             self.proposedState = 'active' if mainItem.amountActive == 0 else 'inactive'
         elif isinstance(mainItem, EosFighter):
             self.proposedState = 'inactive' if mainItem.active else 'active'
         elif isinstance(mainItem, EosFit):
             projectionInfo = mainItem.getProjectionInfo(self.fitID)
             if projectionInfo is not None:
                 self.proposedState = 'inactive' if projectionInfo.active else 'active'
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: Do

    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
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:20,代码来源:fitAddProjectedModule.py

示例5: Do

    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
开发者ID:petosorus,项目名称:Pyfa,代码行数:20,代码来源:fitAddProjectedEnv.py

示例6: Do

    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
开发者ID:blitzmann,项目名称:Pyfa,代码行数:21,代码来源:fitAddProjectedEnv.py

示例7: Do

    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
开发者ID:burnsypet,项目名称:Pyfa,代码行数:59,代码来源:fitImportMutatedModule.py

示例8: toggleModulesState

    def toggleModulesState(self, fitID, base, modules, click):
        pyfalog.debug("Toggle module state for fit ID: {0}", fitID)
        changed = False
        proposedState = es_Module.getProposedState(base, click)

        if proposedState != base.state:
            changed = True
            base.state = proposedState
            for mod in modules:
                if mod != base:
                    p = es_Module.getProposedState(mod, click, proposedState)
                    mod.state = p
                    if p != mod.state:
                        changed = True

        if changed:
            eos.db.commit()
            fit = eos.db.getFit(fitID)

            # 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
            self.checkStates(fit, base)
开发者ID:blitzmann,项目名称:Pyfa,代码行数:23,代码来源:fitDeprecated.py

示例9: change_module

    def change_module(self, fitID, position, itemID):
        fit = eos.db.getFit(fitID)

        # We're trying to add a charge to a slot, which won't work. Instead, try to add the charge to the module in that slot.
        # todo: evaluate if this is still a thing
        # actually, this seems like it should be handled higher up...
        #
        # if self.isAmmo(itemID):
        #     module = fit.modules[self.position]
        #     if not module.isEmpty:
        #         self.setAmmo(fitID, itemID, [module])
        #     return True

        pyfalog.debug("Changing position of module from position ({0}) for fit ID: {1}", self.position, fitID)

        item = eos.db.getItem(itemID, eager=("attributes", "group.category"))
        mod = fit.modules[self.position]

        try:
            self.module = Module(item)
        except ValueError:
            pyfalog.warning("Invalid item: {0}", itemID)
            return False

        if self.module.slot != mod.slot:
            return False

        # Dummy it out in case the next bit fails
        fit.modules.toDummy(self.position)

        if not self.module.fits(fit):
            self.Undo()
            return False

        self.module.owner = fit
        fit.modules.toModule(self.position, self.module)
        if self.module.isValidState(FittingModuleState.ACTIVE):
            self.module.state = FittingModuleState.ACTIVE

        if self.old_module and self.old_module.charge and self.module.isValidCharge(self.old_module.charge):
            self.module.charge = self.old_module.charge

        # Then, check states of all modules and change where needed. This will recalc if needed
        # self.checkStates(fit, m)

        # fit.fill()
        eos.db.commit()
        return True
开发者ID:blitzmann,项目名称:Pyfa,代码行数:48,代码来源:fitReplaceModule.py

示例10: Do

    def Do(self):
        sFit = Fit.getInstance()
        fitID = self.fitID
        itemID = self.itemID
        fit = eos.db.getFit(fitID)
        item = eos.db.getItem(itemID, eager=("attributes", "group.category"))

        bItem = eos.db.getItem(self.baseID) if self.baseID else None
        mItem = next((x for x in bItem.mutaplasmids if x.ID == self.mutaplasmidID)) if self.mutaplasmidID else None

        try:
            self.module = Module(item, bItem, mItem)
        except ValueError:
            pyfalog.warning("Invalid module: {}", item)
            return False

        # If subsystem and we need to replace, run the replace command instead and bypass the rest of this command
        if self.module.item.category.name == "Subsystem":
            for mod in fit.modules:
                if mod.getModifiedItemAttr("subSystemSlot") == self.module.getModifiedItemAttr("subSystemSlot"):
                    from .fitReplaceModule import FitReplaceModuleCommand
                    self.replace_cmd = FitReplaceModuleCommand(self.fitID, mod.modPosition, itemID)
                    return self.replace_cmd.Do()

        if self.module.fits(fit):
            pyfalog.debug("Adding {} as module for fit {}", self.module, fit)
            self.module.owner = fit
            numSlots = len(fit.modules)
            fit.modules.append(self.module)
            if self.module.isValidState(State.ACTIVE):
                self.module.state = State.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, self.module)

            # fit.fill()
            eos.db.commit()

            self.change = numSlots != len(fit.modules)
            self.new_position = self.module.modPosition
        else:
            return False

        return True
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:47,代码来源:fitAddModule.py

示例11: toggleProjected

    def toggleProjected(self, fitID, thing, click):
        pyfalog.debug("Toggling projected on fit ({0}) for: {1}", fitID, thing)
        fit = eos.db.getFit(fitID)
        if isinstance(thing, es_Drone):
            if thing.amountActive == 0 and thing.canBeApplied(fit):
                thing.amountActive = thing.amount
            else:
                thing.amountActive = 0
        elif isinstance(thing, es_Fighter):
            thing.active = not thing.active
        elif isinstance(thing, es_Module):
            thing.state = es_Module.getProposedState(thing, click)
            if not thing.canHaveState(thing.state, fit):
                thing.state = State.OFFLINE
        elif isinstance(thing, FitType):
            projectionInfo = thing.getProjectionInfo(fitID)
            if projectionInfo:
                projectionInfo.active = not projectionInfo.active

        eos.db.commit()
        self.recalc(fit)
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:21,代码来源:fit.py

示例12: getTestSet

    def getTestSet(setType):
        def getT2ItemsWhere(additionalFilter, mustBeOffensive=False, category="Module"):
            # Used to obtain a smaller subset of items while still containing examples of each group.
            T2_META_LEVEL = 5
            metaLevelAttrID = getAttributeInfo("metaLevel").attributeID
            categoryID = getCategory(category).categoryID
            result = gamedata_session.query(Item).join(ItemEffect, Group, Attribute).\
                      filter(
                          additionalFilter,
                          Attribute.attributeID == metaLevelAttrID,
                          Attribute.value == T2_META_LEVEL,
                          Group.categoryID == categoryID,
                      ).all()
            if mustBeOffensive:
                result = filter(lambda t: t.offensive is True, result)
            return list(result)

        def getChargeType(item, setType):
            if setType == "turret":
                return str(item.attributes["chargeGroup1"].value) + "-" + str(item.attributes["chargeSize"].value)
            return str(item.attributes["chargeGroup1"].value)

        if setType in EfsPort.wepTestSet.keys():
            return EfsPort.wepTestSet[setType]
        else:
            EfsPort.wepTestSet[setType] = []
        modSet = EfsPort.wepTestSet[setType]

        if setType == "drone":
            ilist = getT2ItemsWhere(True, True, "Drone")
            for item in ilist:
                drone = Drone(item)
                drone.amount = 1
                drone.amountActive = 1
                drone.itemModifiedAttributes.parent = drone
                modSet.append(drone)
            return modSet

        turretFittedEffectID = gamedata_session.query(Effect).filter(Effect.name == "turretFitted").first().effectID
        launcherFittedEffectID = gamedata_session.query(Effect).filter(Effect.name == "launcherFitted").first().effectID
        if setType == "launcher":
            effectFilter = ItemEffect.effectID == launcherFittedEffectID
            reqOff = False
        else:
            effectFilter = ItemEffect.effectID == turretFittedEffectID
            reqOff = True
        ilist = getT2ItemsWhere(effectFilter, reqOff)
        previousChargeTypes = []
        # Get modules from item list
        for item in ilist:
            chargeType = getChargeType(item, setType)
            # Only add turrets if we don"t already have one with the same size and ammo type.
            if setType == "launcher" or chargeType not in previousChargeTypes:
                previousChargeTypes.append(chargeType)
                mod = Module(item)
                modSet.append(mod)

        sMkt = Market.getInstance()
        # Due to typed missile damage bonuses we"ll need to add extra launchers to cover all four types.
        additionalLaunchers = []
        for mod in modSet:
            clist = list(gamedata_session.query(Item).options().
                    filter(Item.groupID == mod.getModifiedItemAttr("chargeGroup1")).all())
            mods = [mod]
            charges = [clist[0]]
            if setType == "launcher":
                # We don"t want variations of missiles we already have
                prevCharges = list(sMkt.getVariationsByItems(charges))
                testCharges = []
                for charge in clist:
                    if charge not in prevCharges:
                        testCharges.append(charge)
                        prevCharges += sMkt.getVariationsByItems([charge])
                for c in testCharges:
                    charges.append(c)
                    additionalLauncher = Module(mod.item)
                    mods.append(additionalLauncher)
            for i in range(len(mods)):
                mods[i].charge = charges[i]
                mods[i].reloadForce = True
                mods[i].state = 2
                if setType == "launcher" and i > 0:
                    additionalLaunchers.append(mods[i])
        modSet += additionalLaunchers
        return modSet
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:85,代码来源:efs.py

示例13: FitAddModuleCommand

class FitAddModuleCommand(wx.Command):
    """"
    Fitting command that appends a module to a fit using the first available slot. In the case of a Subsystem, it checks
    if there is already a subsystem with the same slot, and runs the replace command instead.

    from sFit.appendModule
    """
    def __init__(self, fitID, itemID, mutaplasmidID=None, baseID=None):
        wx.Command.__init__(self, True)
        self.fitID = fitID
        self.itemID = itemID
        self.mutaplasmidID = mutaplasmidID
        self.baseID = baseID
        self.new_position = None
        self.change = None
        self.replace_cmd = None

    def Do(self):
        sFit = Fit.getInstance()
        fitID = self.fitID
        itemID = self.itemID
        fit = eos.db.getFit(fitID)
        item = eos.db.getItem(itemID, eager=("attributes", "group.category"))

        bItem = eos.db.getItem(self.baseID) if self.baseID else None
        mItem = next((x for x in bItem.mutaplasmids if x.ID == self.mutaplasmidID)) if self.mutaplasmidID else None

        try:
            self.module = Module(item, bItem, mItem)
        except ValueError:
            pyfalog.warning("Invalid module: {}", item)
            return False

        # If subsystem and we need to replace, run the replace command instead and bypass the rest of this command
        if self.module.item.category.name == "Subsystem":
            for mod in fit.modules:
                if mod.getModifiedItemAttr("subSystemSlot") == self.module.getModifiedItemAttr("subSystemSlot"):
                    from .fitReplaceModule import FitReplaceModuleCommand
                    self.replace_cmd = FitReplaceModuleCommand(self.fitID, mod.modPosition, itemID)
                    return self.replace_cmd.Do()

        if self.module.fits(fit):
            pyfalog.debug("Adding {} as module for fit {}", self.module, fit)
            self.module.owner = fit
            numSlots = len(fit.modules)
            fit.modules.append(self.module)
            if self.module.isValidState(State.ACTIVE):
                self.module.state = State.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, self.module)

            # fit.fill()
            eos.db.commit()

            self.change = numSlots != len(fit.modules)
            self.new_position = self.module.modPosition
        else:
            return False

        return True

    def Undo(self):
        # We added a subsystem module, which actually ran the replace command. Run the undo for that guy instead
        if self.replace_cmd:
            return self.replace_cmd.Undo()

        from .fitRemoveModule import FitRemoveModuleCommand  # Avoid circular import
        if self.new_position:
            cmd = FitRemoveModuleCommand(self.fitID, [self.new_position])
            cmd.Do()
        return True
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:75,代码来源:fitAddModule.py

示例14: importESI

def importESI(str_):

    sMkt = Market.getInstance()
    fitobj = Fit()
    refobj = json.loads(str_)
    items = refobj['items']
    # "<" and ">" is replace to "&lt;", "&gt;" 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
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:69,代码来源:esi.py

示例15: importXml

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
开发者ID:,项目名称:,代码行数:97,代码来源:


注:本文中的eos.saveddata.module.Module类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。