Move export logic from mainframe to export dialog, and introducing ui blocking for price optimization
This commit is contained in:
18674
eos/effects/all.py
Normal file
18674
eos/effects/all.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,10 @@ import wx
|
||||
from service.port.eft import EFT_OPTIONS
|
||||
from service.port.multibuy import MULTIBUY_OPTIONS
|
||||
from service.settings import SettingsProvider
|
||||
from service.port import EfsPort, Port
|
||||
from service.const import PortMultiBuyOptions
|
||||
from eos.db import getFit
|
||||
from gui.utils.clipboard import toClipboard
|
||||
|
||||
|
||||
class CopySelectDialog(wx.Dialog):
|
||||
@@ -39,6 +43,17 @@ class CopySelectDialog(wx.Dialog):
|
||||
def __init__(self, parent):
|
||||
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title="Select a format", size=(-1, -1),
|
||||
style=wx.DEFAULT_DIALOG_STYLE)
|
||||
|
||||
self.CopySelectDict = {
|
||||
CopySelectDialog.copyFormatEft : self.exportEft,
|
||||
CopySelectDialog.copyFormatXml : self.exportXml,
|
||||
CopySelectDialog.copyFormatDna : self.exportDna,
|
||||
CopySelectDialog.copyFormatEsi : self.exportEsi,
|
||||
CopySelectDialog.copyFormatMultiBuy: self.exportMultiBuy,
|
||||
CopySelectDialog.copyFormatEfs : self.exportEfs
|
||||
}
|
||||
|
||||
self.mainFrame = parent
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
self.copyFormats = OrderedDict((
|
||||
@@ -99,6 +114,29 @@ class CopySelectDialog(wx.Dialog):
|
||||
self.Fit()
|
||||
self.Center()
|
||||
|
||||
def Validate(self):
|
||||
selected = self.GetSelected()
|
||||
options = self.GetOptions()
|
||||
|
||||
settings = SettingsProvider.getInstance().getSettings("pyfaExport")
|
||||
settings["format"] = selected
|
||||
settings["options"] = options
|
||||
self.waitDialog = None
|
||||
|
||||
def cb(text):
|
||||
if self.waitDialog:
|
||||
del self.waitDialog
|
||||
q toClipboard(text)
|
||||
self.EndModal(wx.ID_OK)
|
||||
|
||||
export_options = options.get(selected)
|
||||
if selected == CopySelectDialog.copyFormatMultiBuy and export_options.get(PortMultiBuyOptions.OPTIMIZE_PRICES, False):
|
||||
self.waitDialog = wx.BusyInfo("Optimizing Prices", parent=self)
|
||||
|
||||
self.CopySelectDict[selected](export_options, callback=cb)
|
||||
|
||||
return False
|
||||
|
||||
def Selected(self, event):
|
||||
obj = event.GetEventObject()
|
||||
formatName = obj.GetLabel()
|
||||
@@ -119,3 +157,27 @@ class CopySelectDialog(wx.Dialog):
|
||||
for formatId in self.options:
|
||||
options[formatId] = {optId: ch.IsChecked() for optId, ch in self.options[formatId].items()}
|
||||
return options
|
||||
|
||||
def exportEft(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
Port.exportEft(fit, options, callback)
|
||||
|
||||
def exportDna(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
Port.exportDna(fit, callback)
|
||||
|
||||
def exportEsi(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
Port.exportESI(fit, callback)
|
||||
|
||||
def exportXml(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
Port.exportXml(None, fit, callback)
|
||||
|
||||
def exportMultiBuy(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
Port.exportMultiBuy(fit, options, callback)
|
||||
|
||||
def exportEfs(self, options, callback):
|
||||
fit = getFit(self.mainFrame.getActiveFit())
|
||||
EfsPort.exportEfs(fit, 0, callback)
|
||||
@@ -37,7 +37,6 @@ import config
|
||||
import gui.globalEvents as GE
|
||||
from eos.config import gamedata_date, gamedata_version
|
||||
from eos.db.saveddata.loadDefaultDatabaseValues import DefaultDatabaseValues
|
||||
from eos.db.saveddata.queries import getFit as db_getFit
|
||||
# import this to access override setting
|
||||
from eos.modifiedAttributeDict import ModifiedAttributeDict
|
||||
from gui import graphFrame
|
||||
@@ -64,11 +63,11 @@ from gui.setEditor import ImplantSetEditorDlg
|
||||
from gui.shipBrowser import ShipBrowser
|
||||
from gui.statsPane import StatsPane
|
||||
from gui.updateDialog import UpdateDialog
|
||||
from gui.utils.clipboard import fromClipboard, toClipboard
|
||||
from gui.utils.clipboard import fromClipboard
|
||||
from service.character import Character
|
||||
from service.esi import Esi
|
||||
from service.fit import Fit
|
||||
from service.port import EfsPort, IPortUser, Port
|
||||
from service.port import IPortUser, Port
|
||||
from service.price import Price
|
||||
from service.settings import HTMLExportSettings, SettingsProvider
|
||||
from service.update import Update
|
||||
@@ -708,30 +707,6 @@ class MainFrame(wx.Frame):
|
||||
else:
|
||||
self.marketBrowser.search.Focus()
|
||||
|
||||
def exportEft(self, options, callback):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
Port.exportEft(fit, options, callback)
|
||||
|
||||
def exportDna(self, options, callback):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
Port.exportDna(fit, callback)
|
||||
|
||||
def exportEsi(self, options, callback):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
Port.exportESI(fit, callback)
|
||||
|
||||
def exportXml(self, options, callback):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
Port.exportXml(None, fit, callback)
|
||||
|
||||
def exportMultiBuy(self, options, callback):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
Port.exportMultiBuy(fit, options, callback)
|
||||
|
||||
def exportEfs(self, options, callback):
|
||||
fit = db_getFit(self.getActiveFit())
|
||||
EfsPort.exportEfs(fit, 0, callback)
|
||||
|
||||
def importFromClipboard(self, event):
|
||||
clipboard = fromClipboard()
|
||||
activeFit = self.getActiveFit()
|
||||
@@ -748,36 +723,8 @@ class MainFrame(wx.Frame):
|
||||
self._openAfterImport(importData)
|
||||
|
||||
def exportToClipboard(self, event):
|
||||
CopySelectDict = {CopySelectDialog.copyFormatEft: self.exportEft,
|
||||
CopySelectDialog.copyFormatXml: self.exportXml,
|
||||
CopySelectDialog.copyFormatDna: self.exportDna,
|
||||
CopySelectDialog.copyFormatEsi: self.exportEsi,
|
||||
CopySelectDialog.copyFormatMultiBuy: self.exportMultiBuy,
|
||||
CopySelectDialog.copyFormatEfs: self.exportEfs}
|
||||
dlg = CopySelectDialog(self)
|
||||
btnPressed = dlg.ShowModal()
|
||||
|
||||
def killDialog():
|
||||
try:
|
||||
dlg.Destroy()
|
||||
except RuntimeError:
|
||||
pyfalog.error("Tried to destroy an object that doesn't exist in <exportToClipboard>.")
|
||||
|
||||
if btnPressed == wx.ID_OK:
|
||||
selected = dlg.GetSelected()
|
||||
options = dlg.GetOptions()
|
||||
|
||||
settings = SettingsProvider.getInstance().getSettings("pyfaExport")
|
||||
settings["format"] = selected
|
||||
settings["options"] = options
|
||||
|
||||
def cb(text):
|
||||
toClipboard(text)
|
||||
killDialog()
|
||||
|
||||
CopySelectDict[selected](options.get(selected), callback=cb)
|
||||
else:
|
||||
killDialog()
|
||||
with CopySelectDialog(self) as dlg:
|
||||
dlg.ShowModal()
|
||||
|
||||
def exportSkillsNeeded(self, event):
|
||||
""" Exports skills needed for active fit and active character """
|
||||
|
||||
100
scripts/effect_rename.py
Normal file
100
scripts/effect_rename.py
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python3
|
||||
#======================================================================
|
||||
# Copyright (C) 2010 Anton Vorobyov
|
||||
#
|
||||
# This file is part of eos.
|
||||
#
|
||||
# eos is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# eos is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||
#======================================================================
|
||||
"""
|
||||
Go through all effects and fill them with 'used by' comments.
|
||||
|
||||
There're several big stages:
|
||||
Stage 1. Gather all required data into 'global' dictionaries. We have
|
||||
2 dictionaries per grouping type, one which lists groups per typeid,
|
||||
and another which lists typeIDs per group.
|
||||
Stage 2. Cycle through each effect.
|
||||
Stage 2.1. Compose similar set of dictionaries like in stage 1, but
|
||||
this time we take into consideration typeIDs affected by effect picked
|
||||
in stage 2.
|
||||
Stage 2.2. Create several lists (1 per grouping type) which will keep
|
||||
IDs of these groups which will describe set of the typeIDs, and start
|
||||
iterating. Each iteration one ID will be appended to any of the lists.
|
||||
Stage 2.2.1. Compose score dictionaries per grouping type, and
|
||||
calculate total score for given grouping type.
|
||||
Stage 2.2.2. Pick grouping type with highest score, find winner group
|
||||
inside grouping type, append its ID to corresponding list created in
|
||||
stage 2.2. If score is less than certain value, stop iterating. If some
|
||||
items are not covered by set of winners from lists, they'll be
|
||||
presented as single items.
|
||||
Stage 2.3. Print results to file if anything has been changed.
|
||||
|
||||
Grouping types used are:
|
||||
Groups (groupID of an item);
|
||||
Categories (categoryID of groupID of an item);
|
||||
Base types (variations, like they appear on eve's variation tab);
|
||||
Market groups + variations (marketGroupID of an item, plus variations
|
||||
of all items from given market group, excluding items with
|
||||
marketGroupID).
|
||||
Type names (various combinations of words taken from typeName of item).
|
||||
"""
|
||||
|
||||
import copy
|
||||
import itertools
|
||||
import os.path
|
||||
import re
|
||||
import sqlite3
|
||||
from optparse import OptionParser
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
|
||||
# Form list of effects for processing
|
||||
effects_path = os.path.join(script_dir, "..", "eos", "effects")
|
||||
|
||||
usage = "usage: %prog --database=DB [--debug=DEBUG]"
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option("-d", "--database", help="path to eve cache data dump in \
|
||||
sqlite format, default to eve database file included in pyfa (../eve.db)",
|
||||
type="string", default=os.path.join(script_dir, "..", "eve.db"))
|
||||
parser.add_option("-e", "--effects", help="explicit comma-separated list of \
|
||||
effects to process", type="string", default="")
|
||||
parser.add_option("-r", "--remove", help="remove effect files that are not \
|
||||
used by any items", action="store_true", dest="remove", default=False)
|
||||
parser.add_option("-x", "--remove2", help="remove effect files that do not exist \
|
||||
in database", action="store_true", dest="remove2", default=False)
|
||||
parser.add_option("-u", "--debug", help="debug level, 0 by default",
|
||||
type="int", default=0)
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# Connect to database and set up cursor
|
||||
db = sqlite3.connect(os.path.expanduser(options.database))
|
||||
cursor = db.cursor()
|
||||
|
||||
QUERY_ALLEFFECTS = 'SELECT effectID, effectName FROM dgmeffects'
|
||||
|
||||
|
||||
# Compose list of effects w/o symbols which eos doesn't take into
|
||||
# consideration, we'll use it to find proper effect IDs from file
|
||||
# names
|
||||
globalmap_effectnameeos_effectid = {}
|
||||
globalmap_effectnameeos_effectnamedb = {}
|
||||
STRIPSPEC = "[^A-Za-z0-9]"
|
||||
cursor.execute(QUERY_ALLEFFECTS)
|
||||
for row in cursor:
|
||||
effectid = row[0]
|
||||
effectnamedb = row[1]
|
||||
effectnameeos = re.sub(STRIPSPEC, "", effectnamedb).lower()
|
||||
if(os.path.isfile(os.path.join('..', 'eos','effects',effectnameeos+'.py'))):
|
||||
os.rename(os.path.join('..', 'eos','effects',effectnameeos+'.py'), os.path.join('..', 'eos','effects','effect{}.py'.format(effectid)))
|
||||
# There may be different effects with the same name, so form
|
||||
Reference in New Issue
Block a user