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


Python Fit.getInstance方法代码示例

本文整理汇总了Python中service.fit.Fit.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python Fit.getInstance方法的具体用法?Python Fit.getInstance怎么用?Python Fit.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在service.fit.Fit的用法示例。


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

示例1: __handleProjectedItem

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
 def __handleProjectedItem(self, mainItem, selection):
     fitID = self.mainFrame.getActiveFit()
     if isinstance(mainItem, EosFit):
         self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
             fitID=fitID, items=selection, amount=math.inf))
     elif isinstance(mainItem, EosModule):
         if wx.GetMouseState().GetModifiers() == wx.MOD_ALT:
             fit = Fit.getInstance().getFit(fitID)
             positions = getSimilarModPositions(fit.projectedModules, mainItem)
             items = [fit.projectedModules[p] for p in positions]
         else:
             items = selection
         self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
             fitID=fitID, items=items, amount=math.inf))
     elif isinstance(mainItem, EosDrone):
         self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
             fitID=fitID, items=selection, amount=math.inf))
     elif isinstance(mainItem, EosFighter):
         if wx.GetMouseState().GetModifiers() == wx.MOD_ALT:
             fit = Fit.getInstance().getFit(fitID)
             items = getSimilarFighters(fit.projectedFighters, mainItem)
         else:
             items = selection
         self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
             fitID=fitID, items=items, amount=math.inf))
     else:
         self.mainFrame.command.Submit(cmd.GuiRemoveProjectedItemsCommand(
             fitID=fitID, items=selection, amount=math.inf))
开发者ID:pyfa-org,项目名称:Pyfa,代码行数:30,代码来源:itemRemove.py

示例2: Undo

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
 def Undo(self):
     for _ in self.internal_history.Commands:
         self.internal_history.Undo()
     eos.db.commit()
     Fit.getInstance().recalc(self.fitID)
     wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=self.fitID))
     return True
开发者ID:blitzmann,项目名称:Pyfa,代码行数:9,代码来源:guiRebaseItems.py

示例3: click

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
 def click(self, event):
     mainRow, _ = self.HitTest(event.Position)
     if mainRow != -1:
         col = self.getColumn(event.Position)
         if col == self.getColIndex(State):
             mainItem = self.get(mainRow)
             if mainItem is None:
                 return
             selection = self.getSelectedProjectors()
             if mainItem not in selection:
                 selection = [mainItem]
             modPressed = wx.GetMouseState().GetModifiers() == wx.MOD_ALT
             fitID = self.mainFrame.getActiveFit()
             if isinstance(mainItem, EosModule) and modPressed:
                 fit = Fit.getInstance().getFit(fitID)
                 positions = getSimilarModPositions(fit.projectedModules, mainItem)
                 selection = [fit.projectedModules[p] for p in positions]
             elif isinstance(mainItem, EosFighter) and modPressed:
                 fit = Fit.getInstance().getFit(fitID)
                 selection = getSimilarFighters(fit.projectedFighters, mainItem)
             self.mainFrame.command.Submit(cmd.GuiChangeProjectedItemStatesCommand(
                 fitID=fitID,
                 mainItem=mainItem,
                 items=selection,
                 click='right' if event.GetButton() == 3 else 'left'))
             return
     event.Skip()
开发者ID:pyfa-org,项目名称:Pyfa,代码行数:29,代码来源:projectedView.py

示例4: importCrest

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def importCrest(str_):
        fit = json.loads(str_)
        sMkt = Market.getInstance()

        f = Fit()
        f.name = fit['name']

        try:
            try:
                f.ship = Ship(sMkt.getItem(fit['ship']['id']))
            except ValueError:
                f.ship = Citadel(sMkt.getItem(fit['ship']['id']))
        except:
            return None

        items = fit['items']
        items.sort(key=lambda k: k['flag'])

        moduleList = []
        for module in items:
            try:
                item = sMkt.getItem(module['type']['id'], eager="group.category")
                if module['flag'] == INV_FLAG_DRONEBAY:
                    d = Drone(item)
                    d.amount = module['quantity']
                    f.drones.append(d)
                elif module['flag'] == INV_FLAG_CARGOBAY:
                    c = Cargo(item)
                    c.amount = module['quantity']
                    f.cargo.append(c)
                elif module['flag'] == INV_FLAG_FIGHTER:
                    fighter = Fighter(item)
                    f.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:
                        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:
                        if m.isValidState(State.ACTIVE):
                            m.state = State.ACTIVE

                        moduleList.append(m)

            except:
                continue

        # Recalc to get slot numbers correct for T3 cruisers
        svcFit.getInstance().recalc(f)

        for module in moduleList:
            if module.fits(f):
                f.modules.append(module)

        return f
开发者ID:Ebag333,项目名称:Pyfa,代码行数:62,代码来源:port.py

示例5: getText

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def getText(self, stuff):
        if isinstance(stuff, Drone):
            return "%dx %s" % (stuff.amount, stuff.item.name)
        elif isinstance(stuff, Fighter):
            return "%d/%d %s" % \
                   (stuff.amountActive, stuff.getModifiedItemAttr("fighterSquadronMaxSize"), stuff.item.name)
        elif isinstance(stuff, Cargo):
            return "%dx %s" % (stuff.amount, stuff.item.name)
        elif isinstance(stuff, Fit):
            if self.projectedView:
                # we need a little more information for the projected view
                fitID = self.mainFrame.getActiveFit()
                info = stuff.getProjectionInfo(fitID)

                if info:
                    return "%dx %s (%s)" % (stuff.getProjectionInfo(fitID).amount, stuff.name, stuff.ship.item.name)

                pyfalog.warning("Projected View trying to display things that aren't there. stuff: {}, info: {}", repr(stuff),
                                info)
                return "<unknown>"
            else:
                return "%s (%s)" % (stuff.name, stuff.ship.item.name)
        elif isinstance(stuff, Rack):
            if FitSvc.getInstance().serviceFittingOptions["rackLabels"]:
                if stuff.slot == FittingSlot.MODE:
                    return '─ Tactical Mode ─'
                else:
                    return '─ {} {} Slot{}─'.format(stuff.num, FittingSlot(stuff.slot).name.capitalize(), '' if stuff.num == 1 else 's')
            else:
                return ""
        elif isinstance(stuff, Module):
            if self.projectedView:
                # check for projected abyssal name
                name_check = stuff.item.name[0:-2]
                type = WhProjector.abyssal_mapping.get(name_check, None)
                if type:
                    sMkt = Market.getInstance()
                    type = sMkt.getItem(type)
                    return "{} {}".format(type.name, stuff.item.name[-1:])

            if stuff.isEmpty:
                return "%s Slot" % FittingSlot(stuff.slot).name.capitalize()
            else:
                return stuff.item.name
        elif isinstance(stuff, Implant):
            return stuff.item.name
        else:
            item = getattr(stuff, "item", stuff)

            if FitSvc.getInstance().serviceFittingOptions["showMarketShortcuts"]:
                marketShortcut = getattr(item, "marketShortcut", None)

                if marketShortcut:
                    # use unicode subscript to display shortcut value
                    shortcut = chr(marketShortcut + 8320) + " "
                    del item.marketShortcut
                    return shortcut + item.name

            return item.name
开发者ID:blitzmann,项目名称:Pyfa,代码行数:61,代码来源:baseName.py

示例6: display

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def display(self, srcContext, mainItem):
        if not self.settings.get('changeAffectingSkills'):
            return False

        if srcContext not in (
            "fittingModule", "fittingCharge",
            "fittingShip", "droneItem",
            "fighterItem"
        ):
            return False

        fitID = self.mainFrame.getActiveFit()
        if fitID is None:
            return False

        if (mainItem is None or getattr(mainItem, "isEmpty", False)) and srcContext != "fittingShip":
            return False

        self.sChar = Character.getInstance()
        self.sFit = Fit.getInstance()
        fit = self.sFit.getFit(fitID)

        self.charID = fit.character.ID

        # if self.sChar.getCharName(self.charID) in ("All 0", "All 5"):
        #    return False

        if srcContext == "fittingShip":
            sFit = Fit.getInstance()
            self.stuff = sFit.getFit(fitID).ship
            cont = sFit.getFit(fitID).ship.itemModifiedAttributes
        elif srcContext == "fittingCharge":
            cont = mainItem.chargeModifiedAttributes
        else:
            cont = mainItem.itemModifiedAttributes

        skills = set()

        for attrName in cont.iterAfflictions():
            if cont[attrName] == 0:
                continue

            for fit, afflictors in cont.getAfflictions(attrName).items():
                for afflictor, modifier, amount, used in afflictors:
                    # only add Skills
                    if not isinstance(afflictor, Skill):
                        continue

                    skills.add(afflictor)

        self.skills = sorted(skills, key=lambda x: x.item.name)
        return len(self.skills) > 0
开发者ID:pyfa-org,项目名称:Pyfa,代码行数:54,代码来源:skillAffectors.py

示例7: getText

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def getText(self, stuff):
        if isinstance(stuff, Drone):
            return "%dx %s" % (stuff.amount, stuff.item.name)
        elif isinstance(stuff, Fighter):
            return "%d/%d %s" % \
                   (stuff.amountActive, stuff.getModifiedItemAttr("fighterSquadronMaxSize"), stuff.item.name)
        elif isinstance(stuff, Cargo):
            return "%dx %s" % (stuff.amount, stuff.item.name)
        elif isinstance(stuff, Fit):
            if self.projectedView:
                # we need a little more information for the projected view
                fitID = self.mainFrame.getActiveFit()
                info = stuff.getProjectionInfo(fitID)

                if info:
                    return "%dx %s (%s)" % (stuff.getProjectionInfo(fitID).amount, stuff.name, stuff.ship.item.name)

                pyfalog.warning("Projected View trying to display things that aren't there. stuff: {}, info: {}", repr(stuff),
                                info)
                return "<unknown>"
            else:
                return "%s (%s)" % (stuff.name, stuff.ship.item.name)
        elif isinstance(stuff, Rack):
            if FitSvc.getInstance().serviceFittingOptions["rackLabels"]:
                if stuff.slot == Slot.MODE:
                    return u'─ Tactical Mode ─'
                else:
                    return u'─ {} Slots ─'.format(Slot.getName(stuff.slot).capitalize())
            else:
                return ""
        elif isinstance(stuff, Module):
            if stuff.isEmpty:
                return "%s Slot" % Slot.getName(stuff.slot).capitalize()
            else:
                return stuff.item.name
        elif isinstance(stuff, Implant):
            return stuff.item.name
        else:
            item = getattr(stuff, "item", stuff)

            if FitSvc.getInstance().serviceFittingOptions["showMarketShortcuts"]:
                marketShortcut = getattr(item, "marketShortcut", None)

                if marketShortcut:
                    # use unicode subscript to display shortcut value
                    shortcut = unichr(marketShortcut + 8320) + u" "
                    del item.marketShortcut
                    return shortcut + item.name

            return item.name
开发者ID:PaulKPetersonCO,项目名称:Pyfa,代码行数:52,代码来源:baseName.py

示例8: fitChanged

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def fitChanged(self, event):
        sFit = Fit.getInstance()
        fit = sFit.getFit(event.fitID)

        self.Parent.Parent.DisablePage(self, not fit or fit.isStructure)

        # Clear list and get out if current fitId is None
        if event.fitID is None and self.lastFitId is not None:
            self.DeleteAllItems()
            self.lastFitId = None
            event.Skip()
            return

        self.origional = fit.boosters if fit is not None else None
        self.boosters = stuff = fit.boosters[:] if fit is not None else None

        if event.fitID != self.lastFitId:
            self.lastFitId = event.fitID

            item = self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_DONTCARE)

            if item != -1:
                self.EnsureVisible(item)

            self.deselectItems()

        self.populate(stuff)
        self.refresh(stuff)
        event.Skip()
开发者ID:Sectoid,项目名称:Pyfa,代码行数:31,代码来源:boosterView.py

示例9: fitSelected

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def fitSelected(self, event):
        count = -1
        # @todo pheonix: _pages is supposed to be private?
        for index, page in enumerate(self.multiSwitch._pages):
            if not isinstance(page, gui.builtinViews.emptyView.BlankPage):  # Don't try and process it if it's a blank page.
                try:
                    if page.activeFitID == event.fitID:
                        count += 1
                        self.multiSwitch.SetSelection(index)
                        wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=event.fitID))
                        break
                except Exception as e:
                    pyfalog.critical("Caught exception in fitSelected")
                    pyfalog.critical(e)
        if count < 0:
            startup = getattr(event, "startup", False)  # see OpenFitsThread in gui.mainFrame
            from_import = getattr(event, "from_import", False)  # always open imported into a new tab
            sFit = Fit.getInstance()
            openFitInNew = sFit.serviceFittingOptions["openFitInNew"]
            mstate = wx.GetMouseState()

            if from_import or (not openFitInNew and mstate.CmdDown()) or startup or (openFitInNew and not mstate.CmdDown()):
                self.multiSwitch.AddPage()

            view = self.multiSwitch.GetSelectedPage()

            if not isinstance(view, FittingView):
                view = FittingView(self.multiSwitch)
                pyfalog.debug("###################### Created new view:" + repr(view))
                self.multiSwitch.ReplaceActivePage(view)

            view.fitSelected(event)
开发者ID:blitzmann,项目名称:Pyfa,代码行数:34,代码来源:fittingView.py

示例10: appendItem

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def appendItem(self, event):
        """
        Adds items that are double clicks from the market browser. We handle both modules and ammo
        """
        if not self:
            event.Skip()
            return
        if self.parent.IsActive(self):
            itemID = event.itemID
            fitID = self.activeFitID
            if fitID is not None:
                sFit = Fit.getInstance()
                if sFit.isAmmo(itemID):
                    # If we've selected ammo, then apply to the selected module(s)
                    modules = []
                    sel = self.GetFirstSelected()
                    while sel != -1 and sel not in self.blanks:
                        mod = self.mods[self.GetItemData(sel)]
                        if isinstance(mod, Module) and not mod.isEmpty:
                            modules.append(self.mods[self.GetItemData(sel)])
                        sel = self.GetNextSelected(sel)

                    if len(modules) > 0:
                        self.mainFrame.command.Submit(cmd.GuiModuleAddChargeCommand(fitID, itemID, modules))
                else:
                    self.mainFrame.command.Submit(cmd.GuiModuleAddCommand(fitID, itemID))

        event.Skip()
开发者ID:blitzmann,项目名称:Pyfa,代码行数:30,代码来源:fittingView.py

示例11: fitChanged

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def fitChanged(self, event):
        sFit = Fit.getInstance()
        fit = sFit.getFit(event.fitID)

        self.Parent.Parent.Parent.DisablePage(self.Parent, not fit or fit.isStructure)

        # Clear list and get out if current fitId is None
        if event.fitID is None and self.lastFitId is not None:
            self.DeleteAllItems()
            self.lastFitId = None
            event.Skip()
            return

        self.original = fit.implants if fit is not None else None
        self.implants = stuff = fit.appliedImplants if fit is not None else None
        if stuff is not None:
            stuff.sort(key=lambda implant: implant.slot)

        if event.fitID != self.lastFitId:
            self.lastFitId = event.fitID

            item = self.GetNextItem(-1, wx.LIST_NEXT_ALL, wx.LIST_STATE_DONTCARE)

            if item != -1:
                self.EnsureVisible(item)

            self.deselectItems()

        self.update(stuff)
        event.Skip()
开发者ID:burnsypet,项目名称:Pyfa,代码行数:32,代码来源:implantView.py

示例12: fitChanged

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def fitChanged(self, event):
        sFit = Fit.getInstance()
        activeFitID = self.mainFrame.getActiveFit()
        fit = sFit.getFit(activeFitID)

        if fit:
            for x in self.labels:
                if fit.isStructure:
                    slot = getattr(FittingSlot, "FS_{}".format(x.upper()))
                else:
                    slot = getattr(FittingSlot, "F_{}".format(x.upper()))
                used = fit.getSlotsUsed(slot)
                total = fit.getNumSlots(slot)
                color = wx.Colour(204, 51, 51) if used > total else wx.SystemSettings.GetColour(
                    wx.SYS_COLOUR_WINDOWTEXT)

                lbl = getattr(self, "label%sUsed" % x.capitalize())
                lbl.SetLabel(str(int(used)))
                lbl.SetForegroundColour(color)

                lbl = getattr(self, "label%sTotal" % x.capitalize())
                lbl.SetLabel(str(int(total)))
                lbl.SetForegroundColour(color)

            self.Refresh()

        event.Skip()
开发者ID:blitzmann,项目名称:Pyfa,代码行数:29,代码来源:fighterView.py

示例13: exportFitting

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def exportFitting(self, event):
        sPort = Port.getInstance()
        fitID = self.mainFrame.getActiveFit()

        self.statusbar.SetStatusText("", 0)

        if fitID is None:
            self.statusbar.SetStatusText("Please select an active fitting in the main window", 1)
            return

        self.statusbar.SetStatusText("Sending request and awaiting response", 1)
        sCrest = Crest.getInstance()

        try:
            sFit = Fit.getInstance()
            data = sPort.exportCrest(sFit.getFit(fitID))
            res = sCrest.postFitting(self.getActiveCharacter(), data)

            self.statusbar.SetStatusText("%d: %s" % (res.status_code, res.reason), 0)
            try:
                text = json.loads(res.text)
                self.statusbar.SetStatusText(text['message'], 1)
            except ValueError:
                self.statusbar.SetStatusText("", 1)
        except requests.exceptions.ConnectionError:
            self.statusbar.SetStatusText("Connection error, please check your internet connection", 1)
开发者ID:Ebag333,项目名称:Pyfa,代码行数:28,代码来源:crestFittings.py

示例14: activate

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
 def activate(self, fullContext, selection, i):
     sFit = Fit.getInstance()
     fitID = self.mainFrame.getActiveFit()
     trigger = sFit.project(fitID, selection[0])
     if trigger:
         wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=fitID))
         self.mainFrame.additionsPane.select("Projected")
开发者ID:PaulKPetersonCO,项目名称:Pyfa,代码行数:9,代码来源:project.py

示例15: fitChanged

# 需要导入模块: from service.fit import Fit [as 别名]
# 或者: from service.fit.Fit import getInstance [as 别名]
    def fitChanged(self, event):
        enable = event.fitID is not None
        self.Enable(wx.ID_SAVEAS, enable)
        self.Enable(wx.ID_COPY, enable)
        self.Enable(self.exportSkillsNeededId, enable)

        sChar = Character.getInstance()
        charID = self.mainFrame.charSelection.getActiveCharacter()
        char = sChar.getCharacter(charID)

        # enable/disable character saving stuff
        self.Enable(self.saveCharId, not char.ro and char.isDirty)
        self.Enable(self.saveCharAsId, char.isDirty)
        self.Enable(self.revertCharId, char.isDirty)

        self.Enable(self.toggleIgnoreRestrictionID, enable)

        if event.fitID:
            sFit = Fit.getInstance()
            fit = sFit.getFit(event.fitID)

            if fit.ignoreRestrictions:
                self.ignoreRestrictionItem.SetItemLabel("Enable Fitting Restrictions")
            else:
                self.ignoreRestrictionItem.SetItemLabel("Disable Fitting Restrictions")

        event.Skip()
开发者ID:Sectoid,项目名称:Pyfa,代码行数:29,代码来源:mainMenuBar.py


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