diff --git a/eos/__init__.py b/eos/__init__.py
index 208d2b1df..f6e146b5f 100644
--- a/eos/__init__.py
+++ b/eos/__init__.py
@@ -1,6 +1,7 @@
version = "0.2.3"
tag = "git"
+
def test():
import tests.runTests
import unittest
diff --git a/eos/capSim.py b/eos/capSim.py
index c0211dde9..d57567ae6 100644
--- a/eos/capSim.py
+++ b/eos/capSim.py
@@ -1,12 +1,12 @@
import heapq
-from math import sqrt, exp
import time
-
+from math import sqrt, exp
DAY = 24 * 60 * 60 * 1000
-def lcm(a,b):
- n = a*b
+
+def lcm(a, b):
+ n = a * b
while b:
a, b = b, a % b
return n / a
@@ -40,20 +40,19 @@ class CapSimulator(object):
# relevant decimal digits of capacitor for LCM period optimization
self.stability_precision = 1
-
def scale_activation(self, duration, capNeed):
for res in self.scale_resolutions:
mod = duration % res
if mod:
- if mod > res/2.0:
- mod = res-mod
+ if mod > res / 2.0:
+ mod = res - mod
else:
mod = -mod
- if abs(mod) <= duration/100.0:
+ if abs(mod) <= duration / 100.0:
# only adjust if the adjustment is less than 1%
duration += mod
- capNeed += float(mod)/duration * capNeed
+ capNeed += float(mod) / duration * capNeed
break
return duration, capNeed
@@ -91,12 +90,12 @@ class CapSimulator(object):
for (duration, capNeed, clipSize, disableStagger), amount in mods.iteritems():
if self.stagger and not disableStagger:
if clipSize == 0:
- duration = int(duration/amount)
+ duration = int(duration / amount)
else:
- stagger_amount = (duration*clipSize+10000)/(amount*clipSize)
+ stagger_amount = (duration * clipSize + 10000) / (amount * clipSize)
for i in range(1, amount):
heapq.heappush(self.state,
- [i*stagger_amount, duration,
+ [i * stagger_amount, duration,
capNeed, 0, clipSize])
else:
capNeed *= amount
@@ -109,13 +108,11 @@ class CapSimulator(object):
heapq.heappush(self.state, [0, duration, capNeed, 0, clipSize])
-
if disable_period:
self.period = self.t_max
else:
self.period = period
-
def run(self):
"""Run the simulation"""
@@ -135,11 +132,11 @@ class CapSimulator(object):
capCapacity = self.capacitorCapacity
tau = self.capacitorRecharge / 5.0
- cap_wrap = capCapacity # cap value at last period
- cap_lowest = capCapacity # lowest cap value encountered
- cap_lowest_pre = capCapacity # lowest cap value before activations
- cap = capCapacity # current cap value
- t_wrap = self.period # point in time of next period
+ cap_wrap = capCapacity # cap value at last period
+ cap_lowest = capCapacity # lowest cap value encountered
+ cap_lowest_pre = capCapacity # lowest cap value before activations
+ cap = capCapacity # current cap value
+ t_wrap = self.period # point in time of next period
t_last = 0
t_max = self.t_max
@@ -150,7 +147,7 @@ class CapSimulator(object):
if t_now >= t_max:
break
- cap = ((1.0+(sqrt(cap/capCapacity)-1.0)*exp((t_last-t_now)/tau))**2)*capCapacity
+ cap = ((1.0 + (sqrt(cap / capCapacity) - 1.0) * exp((t_last - t_now) / tau)) ** 2) * capCapacity
if t_now != t_last:
if cap < cap_lowest_pre:
@@ -182,7 +179,7 @@ class CapSimulator(object):
if clipSize:
if shot % clipSize == 0:
shot = 0
- t_now += 10000 # include reload time
+ t_now += 10000 # include reload time
activation[0] = t_now
activation[3] = shot
@@ -195,19 +192,17 @@ class CapSimulator(object):
# calculate EVE's stability value
try:
- avgDrain = reduce(float.__add__, map(lambda x: x[2]/x[1], self.state), 0.0)
- self.cap_stable_eve = 0.25 * (1.0 + sqrt(-(2.0 * avgDrain * tau - capCapacity)/capCapacity)) ** 2
+ avgDrain = reduce(float.__add__, map(lambda x: x[2] / x[1], self.state), 0.0)
+ self.cap_stable_eve = 0.25 * (1.0 + sqrt(-(2.0 * avgDrain * tau - capCapacity) / capCapacity)) ** 2
except ValueError:
self.cap_stable_eve = 0.0
-
if cap > 0.0:
# capacitor low/high water marks
self.cap_stable_low = cap_lowest
self.cap_stable_high = cap_lowest_pre
else:
- self.cap_stable_low =\
- self.cap_stable_high = 0.0
+ self.cap_stable_low = \
+ self.cap_stable_high = 0.0
-
- self.runtime = time.time()-start
+ self.runtime = time.time() - start
diff --git a/eos/config.py b/eos/config.py
index 6e30afb03..63bf7695b 100644
--- a/eos/config.py
+++ b/eos/config.py
@@ -1,11 +1,13 @@
-from os.path import realpath, join, dirname, abspath
import sys
+from os.path import realpath, join, dirname, abspath
debug = False
gamedataCache = True
saveddataCache = True
-gamedata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "eve.db")), sys.getfilesystemencoding())
-saveddata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())
+gamedata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "eve.db")),
+ sys.getfilesystemencoding())
+saveddata_connectionstring = 'sqlite:///' + unicode(
+ realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())
-#Autodetect path, only change if the autodetection bugs out.
+# Autodetect path, only change if the autodetection bugs out.
path = dirname(unicode(__file__, sys.getfilesystemencoding()))
diff --git a/eos/effectHandlerHelpers.py b/eos/effectHandlerHelpers.py
index 75b51715d..2e42ef69f 100644
--- a/eos/effectHandlerHelpers.py
+++ b/eos/effectHandlerHelpers.py
@@ -1,4 +1,4 @@
-#===============================================================================
+# ===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of eos.
@@ -15,15 +15,17 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see .
-#===============================================================================
+# ===============================================================================
-#from sqlalchemy.orm.attributes import flag_modified
-import eos.db
-import eos.types
+# from sqlalchemy.orm.attributes import flag_modified
import logging
+import eos.db
+import eos.types
+
logger = logging.getLogger(__name__)
+
class HandledList(list):
def filteredItemPreAssign(self, filter, *args, **kwargs):
for element in self:
@@ -108,11 +110,12 @@ class HandledList(list):
def remove(self, thing):
# We must flag it as modified, otherwise it not be removed from the database
# @todo: flag_modified isn't in os x skel. need to rebuild to include
- #flag_modified(thing, "itemID")
+ # flag_modified(thing, "itemID")
if thing.isInvalid: # see GH issue #324
thing.itemID = 0
list.remove(self, thing)
+
class HandledModuleList(HandledList):
def append(self, mod):
emptyPosition = float("Inf")
@@ -169,11 +172,12 @@ class HandledModuleList(HandledList):
self[index] = mod
def freeSlot(self, slot):
- for i in range(len(self) -1, -1, -1):
+ for i in range(len(self) - 1, -1, -1):
mod = self[i]
if mod.getModifiedItemAttr("subSystemSlot") == slot:
del self[i]
+
class HandledDroneCargoList(HandledList):
def find(self, item):
for o in self:
@@ -190,6 +194,7 @@ class HandledDroneCargoList(HandledList):
if thing.isInvalid:
self.remove(thing)
+
class HandledImplantBoosterList(HandledList):
def append(self, thing):
if thing.isInvalid:
@@ -206,6 +211,7 @@ class HandledImplantBoosterList(HandledList):
HandledList.append(self, thing)
+
class HandledProjectedModList(HandledList):
def append(self, proj):
if proj.isInvalid:
@@ -232,6 +238,7 @@ class HandledProjectedModList(HandledList):
if not proj.item.isType("projected") and not isSystemEffect:
self.remove(proj)
+
class HandledProjectedDroneList(HandledDroneCargoList):
def append(self, proj):
proj.projected = True
@@ -241,6 +248,7 @@ class HandledProjectedDroneList(HandledDroneCargoList):
if proj.isInvalid or not proj.item.isType("projected"):
self.remove(proj)
+
class HandledItem(object):
def preAssignItemAttr(self, *args, **kwargs):
self.itemModifiedAttributes.preAssign(*args, **kwargs)
@@ -257,6 +265,7 @@ class HandledItem(object):
def forceItemAttr(self, *args, **kwargs):
self.itemModifiedAttributes.force(*args, **kwargs)
+
class HandledCharge(object):
def preAssignChargeAttr(self, *args, **kwargs):
self.chargeModifiedAttributes.preAssign(*args, **kwargs)
diff --git a/eos/eqBase.py b/eos/eqBase.py
index 072436642..95d063019 100644
--- a/eos/eqBase.py
+++ b/eos/eqBase.py
@@ -1,4 +1,4 @@
-#===============================================================================
+# ===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of eos.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see .
-#===============================================================================
+# ===============================================================================
class EqBase(object):
def __eq__(self, other):
@@ -25,4 +25,4 @@ class EqBase(object):
return type(self) != type(other) or self.ID != other.ID
def __hash__(self):
- return id(type(self)) + self.ID
\ No newline at end of file
+ return id(type(self)) + self.ID
diff --git a/eos/gamedata.py b/eos/gamedata.py
index fd2a15f70..febc59ac8 100644
--- a/eos/gamedata.py
+++ b/eos/gamedata.py
@@ -1,4 +1,4 @@
-#===============================================================================
+# ===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of eos.
@@ -15,22 +15,22 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see .
-#===============================================================================
+# ===============================================================================
import re
+import traceback
from sqlalchemy.orm import reconstructor
-from eqBase import EqBase
-
-import traceback
import eos.db
+from eqBase import EqBase
try:
from collections import OrderedDict
except ImportError:
from utils.compat import OrderedDict
+
class Effect(EqBase):
"""
The effect handling class, it is used to proxy and load effect handler code,
@@ -42,7 +42,7 @@ class Effect(EqBase):
@ivar description: The description of this effect, this is usualy pretty useless
@ivar published: Wether this effect is published or not, unpublished effects are typicaly unused.
"""
- #Filter to change names of effects to valid python method names
+ # Filter to change names of effects to valid python method names
nameFilter = re.compile("[^A-Za-z0-9]")
@reconstructor
@@ -159,10 +159,11 @@ class Effect(EqBase):
def effectDummy(*args, **kwargs):
pass
+
class Item(EqBase):
- MOVE_ATTRS = (4, # Mass
+ MOVE_ATTRS = (4, # Mass
38, # Capacity
- 161) # Volume
+ 161) # Volume
MOVE_ATTR_INFO = None
@@ -301,14 +302,14 @@ class Item(EqBase):
map = {1: "caldari",
2: "minmatar",
4: "amarr",
- 5: "sansha", # Caldari + Amarr
- 6: "blood", # Minmatar + Amarr
+ 5: "sansha", # Caldari + Amarr
+ 6: "blood", # Minmatar + Amarr
8: "gallente",
- 9: "guristas", # Caldari + Gallente
- 10: "angelserp", # Minmatar + Gallente, final race depends on the order of skills
- 12: "sisters", # Amarr + Gallente
+ 9: "guristas", # Caldari + Gallente
+ 10: "angelserp", # Minmatar + Gallente, final race depends on the order of skills
+ 12: "sisters", # Amarr + Gallente
16: "jove",
- 32: "sansha", # Incrusion Sansha
+ 32: "sansha", # Incrusion Sansha
128: "ore"}
# Race is None by default
race = None
@@ -329,7 +330,6 @@ class Item(EqBase):
self.__race = race
return self.__race
-
@property
def assistive(self):
"""Detects if item can be used as assistance"""
@@ -387,38 +387,49 @@ class Item(EqBase):
class MetaData(EqBase):
pass
+
class EffectInfo(EqBase):
pass
+
class AttributeInfo(EqBase):
pass
+
class Attribute(EqBase):
pass
+
class Category(EqBase):
pass
+
class Group(EqBase):
pass
+
class Icon(EqBase):
pass
+
class MarketGroup(EqBase):
def __repr__(self):
return u"MarketGroup(ID={}, name={}, parent={}) at {}".format(
self.ID, self.name, getattr(self.parent, "name", None), self.name, hex(id(self))
).encode('utf8')
+
class MetaGroup(EqBase):
pass
+
class MetaType(EqBase):
pass
+
class Unit(EqBase):
pass
+
class Traits(EqBase):
pass
diff --git a/eos/mathUtils.py b/eos/mathUtils.py
index c56e88cf3..5de12c60f 100644
--- a/eos/mathUtils.py
+++ b/eos/mathUtils.py
@@ -1,4 +1,4 @@
-#===============================================================================
+# ===============================================================================
# Copyright (C) 2010 Anton Vorobyov
#
# This file is part of eos.
@@ -15,10 +15,11 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see .
-#===============================================================================
+# ===============================================================================
import decimal
+
def floorFloat(value):
"""Round float down to integer"""
# We have to convert float to str to keep compatibility with
diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py
index dd2abcf7a..69ba2a01e 100644
--- a/eos/modifiedAttributeDict.py
+++ b/eos/modifiedAttributeDict.py
@@ -1,4 +1,4 @@
-#===============================================================================
+# ===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of eos.
@@ -15,14 +15,15 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see .
-#===============================================================================
+# ===============================================================================
-from math import exp
import collections
+from math import exp
defaultValuesCache = {}
cappingAttrKeyCache = {}
+
class ItemAttrShortcut(object):
def getModifiedItemAttr(self, key):
if key in self.itemModifiedAttributes:
@@ -30,6 +31,7 @@ class ItemAttrShortcut(object):
else:
return None
+
class ChargeAttrShortcut(object):
def getModifiedChargeAttr(self, key):
if key in self.chargeModifiedAttributes:
@@ -37,8 +39,8 @@ class ChargeAttrShortcut(object):
else:
return None
-class ModifiedAttributeDict(collections.MutableMapping):
+class ModifiedAttributeDict(collections.MutableMapping):
OVERRIDES = False
class CalculationPlaceholder():
@@ -130,7 +132,8 @@ class ModifiedAttributeDict(collections.MutableMapping):
return (key for key in all)
def __contains__(self, key):
- return (self.__original is not None and key in self.__original) or key in self.__modified or key in self.__intermediary
+ return (
+ self.__original is not None and key in self.__original) or key in self.__modified or key in self.__intermediary
def __placehold(self, key):
"""Create calculation placeholder in item's modified attribute dict"""
@@ -197,7 +200,8 @@ class ModifiedAttributeDict(collections.MutableMapping):
else:
dv = attrInfo.defaultValue
default = defaultValuesCache[key] = dv if dv is not None else 0.0
- val = self.__intermediary[key] if key in self.__intermediary else self.__preAssigns[key] if key in self.__preAssigns else self.getOriginal(key) if key in self.__original else default
+ val = self.__intermediary[key] if key in self.__intermediary else self.__preAssigns[
+ key] if key in self.__preAssigns else self.getOriginal(key) if key in self.__original else default
# We'll do stuff in the following order:
# preIncrease > multiplier > stacking penalized multipliers > postIncrease
@@ -354,6 +358,7 @@ class ModifiedAttributeDict(collections.MutableMapping):
self.__placehold(attributeName)
self.__afflict(attributeName, u"\u2263", value)
+
class Affliction():
def __init__(self, type, amount):
self.type = type
diff --git a/eos/types.py b/eos/types.py
index 12e7eb281..f11443d1f 100644
--- a/eos/types.py
+++ b/eos/types.py
@@ -1,4 +1,4 @@
-#===============================================================================
+# ===============================================================================
# Copyright (C) 2010 Diego Duclos
#
# This file is part of eos.
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with eos. If not, see .
-#===============================================================================
+# ===============================================================================
from eos.gamedata import Attribute, Category, Effect, Group, Icon, Item, MarketGroup, \
MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData, Traits