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


Python port.Port类代码示例

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


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

示例1: backupToXml

    def backupToXml(self, event):
        """ Back up all fits to EVE XML file """
        defaultFile = "pyfa-fits-%s.xml" % strftime("%Y%m%d_%H%M%S", gmtime())

        saveDialog = wx.FileDialog(
            self,
            "Save Backup As...",
            wildcard="EVE XML fitting file (*.xml)|*.xml",
            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
            defaultFile=defaultFile,
        )

        if saveDialog.ShowModal() == wx.ID_OK:
            filePath = saveDialog.GetPath()
            if '.' not in os.path.basename(filePath):
                filePath += ".xml"

            sFit = Fit.getInstance()
            max_ = sFit.countAllFits()

            self.progressDialog = wx.ProgressDialog(
                "Backup fits",
                "Backing up %d fits to: %s" % (max_, filePath),
                maximum=max_,
                parent=self,
                style=wx.PD_CAN_ABORT | wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_APP_MODAL
            )
            Port.backupFits(filePath, self)
            self.progressDialog.ShowModal()
开发者ID:petosorus,项目名称:Pyfa,代码行数:29,代码来源:mainFrame.py

示例2: generateMinimalHTML

    def generateMinimalHTML(self, sMkt, sFit, dnaUrl):
        """ Generate a minimal HTML version of the fittings, without any javascript or styling"""
        categoryList = list(sMkt.getShipRoot())
        categoryList.sort(key=lambda _ship: _ship.name)

        count = 0
        HTML = ''
        for group in categoryList:
            # init market group string to give ships something to attach to

            ships = list(sMkt.getShipList(group.ID))
            ships.sort(key=lambda _ship: _ship.name)

            ships.sort(key=lambda _ship: _ship.name)

            for ship in ships:
                fits = sFit.getFitsWithShip(ship.ID)
                for fit in fits:
                    if self.stopRunning:
                        return
                    try:
                        dnaFit = Port.exportDna(getFit(fit[0]))
                        HTML += '<a class="outOfGameBrowserLink" target="_blank" href="' + dnaUrl + dnaFit + '">' \
                                + ship.name + ': ' + \
                                fit[1] + '</a><br> \n'
                    except:
                        pyfalog.error("Failed to export line")
                        continue
                    finally:
                        if self.callback:
                            wx.CallAfter(self.callback, count)
                        count += 1
        return HTML
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:33,代码来源:exportHtml.py

示例3: showExportDialog

    def showExportDialog(self, event):
        """ Export active fit """
        sFit = Fit.getInstance()
        fit = sFit.getFit(self.getActiveFit())
        defaultFile = "%s - %s.xml" % (fit.ship.item.name, fit.name) if fit else None

        dlg = wx.FileDialog(self, "Save Fitting As...",
                            wildcard="EVE XML fitting files (*.xml)|*.xml",
                            style=wx.FD_SAVE,
                            defaultFile=defaultFile)
        if dlg.ShowModal() == wx.ID_OK:
            self.supress_left_up = True
            format_ = dlg.GetFilterIndex()
            path = dlg.GetPath()
            if format_ == 0:
                output = Port.exportXml(None, fit)
                if '.' not in os.path.basename(path):
                    path += ".xml"
            else:
                print(("oops, invalid fit format %d" % format_))
                try:
                    dlg.Destroy()
                except RuntimeError:
                    pyfalog.error("Tried to destroy an object that doesn't exist in <showExportDialog>.")
                return

            with open(path, "w", encoding="utf-8") as openfile:
                openfile.write(output)
                openfile.close()

        try:
            dlg.Destroy()
        except RuntimeError:
            pyfalog.error("Tried to destroy an object that doesn't exist in <showExportDialog>.")
开发者ID:petosorus,项目名称:Pyfa,代码行数:34,代码来源:mainFrame.py

示例4: exportFitting

    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,代码行数:26,代码来源:crestFittings.py

示例5: importFitFromBuffer

 def importFitFromBuffer(self, bufferStr, activeFit=None):
     _, fits = Port.importAuto(bufferStr, activeFit=activeFit)
     for fit in fits:
         fit.character = self.character
         fit.damagePattern = self.pattern
         fit.targetResists = self.targetResists
         eos.db.save(fit)
     return fits
开发者ID:Bashta,项目名称:Pyfa,代码行数:8,代码来源:fit.py

示例6: importFitting

 def importFitting(self, event):
     selection = self.fitView.fitSelection
     if not selection:
         return
     data = self.fitTree.fittingsTreeCtrl.GetItemData(selection)
     sPort = Port.getInstance()
     import_type, fits = sPort.importFitFromBuffer(data)
     self.mainFrame._openAfterImport(fits)
开发者ID:blitzmann,项目名称:Pyfa,代码行数:8,代码来源:esiFittings.py

示例7: importFitFromFiles

    def importFitFromFiles(self, paths, callback=None):
        """
        Imports fits from file(s). First processes all provided paths and stores
        assembled fits into a list. This allows us to call back to the GUI as
        fits are processed as well as when fits are being saved.

        returns
        """
        defcodepage = locale.getpreferredencoding()

        fits = []
        for path in paths:
            if callback:  # Pulse
                wx.CallAfter(callback, "Processing file:\n%s"%path)

            file = open(path, "r")
            srcString = file.read()
            codec_found = None
            # If file had ANSI encoding, convert it to unicode using system
            # default codepage, or use fallbacks UTF-16, then cp1252 on any
            # encoding errors
            if isinstance(srcString, str):
                attempt_codecs = (defcodepage, "utf-16", "cp1252")
                for page in attempt_codecs:
                    try:
                        srcString = unicode(srcString, page)
                        codec_found = page
                    except UnicodeDecodeError:
                        logger.warn("Error unicode decoding %s from page %s, trying next codec", path, page)
                    else:
                        break
            else:
                # nasty hack to detect other transparent utf-16 loading
                if srcString[0] == '<' and 'utf-16' in srcString[:128].lower():
                    codec_found = "utf-16"
                else:
                    codec_found = "utf-8"

            _, fitsImport = Port.importAuto(srcString, path, callback=callback, encoding=codec_found)
            fits += fitsImport

        IDs = []
        numFits = len(fits)
        for i, fit in enumerate(fits):
            # Set some more fit attributes and save
            fit.character = self.character
            fit.damagePattern = self.pattern
            fit.targetResists = self.targetResists
            eos.db.save(fit)
            IDs.append(fit.ID)
            if callback:  # Pulse
                wx.CallAfter(
                    callback,
                    "Processing complete, saving fits to database\n(%d/%d)" %
                    (i+1, numFits)
                )

        return fits
开发者ID:Bashta,项目名称:Pyfa,代码行数:58,代码来源:fit.py

示例8: fileImportDialog

 def fileImportDialog(self, event):
     """Handles importing single/multiple EVE XML / EFT cfg fit files"""
     dlg = wx.FileDialog(
         self,
         "Open One Or More Fitting Files",
         wildcard=("EVE XML fitting files (*.xml)|*.xml|"
                   "EFT text fitting files (*.cfg)|*.cfg|"
                   "All Files (*)|*"),
         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE
     )
     if dlg.ShowModal() == wx.ID_OK:
         self.progressDialog = wx.ProgressDialog(
             "Importing fits",
             " " * 100,  # set some arbitrary spacing to create width in window
             parent=self,
             style=wx.PD_CAN_ABORT | wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_APP_MODAL
         )
         # self.progressDialog.message = None
         Port.importFitsThreaded(dlg.GetPaths(), self)
         self.progressDialog.ShowModal()
         try:
             dlg.Destroy()
         except RuntimeError:
             pyfalog.error("Tried to destroy an object that doesn't exist in <fileImportDialog>.")
开发者ID:petosorus,项目名称:Pyfa,代码行数:24,代码来源:mainFrame.py

示例9: test_import_xml

def test_import_xml(print_db_info):
    usr = PortUser()
# for path in XML_FILES:
    xml_file = "jeffy_ja-en[99].xml"
    fit_count = int(re.search(r"\[(\d+)\]", xml_file).group(1))
    fits = None
    with open(os.path.join(script_dir, xml_file), "r") as file_:
        srcString = file_.read()
        srcString = str(srcString, "utf-8")
        #  (basestring, IPortUser, basestring) -> list[eos.saveddata.fit.Fit]
        usr.on_port_process_start()
        #stpw.reset()
        #with stpw:
        fits = Port.importXml(srcString, usr)

        assert fits is not None and len(fits) is fit_count
开发者ID:Sectoid,项目名称:Pyfa,代码行数:16,代码来源:test_unread_desc.py

示例10: importFitFromFiles

    def importFitFromFiles(self, paths, callback=None):
        """
        Imports fits from file(s). First processes all provided paths and stores
        assembled fits into a list. This allows us to call back to the GUI as
        fits are processed as well as when fits are being saved.

        returns
        """
        defcodepage = locale.getpreferredencoding()

        fits = []
        for path in paths:
            if callback:  # Pulse
                wx.CallAfter(callback, "Processing file:\n%s"%path)

            file = open(path, "r")
            srcString = file.read()
            # If file had ANSI encoding, convert it to unicode using system
            # default codepage, or use fallback cp1252 on any encoding errors
            if isinstance(srcString, str):
                try:
                    srcString = unicode(srcString, defcodepage)
                except UnicodeDecodeError:
                    srcString = unicode(srcString, "cp1252")

            _, fitsImport = Port.importAuto(srcString, path, callback=callback)
            fits += fitsImport

        IDs = []
        numFits = len(fits)
        for i, fit in enumerate(fits):
            # Set some more fit attributes and save
            fit.character = self.character
            fit.damagePattern = self.pattern
            fit.targetResists = self.targetResists
            eos.db.save(fit)
            IDs.append(fit.ID)
            if callback:  # Pulse
                wx.CallAfter(
                    callback,
                    "Processing complete, saving fits to database\n(%d/%d)" %
                    (i+1, numFits)
                )

        return fits
开发者ID:ghettocruizer,项目名称:Pyfa,代码行数:45,代码来源:fit.py

示例11: importFit

    def importFit(self, path):
        filename = os.path.split(path)[1]

        defcodepage = locale.getpreferredencoding()

        file = open(path, "r")
        srcString = file.read()
        # If file had ANSI encoding, convert it to unicode using system
        # default codepage, or use fallback cp1252 on any encoding errors
        if isinstance(srcString, str):
            try:
                srcString = unicode(srcString, defcodepage)
            except UnicodeDecodeError:
                srcString = unicode(srcString, "cp1252")

        _, fits = Port.importAuto(srcString, filename)
        for fit in fits:
            fit.character = self.character
            fit.damagePattern = self.pattern
        return fits
开发者ID:SpeakerJunk,项目名称:Pyfa,代码行数:20,代码来源:fit.py

示例12: exportFitting

    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)
        sEsi = Esi.getInstance()

        sFit = Fit.getInstance()
        data = sPort.exportESI(sFit.getFit(fitID))
        res = sEsi.postFitting(self.getActiveCharacter(), data)

        try:
            res.raise_for_status()
            self.statusbar.SetStatusText("", 0)
            self.statusbar.SetStatusText(res.reason, 1)
        except requests.exceptions.ConnectionError:
            msg = "Connection error, please check your internet connection"
            pyfalog.error(msg)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText(msg, 1)
        except ESIExportException as ex:
            pyfalog.error(ex)
            self.statusbar.SetStatusText("ERROR", 0)
            self.statusbar.SetStatusText("{} - {}".format(res.status_code, res.reason), 1)
        except APIException as ex:
            try:
                ESIExceptionHandler(self, ex)
            except Exception as ex:
                self.statusbar.SetStatusText("ERROR", 0)
                self.statusbar.SetStatusText("{} - {}".format(res.status_code, res.reason), 1)
                pyfalog.error(ex)
开发者ID:blitzmann,项目名称:Pyfa,代码行数:37,代码来源:esiFittings.py

示例13: exportXml

 def exportXml(self, *fitIDs):
     fits = map(lambda fitID: eos.db.getFit(fitID), fitIDs)
     return Port.exportXml(*fits)
开发者ID:SpeakerJunk,项目名称:Pyfa,代码行数:3,代码来源:fit.py

示例14: exportDna

 def exportDna(self, fitID):
     fit = eos.db.getFit(fitID)
     return Port.exportDna(fit)
开发者ID:SpeakerJunk,项目名称:Pyfa,代码行数:3,代码来源:fit.py

示例15: exportEftImps

 def exportEftImps(self, fitID):
     fit = eos.db.getFit(fitID)
     return Port.exportEftImps(fit)
开发者ID:SpeakerJunk,项目名称:Pyfa,代码行数:3,代码来源:fit.py


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