Resolve 352 (Clean up root folder)

This commit is contained in:
DarkPhoenix
2010-12-18 13:34:51 +03:00
parent ab17c6d3c4
commit cede27f1b2
25 changed files with 26 additions and 26 deletions

25
gui/aboutData.py Normal file
View File

@@ -0,0 +1,25 @@
#===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
versionString = "1.0 Stable RC1 - INCURSION"
license = "pyfa is released under GNU GPL"
licenseLocation = "gpl.txt"
developers = ("\n cncfanatics \t(Sakari Orisi)\n" , " DarkPhoenix \t(Kadesh Priestess)\n", " Darriele \t(Darriele)")
credits = (("EVE SERVICE CORP \twww.evsco.net - host of EVEFIT project ( pyfa / EOS/ Aurora)"), ("Entity (Entity) \t\tCapacitor calculations / EVEAPI python lib / Reverence"), ("Aurora \t\tMaths"), ("Corollax (Aamrr) \tVarious EOS/pyfa improvements"))
description = "Pyfa (the Python Fitting Assistant) is a standalone application able to create and simulate fittings for EVE-Online SciFi MMORPG with a very high degree of accuracy.\nPyfa can be virtually ran on all platforms where python and wxwidgets are supported, and, in order to make things effortless for you, we maintain daily builds for OSX/WIN32(64) and LINUX (http://www.evefit.org/Pyfa/Installation). The layout of pyfa is somewhat similar to EFT ( EVE fitting tool ), but , it goes way beyond EFT in terms of functionality, accuracy and usefulness. While Pyfa is a completely new application unrelated to EFT, it is able to import/export EFT style fits without any hassle.\n\n\nAll EVE-Online related materials are property of CCP hf.\n\nSilk Icons Set by famfamfam.com released under Creative Commons Attribution 2.5 License"

View File

@@ -18,14 +18,14 @@
#===============================================================================
import os.path
import config
from gui import config
import wx
import time
try:
from collections import OrderedDict
except ImportError:
from compat import OrderedDict
from gui.compat import OrderedDict
cachedBitmapsCount = 0
cachedBitmaps = OrderedDict()

View File

@@ -21,7 +21,7 @@ import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from util import formatAmount
from gui.util import formatAmount
class CapacitorViewFull(StatsView):
name = "capacitorViewFull"

View File

@@ -21,7 +21,7 @@ import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from util import formatAmount
from gui.util import formatAmount
class FirepowerViewFull(StatsView):
name = "firepowerViewFull"

View File

@@ -21,7 +21,7 @@ import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from util import formatAmount
from gui.util import formatAmount
import service
class PriceViewFull(StatsView):

View File

@@ -20,7 +20,7 @@
import wx
from gui.statsView import StatsView
from gui import bitmapLoader
from util import formatAmount
from gui.util import formatAmount
import gui.mainFrame
import gui.builtinStatsViews.resistancesViewFull as rvf
import service

View File

@@ -22,7 +22,7 @@ from gui.statsView import StatsView
from gui import builtinStatsViews
from gui import bitmapLoader
from gui import pygauge as PG
from util import formatAmount
from gui.util import formatAmount
import service
import gui.mainFrame
import gui.builtinViews.fittingView as fv

View File

@@ -25,7 +25,7 @@ from gui import pygauge as PG
from eos.types import Hardpoint
from util import formatAmount
from gui.util import formatAmount
class ResourcesViewFull(StatsView):
name = "resourcesViewFull"

View File

@@ -20,7 +20,7 @@
import wx
from gui.statsView import StatsView
from gui import builtinStatsViews
from util import formatAmount
from gui.util import formatAmount
class TargetingMiscViewFull(StatsView):
name = "targetingmiscViewFull"
@@ -132,7 +132,7 @@ class TargetingMiscViewFull(StatsView):
elif labelName is "labelFullSigRadius":
label.SetToolTip(wx.ToolTip("Probe Size: %.3f" % (fit.probeSize or 0) ))
elif labelName is "labelFullWarpSpeed":
label.SetToolTip(wx.ToolTip("Max Warp Distance: %.1f AU" %
label.SetToolTip(wx.ToolTip("Max Warp Distance: %.1f AU" %
fit.maxWarpDistance))
elif fit is not None:
label.SetToolTip(wx.ToolTip("%.1f" % value))

View File

@@ -21,7 +21,7 @@ from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
import service
from util import formatAmount
from gui.util import formatAmount
import wx
class AttributeDisplay(ViewColumn):

View File

@@ -20,7 +20,7 @@
import wx
import service
from util import formatAmount
from gui.util import formatAmount
from gui.viewColumn import ViewColumn
from gui import bitmapLoader

View File

@@ -21,7 +21,7 @@ from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
import service
from util import formatAmount
from gui.util import formatAmount
import wx
class MaxRange(ViewColumn):

View File

@@ -20,7 +20,7 @@
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
import service
from util import formatAmount
from gui.util import formatAmount
import wx
class Price(ViewColumn):

View File

@@ -20,7 +20,7 @@
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
import service
from util import formatAmount
from gui.util import formatAmount
import wx
class PropertyDisplay(ViewColumn):

View File

@@ -21,7 +21,7 @@ from gui import builtinViewColumns
from gui.viewColumn import ViewColumn
from gui import bitmapLoader
import service
from util import formatAmount
from gui.util import formatAmount
from eos.types import Hardpoint
import wx

102
gui/compat.py Normal file
View File

@@ -0,0 +1,102 @@
## {{{ http://code.activestate.com/recipes/576693/ (r6)
from UserDict import DictMixin
class OrderedDict(dict, DictMixin):
def __init__(self, *args, **kwds):
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
self.__end
except AttributeError:
self.clear()
self.update(*args, **kwds)
def clear(self):
self.__end = end = []
end += [None, end, end] # sentinel node for doubly linked list
self.__map = {} # key --> [key, prev, next]
dict.clear(self)
def __setitem__(self, key, value):
if key not in self:
end = self.__end
curr = end[1]
curr[2] = end[1] = self.__map[key] = [key, curr, end]
dict.__setitem__(self, key, value)
def __delitem__(self, key):
dict.__delitem__(self, key)
key, prev, next = self.__map.pop(key)
prev[2] = next
next[1] = prev
def __iter__(self):
end = self.__end
curr = end[2]
while curr is not end:
yield curr[0]
curr = curr[2]
def __reversed__(self):
end = self.__end
curr = end[1]
while curr is not end:
yield curr[0]
curr = curr[1]
def popitem(self, last=True):
if not self:
raise KeyError('dictionary is empty')
if last:
key = reversed(self).next()
else:
key = iter(self).next()
value = self.pop(key)
return key, value
def __reduce__(self):
items = [[k, self[k]] for k in self]
tmp = self.__map, self.__end
del self.__map, self.__end
inst_dict = vars(self).copy()
self.__map, self.__end = tmp
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def keys(self):
return list(self)
setdefault = DictMixin.setdefault
update = DictMixin.update
pop = DictMixin.pop
values = DictMixin.values
items = DictMixin.items
iterkeys = DictMixin.iterkeys
itervalues = DictMixin.itervalues
iteritems = DictMixin.iteritems
def __repr__(self):
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
def copy(self):
return self.__class__(self)
@classmethod
def fromkeys(cls, iterable, value=None):
d = cls()
for key in iterable:
d[key] = value
return d
def __eq__(self, other):
if isinstance(other, OrderedDict):
return len(self)==len(other) and self.items() == other.items()
return dict.__eq__(self, other)
def __ne__(self, other):
return not self == other
## end of http://code.activestate.com/recipes/576693/ }}}

35
gui/config.py Normal file
View File

@@ -0,0 +1,35 @@
import os
import sys
# Turns on debug mode
debug = False
# You can adjust these paths to your needs
# The main pyfa directory which contains run.py
# python 2.X uses ansi by default, so we need to convert the character encoding :(
pyfaPath = unicode(os.path.dirname(os.path.abspath(sys.modules['__main__'].__file__)),
sys.getfilesystemencoding())
# Where we store the saved fits etc, default is the current users home directory
savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")),
sys.getfilesystemencoding())
# Static EVE Data from the staticdata repository, should be in the staticdata directory in our pyfa directory
staticPath = os.path.join(pyfaPath, "staticdata")
# The database where we store all the fits etc
saveDB = os.path.join(savePath, "saveddata.db")
# The database where the static EVE data from the datadump is kept.
# WARNING: This is not the standard sqlite datadump but a modified version for EOS
gameDB = os.path.join(staticPath, "eve.db")
## DON'T MODIFY ANYTHING BELOW ##
import eos.config
#Caching modifiers, disable all gamedata caching, its unneeded.
eos.config.gamedataCache = None
# saveddata db location modifier, shouldn't ever need to touch this
eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False"
eos.config.gamedata_connectionstring = "sqlite:///" + gameDB + "?check_same_thread=False"

View File

@@ -4,7 +4,7 @@ from gui import bitmapLoader
import gui.mainFrame
from gui.PFListPane import PFListPane
import service.fleet
from util import GetPartialText
from gui.util import GetPartialText
from wx.lib.buttons import GenBitmapButton
@@ -572,4 +572,4 @@ class PFGenBitmapButton(GenBitmapButton):
self.bgcolor = wx.Brush(color)
def GetBackgroundBrush(self, dc):
return self.bgcolor
return self.bgcolor

View File

@@ -25,7 +25,7 @@ import sys
import wx.lib.mixins.listctrl as listmix
import wx.html
from eos.types import Ship, Module, Skill, Booster, Implant, Drone
from util import formatAmount
from gui.util import formatAmount
import service
class ItemStatsDialog(wx.Dialog):

View File

@@ -19,7 +19,7 @@
import wx
import service
import config
from gui import config
from gui import bitmapLoader
from gui.mainMenuBar import MainMenuBar
from gui.additionsPane import AdditionsPane
@@ -34,11 +34,11 @@ from gui.patternEditor import DmgPatternEditorDlg
from gui.preferenceDialog import PreferenceDialog
from gui.graphFrame import GraphFrame
from gui.copySelectDialog import CopySelectDialog
import aboutData
from gui import aboutData
from wx._core import PyDeadObjectError
import os.path
import gui.chromeTabs
from util import toClipboard, fromClipboard
from gui.util import toClipboard, fromClipboard
from builtinViews import *
from gui.fleetBrowser import FleetBrowser

View File

@@ -18,7 +18,7 @@
#===============================================================================
import wx
import config
from gui import config
import bitmapLoader
import gui.mainFrame
import gui.graphFrame

View File

@@ -21,7 +21,7 @@ import wx
import bitmapLoader
import service
from wx.lib.intctrl import IntCtrl
from util import toClipboard, fromClipboard
from gui.util import toClipboard, fromClipboard
###########################################################################
## Class DmgPatternEditorDlg

122
gui/util.py Normal file
View File

@@ -0,0 +1,122 @@
import math
import wx
def formatAmount(val, prec=3, lowest=0, highest=0):
"""
Add suffix to value, transform value to match new suffix and round it.
Keyword arguments:
val -- value to process
prec -- precision of final number (number of significant positions to show)
lowest -- lowest order for suffixizing
highest -- highest order for suffixizing
"""
if val is None:
result = ""
else:
# Separate value to mantissa and suffix
mantissa, suffix = suffixizeAmount(val, lowest, highest)
# Round mantissa and add suffix
newMantissa = processAmount(mantissa, prec)
result = u"{0}{1}".format(newMantissa, suffix)
return result
def suffixizeAmount(val, lowest=-6, highest=9):
"""
Add suffix to value and transform value to match new suffix.
Keyword arguments:
val -- value to process
lowest -- lowest order for suffixizing
highest -- highest order for suffixizing
Suffixes below lowest and above highest orders won't be used.
"""
if abs(val) >= 1000 and highest >= 3:
suffixmap = {3 : "k", 6 : "M", 9 : "B"}
# Start from highest possible suffix
for key in sorted(suffixmap, reverse = True):
# Find first suitable suffix and check if it's not above highest order
if val >= 10**key and key <= highest:
return val/float(10**key), suffixmap[key]
# Take numbers between 0 and 1, and matching/below highest possible negative suffix
elif abs(val) < 1 and val != 0 and lowest <= -3:
suffixmap = {-6 : u'\u03bc', -3 : "m"}
# Start from lowest possible suffix
for key in sorted(suffixmap, reverse = False):
# Check if mantissa with next suffix is in range [1, 1000)
# Here we assume that each next order is greater than previous by 3
if val < 10**(key+3) and key >= lowest:
return val/float(10**key), suffixmap[key]
# If no suitable suffixes are found within given order borders, or value
# is already within [1, 1000) boundaries, just return rounded value with no suffix
else:
return val, ""
def processAmount(val, prec=3):
"""
Round number and return as string.
Keyword arguments:
val -- value to round
prec -- precision of final number (number of significant positions to show)
Integer numbers are not rounded, only fractional part.
"""
if val == 0: # Logarithm is not defined for zero
return "0"
roundFactor = int(prec - math.ceil(math.log10(abs(val))))
# But we don't want to round integers
if roundFactor < 0: roundFactor = 0
val = round(val, roundFactor)
# Strip trailing zero for integers and convert to string
result = str(val)[-2:] == '.0' and str(val)[:-2] or str(val)
return result
def toClipboard(text):
clip = wx.TheClipboard
clip.Open()
data = wx.TextDataObject(text)
clip.SetData(data)
clip.Close()
def fromClipboard():
clip = wx.TheClipboard
clip.Open()
data = wx.TextDataObject("")
if clip.GetData(data):
clip.Close()
return data.GetText()
else:
clip.Close()
return None
def GetPartialText(dc, text , maxWidth):
ellipsis = "..."
base_w, h = dc.GetTextExtent(ellipsis)
lenText = len(text)
drawntext = text
w, dummy = dc.GetTextExtent(text)
while lenText > 1:
if w + base_w <= maxWidth:
break
w_c, h_c = dc.GetTextExtent(drawntext[-1])
drawntext = drawntext[0:-1]
lenText -= 1
w -= w_c
while len(ellipsis) > 0 and w + base_w > maxWidth:
ellipsis = ellipsis[0:-1]
base_w, h = dc.GetTextExtent(ellipsis)
if len(text) > lenText:
return drawntext + ellipsis
else:
return text