py2to3 automatic conversion. Woot!
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import heapq
|
||||
import time
|
||||
from math import sqrt, exp
|
||||
from functools import reduce
|
||||
|
||||
DAY = 24 * 60 * 60 * 1000
|
||||
|
||||
@@ -87,7 +88,7 @@ class CapSimulator(object):
|
||||
mods[(duration, capNeed, clipSize, disableStagger)] = 1
|
||||
|
||||
# Loop over grouped modules, configure staggering and push to the simulation state
|
||||
for (duration, capNeed, clipSize, disableStagger), amount in mods.iteritems():
|
||||
for (duration, capNeed, clipSize, disableStagger), amount in mods.items():
|
||||
if self.stagger and not disableStagger:
|
||||
if clipSize == 0:
|
||||
duration = int(duration / amount)
|
||||
@@ -192,7 +193,7 @@ class CapSimulator(object):
|
||||
|
||||
# calculate EVE's stability value
|
||||
try:
|
||||
avgDrain = reduce(float.__add__, map(lambda x: x[2] / x[1], self.state), 0.0)
|
||||
avgDrain = reduce(float.__add__, [x[2] / x[1] for x in 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
|
||||
|
||||
@@ -11,14 +11,14 @@ debug = False
|
||||
gamedataCache = True
|
||||
saveddataCache = True
|
||||
gamedata_version = ""
|
||||
gamedata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "eve.db")), sys.getfilesystemencoding())
|
||||
gamedata_connectionstring = 'sqlite:///' + str(realpath(join(dirname(abspath(__file__)), "..", "eve.db")), sys.getfilesystemencoding())
|
||||
pyfalog.debug("Gamedata connection string: {0}", gamedata_connectionstring)
|
||||
|
||||
if istravis is True or hasattr(sys, '_called_from_test'):
|
||||
# Running in Travis. Run saveddata database in memory.
|
||||
saveddata_connectionstring = 'sqlite:///:memory:'
|
||||
else:
|
||||
saveddata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())
|
||||
saveddata_connectionstring = 'sqlite:///' + str(realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())
|
||||
|
||||
pyfalog.debug("Saveddata connection string: {0}", saveddata_connectionstring)
|
||||
|
||||
@@ -28,4 +28,4 @@ settings = {
|
||||
}
|
||||
|
||||
# Autodetect path, only change if the autodetection bugs out.
|
||||
path = dirname(unicode(__file__, sys.getfilesystemencoding()))
|
||||
path = dirname(str(__file__, sys.getfilesystemencoding()))
|
||||
|
||||
@@ -22,7 +22,7 @@ import threading
|
||||
from sqlalchemy import MetaData, create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
import migration
|
||||
from . import migration
|
||||
from eos import config
|
||||
from logbook import Logger
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ def getItem(lookfor, eager=None):
|
||||
item = gamedata_session.query(Item).get(lookfor)
|
||||
else:
|
||||
item = gamedata_session.query(Item).options(*processEager(eager)).filter(Item.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
if lookfor in itemNameMap:
|
||||
id = itemNameMap[lookfor]
|
||||
if eager is None:
|
||||
@@ -154,7 +154,7 @@ def getGroup(lookfor, eager=None):
|
||||
group = gamedata_session.query(Group).get(lookfor)
|
||||
else:
|
||||
group = gamedata_session.query(Group).options(*processEager(eager)).filter(Group.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
if lookfor in groupNameMap:
|
||||
id = groupNameMap[lookfor]
|
||||
if eager is None:
|
||||
@@ -181,7 +181,7 @@ def getCategory(lookfor, eager=None):
|
||||
else:
|
||||
category = gamedata_session.query(Category).options(*processEager(eager)).filter(
|
||||
Category.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
if lookfor in categoryNameMap:
|
||||
id = categoryNameMap[lookfor]
|
||||
if eager is None:
|
||||
@@ -210,7 +210,7 @@ def getMetaGroup(lookfor, eager=None):
|
||||
else:
|
||||
metaGroup = gamedata_session.query(MetaGroup).options(*processEager(eager)).filter(
|
||||
MetaGroup.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
if lookfor in metaGroupNameMap:
|
||||
id = metaGroupNameMap[lookfor]
|
||||
if eager is None:
|
||||
@@ -245,7 +245,7 @@ def getMarketGroup(lookfor, eager=None):
|
||||
def getItemsByCategory(filter, where=None, eager=None):
|
||||
if isinstance(filter, int):
|
||||
filter = Category.ID == filter
|
||||
elif isinstance(filter, basestring):
|
||||
elif isinstance(filter, str):
|
||||
filter = Category.name == filter
|
||||
else:
|
||||
raise TypeError("Need integer or string as argument")
|
||||
@@ -257,7 +257,7 @@ def getItemsByCategory(filter, where=None, eager=None):
|
||||
|
||||
@cachedQuery(3, "where", "nameLike", "join")
|
||||
def searchItems(nameLike, where=None, join=None, eager=None):
|
||||
if not isinstance(nameLike, basestring):
|
||||
if not isinstance(nameLike, str):
|
||||
raise TypeError("Need string as argument")
|
||||
|
||||
if join is None:
|
||||
@@ -268,7 +268,7 @@ def searchItems(nameLike, where=None, join=None, eager=None):
|
||||
|
||||
items = gamedata_session.query(Item).options(*processEager(eager)).join(*join)
|
||||
for token in nameLike.split(' '):
|
||||
token_safe = u"%{0}%".format(sqlizeString(token))
|
||||
token_safe = "%{0}%".format(sqlizeString(token))
|
||||
if where is not None:
|
||||
items = items.filter(and_(Item.name.like(token_safe, escape="\\"), where))
|
||||
else:
|
||||
@@ -279,12 +279,12 @@ def searchItems(nameLike, where=None, join=None, eager=None):
|
||||
|
||||
@cachedQuery(3, "where", "nameLike", "join")
|
||||
def searchSkills(nameLike, where=None, eager=None):
|
||||
if not isinstance(nameLike, basestring):
|
||||
if not isinstance(nameLike, str):
|
||||
raise TypeError("Need string as argument")
|
||||
|
||||
items = gamedata_session.query(Item).options(*processEager(eager)).join(Item.group, Group.category)
|
||||
for token in nameLike.split(' '):
|
||||
token_safe = u"%{0}%".format(sqlizeString(token))
|
||||
token_safe = "%{0}%".format(sqlizeString(token))
|
||||
if where is not None:
|
||||
items = items.filter(and_(Item.name.like(token_safe, escape="\\"), Category.ID == 16, where))
|
||||
else:
|
||||
@@ -322,7 +322,7 @@ def getVariations(itemids, groupIDs=None, where=None, eager=None):
|
||||
|
||||
@cachedQuery(1, "attr")
|
||||
def getAttributeInfo(attr, eager=None):
|
||||
if isinstance(attr, basestring):
|
||||
if isinstance(attr, str):
|
||||
filter = AttributeInfo.name == attr
|
||||
elif isinstance(attr, int):
|
||||
filter = AttributeInfo.ID == attr
|
||||
@@ -337,7 +337,7 @@ def getAttributeInfo(attr, eager=None):
|
||||
|
||||
@cachedQuery(1, "field")
|
||||
def getMetaData(field):
|
||||
if isinstance(field, basestring):
|
||||
if isinstance(field, str):
|
||||
data = gamedata_session.query(MetaData).get(field)
|
||||
else:
|
||||
raise TypeError("Need string as argument")
|
||||
@@ -367,7 +367,7 @@ def getRequiredFor(itemID, attrMapping):
|
||||
|
||||
skillToLevelClauses = []
|
||||
|
||||
for attrSkill, attrLevel in attrMapping.iteritems():
|
||||
for attrSkill, attrLevel in attrMapping.items():
|
||||
skillToLevelClauses.append(and_(Attribute1.attributeID == attrSkill, Attribute2.attributeID == attrLevel))
|
||||
|
||||
queryOr = or_(*skillToLevelClauses)
|
||||
|
||||
@@ -3,7 +3,7 @@ import shutil
|
||||
import time
|
||||
|
||||
import config
|
||||
import migrations
|
||||
from . import migrations
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
@@ -34,7 +34,7 @@ def update(saveddata_engine):
|
||||
|
||||
shutil.copyfile(config.saveDB, toFile)
|
||||
|
||||
for version in xrange(dbVersion, appVersion):
|
||||
for version in range(dbVersion, appVersion):
|
||||
func = migrations.updates[version + 1]
|
||||
if func:
|
||||
pyfalog.info("Applying database update: {0}", version + 1)
|
||||
|
||||
@@ -91,7 +91,7 @@ def upgrade(saveddata_engine):
|
||||
saveddata_engine.execute("ALTER TABLE fits ADD COLUMN targetResistsID INTEGER;")
|
||||
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for replacement_item, list in CONVERSIONS.items():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -108,7 +108,7 @@ CONVERSIONS = {
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for replacement_item, list in CONVERSIONS.items():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -332,7 +332,7 @@ CONVERSIONS = {
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for replacement_item, list in CONVERSIONS.items():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -60,7 +60,7 @@ CONVERSIONS = {
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for replacement_item, list in CONVERSIONS.items():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -29,7 +29,7 @@ def upgrade(saveddata_engine):
|
||||
"targetResists": 2
|
||||
}
|
||||
|
||||
for table in tables.keys():
|
||||
for table in list(tables.keys()):
|
||||
|
||||
# midnight brain, there's probably a much more simple way to do this, but fuck it
|
||||
if tables[table] > 0:
|
||||
|
||||
@@ -133,7 +133,7 @@ CONVERSIONS = {
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for replacement_item, list in CONVERSIONS.items():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -17,7 +17,7 @@ CONVERSIONS = {
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert ships
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for replacement_item, list in CONVERSIONS.items():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "fits" SET "shipID" = ? WHERE "shipID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -77,7 +77,7 @@ CONVERSIONS = {
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for replacement_item, list in CONVERSIONS.items():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -109,9 +109,9 @@ if configVal is True:
|
||||
if type not in queryCache:
|
||||
return
|
||||
functionCache = queryCache[type]
|
||||
for _, localCache in functionCache.iteritems():
|
||||
for _, localCache in functionCache.items():
|
||||
toDelete = set()
|
||||
for cacheKey, info in localCache.iteritems():
|
||||
for cacheKey, info in localCache.items():
|
||||
IDs = info[1]
|
||||
if ID in IDs:
|
||||
toDelete.add(cacheKey)
|
||||
@@ -156,7 +156,7 @@ def getUser(lookfor, eager=None):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
user = saveddata_session.query(User).options(*eager).filter(User.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
user = saveddata_session.query(User).options(*eager).filter(User.username == lookfor).first()
|
||||
@@ -175,7 +175,7 @@ def getCharacter(lookfor, eager=None):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
character = saveddata_session.query(Character).options(*eager).filter(Character.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
character = saveddata_session.query(Character).options(*eager).filter(
|
||||
@@ -337,7 +337,7 @@ def clearPrices():
|
||||
|
||||
|
||||
def getMiscData(field):
|
||||
if isinstance(field, basestring):
|
||||
if isinstance(field, str):
|
||||
with sd_lock:
|
||||
data = saveddata_session.query(MiscData).get(field)
|
||||
else:
|
||||
@@ -391,7 +391,7 @@ def getDamagePattern(lookfor, eager=None):
|
||||
with sd_lock:
|
||||
pattern = saveddata_session.query(DamagePattern).options(*eager).filter(
|
||||
DamagePattern.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
pattern = saveddata_session.query(DamagePattern).options(*eager).filter(
|
||||
@@ -412,7 +412,7 @@ def getTargetResists(lookfor, eager=None):
|
||||
with sd_lock:
|
||||
pattern = saveddata_session.query(TargetResists).options(*eager).filter(
|
||||
TargetResists.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
pattern = saveddata_session.query(TargetResists).options(*eager).filter(
|
||||
@@ -433,7 +433,7 @@ def getImplantSet(lookfor, eager=None):
|
||||
with sd_lock:
|
||||
pattern = saveddata_session.query(ImplantSet).options(*eager).filter(
|
||||
TargetResists.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.name == lookfor).first()
|
||||
@@ -443,10 +443,10 @@ def getImplantSet(lookfor, eager=None):
|
||||
|
||||
|
||||
def searchFits(nameLike, where=None, eager=None):
|
||||
if not isinstance(nameLike, basestring):
|
||||
if not isinstance(nameLike, str):
|
||||
raise TypeError("Need string as argument")
|
||||
# Prepare our string for request
|
||||
nameLike = u"%{0}%".format(sqlizeString(nameLike))
|
||||
nameLike = "%{0}%".format(sqlizeString(nameLike))
|
||||
|
||||
# Add any extra components to the search to our where clause
|
||||
filter = processWhere(Fit.name.like(nameLike, escape="\\"), where)
|
||||
@@ -484,7 +484,7 @@ def getCrestCharacter(lookfor, eager=None):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.ID == lookfor).first()
|
||||
elif isinstance(lookfor, basestring):
|
||||
elif isinstance(lookfor, str):
|
||||
eager = processEager(eager)
|
||||
with sd_lock:
|
||||
character = saveddata_session.query(CrestChar).options(*eager).filter(CrestChar.name == lookfor).first()
|
||||
@@ -515,8 +515,8 @@ def removeInvalid(fits):
|
||||
invalids = [f for f in fits if f.isInvalid]
|
||||
|
||||
if invalids:
|
||||
map(fits.remove, invalids)
|
||||
map(saveddata_session.delete, invalids)
|
||||
list(map(fits.remove, invalids))
|
||||
list(map(saveddata_session.delete, invalids))
|
||||
saveddata_session.commit()
|
||||
|
||||
return fits
|
||||
@@ -547,4 +547,4 @@ def commit():
|
||||
except Exception:
|
||||
saveddata_session.rollback()
|
||||
exc_info = sys.exc_info()
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
|
||||
|
||||
@@ -39,7 +39,7 @@ def processEager(eager):
|
||||
return tuple()
|
||||
else:
|
||||
l = []
|
||||
if isinstance(eager, basestring):
|
||||
if isinstance(eager, str):
|
||||
eager = (eager,)
|
||||
|
||||
for e in eager:
|
||||
@@ -50,7 +50,7 @@ def processEager(eager):
|
||||
|
||||
def _replacements(eagerString):
|
||||
splitEager = eagerString.split(".")
|
||||
for i in xrange(len(splitEager)):
|
||||
for i in range(len(splitEager)):
|
||||
part = splitEager[i]
|
||||
replacement = replace.get(part)
|
||||
if replacement:
|
||||
|
||||
@@ -26,7 +26,7 @@ class HandledList(list):
|
||||
def filteredItemPreAssign(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.preAssignItemAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -34,7 +34,7 @@ class HandledList(list):
|
||||
def filteredItemIncrease(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.increaseItemAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -42,7 +42,7 @@ class HandledList(list):
|
||||
def filteredItemMultiply(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.multiplyItemAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -50,7 +50,7 @@ class HandledList(list):
|
||||
def filteredItemBoost(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.boostItemAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -58,7 +58,7 @@ class HandledList(list):
|
||||
def filteredItemForce(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.forceItemAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -66,7 +66,7 @@ class HandledList(list):
|
||||
def filteredChargePreAssign(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.preAssignChargeAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -74,7 +74,7 @@ class HandledList(list):
|
||||
def filteredChargeIncrease(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.increaseChargeAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -82,7 +82,7 @@ class HandledList(list):
|
||||
def filteredChargeMultiply(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.multiplyChargeAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -90,7 +90,7 @@ class HandledList(list):
|
||||
def filteredChargeBoost(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.boostChargeAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -98,7 +98,7 @@ class HandledList(list):
|
||||
def filteredChargeForce(self, filter, *args, **kwargs):
|
||||
for element in self:
|
||||
try:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.forceChargeAttr(*args, **kwargs)
|
||||
except AttributeError:
|
||||
pass
|
||||
@@ -115,7 +115,7 @@ class HandledList(list):
|
||||
class HandledModuleList(HandledList):
|
||||
def append(self, mod):
|
||||
emptyPosition = float("Inf")
|
||||
for i in xrange(len(self)):
|
||||
for i in range(len(self)):
|
||||
currMod = self[i]
|
||||
if currMod.isEmpty and not mod.isEmpty and currMod.slot == mod.slot:
|
||||
currPos = mod.position or i
|
||||
@@ -149,7 +149,7 @@ class HandledModuleList(HandledList):
|
||||
oldPos = mod.position
|
||||
|
||||
mod.position = None
|
||||
for i in xrange(oldPos, len(self)):
|
||||
for i in range(oldPos, len(self)):
|
||||
self[i].position -= 1
|
||||
|
||||
def toDummy(self, index):
|
||||
|
||||
@@ -6,6 +6,6 @@ type = "active"
|
||||
|
||||
|
||||
def handler(fit, module, context):
|
||||
for x in xrange(1, 4):
|
||||
for x in range(1, 4):
|
||||
value = module.getModifiedChargeAttr("warfareBuff{}Multiplier".format(x))
|
||||
module.multiplyItemAttr("warfareBuff{}Value".format(x), value)
|
||||
|
||||
@@ -8,7 +8,7 @@ type = "passive"
|
||||
|
||||
def handler(fit, container, context):
|
||||
level = container.level if "skill" in context else 1
|
||||
for i in xrange(5):
|
||||
for i in range(5):
|
||||
attr = "boosterEffectChance{0}".format(i + 1)
|
||||
fit.boosters.filteredItemBoost(lambda booster: attr in booster.itemModifiedAttributes,
|
||||
attr, container.getModifiedItemAttr("boosterChanceBonus") * level)
|
||||
|
||||
@@ -16,7 +16,7 @@ type = "active", "gang"
|
||||
|
||||
|
||||
def handler(fit, module, context, **kwargs):
|
||||
for x in xrange(1, 5):
|
||||
for x in range(1, 5):
|
||||
if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)):
|
||||
value = module.getModifiedItemAttr("warfareBuff{}Value".format(x))
|
||||
id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x))
|
||||
|
||||
@@ -7,7 +7,7 @@ type = "active", "gang"
|
||||
|
||||
|
||||
def handler(fit, module, context, **kwargs):
|
||||
for x in xrange(1, 5):
|
||||
for x in range(1, 5):
|
||||
if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)):
|
||||
value = module.getModifiedItemAttr("warfareBuff{}Value".format(x))
|
||||
id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x))
|
||||
|
||||
@@ -7,7 +7,7 @@ type = "active", "gang"
|
||||
|
||||
|
||||
def handler(fit, module, context, **kwargs):
|
||||
for x in xrange(1, 5):
|
||||
for x in range(1, 5):
|
||||
if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)):
|
||||
value = module.getModifiedItemAttr("warfareBuff{}Value".format(x))
|
||||
id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x))
|
||||
|
||||
@@ -7,7 +7,7 @@ type = "active", "gang"
|
||||
|
||||
|
||||
def handler(fit, module, context, **kwargs):
|
||||
for x in xrange(1, 5):
|
||||
for x in range(1, 5):
|
||||
if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)):
|
||||
value = module.getModifiedItemAttr("warfareBuff{}Value".format(x))
|
||||
id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x))
|
||||
|
||||
@@ -7,7 +7,7 @@ type = "active", "gang"
|
||||
|
||||
|
||||
def handler(fit, module, context, **kwargs):
|
||||
for x in xrange(1, 5):
|
||||
for x in range(1, 5):
|
||||
if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)):
|
||||
value = module.getModifiedItemAttr("warfareBuff{}Value".format(x))
|
||||
id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x))
|
||||
|
||||
@@ -6,7 +6,7 @@ type = "active", "gang"
|
||||
|
||||
|
||||
def handler(fit, module, context, **kwargs):
|
||||
for x in xrange(1, 5):
|
||||
for x in range(1, 5):
|
||||
if module.getModifiedItemAttr("warfareBuff{}ID".format(x)):
|
||||
value = module.getModifiedItemAttr("warfareBuff{}Value".format(x))
|
||||
id = module.getModifiedItemAttr("warfareBuff{}ID".format(x))
|
||||
|
||||
@@ -4,5 +4,5 @@ runTime = "late"
|
||||
|
||||
|
||||
def handler(fit, module, context):
|
||||
for x in xrange(1, 4):
|
||||
for x in range(1, 4):
|
||||
module.boostChargeAttr("warfareBuff{}Multiplier".format(x), module.getModifiedItemAttr("commandBurstStrengthBonus"))
|
||||
|
||||
@@ -58,7 +58,7 @@ def rel_listener(target, value, initiator):
|
||||
if not target or (isinstance(value, Module) and value.isEmpty):
|
||||
return
|
||||
|
||||
print "{} has had a relationship change :D".format(target)
|
||||
print("{} has had a relationship change :D".format(target))
|
||||
target.modified = datetime.datetime.now()
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import re
|
||||
from sqlalchemy.orm import reconstructor
|
||||
|
||||
import eos.db
|
||||
from eqBase import EqBase
|
||||
from .eqBase import EqBase
|
||||
from eos.saveddata.price import Price as types_Price
|
||||
|
||||
try:
|
||||
@@ -259,7 +259,7 @@ class Item(EqBase):
|
||||
return default
|
||||
|
||||
def isType(self, type):
|
||||
for effect in self.effects.itervalues():
|
||||
for effect in self.effects.values():
|
||||
if effect.isType(type):
|
||||
return True
|
||||
|
||||
@@ -300,7 +300,7 @@ class Item(EqBase):
|
||||
self.__requiredSkills = requiredSkills
|
||||
# Map containing attribute IDs we may need for required skills
|
||||
# { requiredSkillX : requiredSkillXLevel }
|
||||
combinedAttrIDs = set(self.srqIDMap.iterkeys()).union(set(self.srqIDMap.itervalues()))
|
||||
combinedAttrIDs = set(self.srqIDMap.keys()).union(set(self.srqIDMap.values()))
|
||||
# Map containing result of the request
|
||||
# { attributeID : attributeValue }
|
||||
skillAttrs = {}
|
||||
@@ -310,7 +310,7 @@ class Item(EqBase):
|
||||
attrVal = attrInfo[2]
|
||||
skillAttrs[attrID] = attrVal
|
||||
# Go through all attributeID pairs
|
||||
for srqIDAtrr, srqLvlAttr in self.srqIDMap.iteritems():
|
||||
for srqIDAtrr, srqLvlAttr in self.srqIDMap.items():
|
||||
# Check if we have both in returned result
|
||||
if srqIDAtrr in skillAttrs and srqLvlAttr in skillAttrs:
|
||||
skillID = int(skillAttrs[srqIDAtrr])
|
||||
@@ -384,7 +384,7 @@ class Item(EqBase):
|
||||
race = None
|
||||
# Check primary and secondary required skills' races
|
||||
if race is None:
|
||||
skillRaces = tuple(filter(lambda rid: rid, (s.raceID for s in tuple(self.requiredSkills.keys()))))
|
||||
skillRaces = tuple([rid for rid in (s.raceID for s in tuple(self.requiredSkills.keys())) if rid])
|
||||
if sum(skillRaces) in map:
|
||||
race = map[sum(skillRaces)]
|
||||
if race == "angelserp":
|
||||
@@ -406,7 +406,7 @@ class Item(EqBase):
|
||||
if self.__assistive is None:
|
||||
assistive = False
|
||||
# Go through all effects and find first assistive
|
||||
for effect in self.effects.itervalues():
|
||||
for effect in self.effects.values():
|
||||
if effect.isAssistance is True:
|
||||
# If we find one, stop and mark item as assistive
|
||||
assistive = True
|
||||
@@ -421,7 +421,7 @@ class Item(EqBase):
|
||||
if self.__offensive is None:
|
||||
offensive = False
|
||||
# Go through all effects and find first offensive
|
||||
for effect in self.effects.itervalues():
|
||||
for effect in self.effects.values():
|
||||
if effect.isOffensive is True:
|
||||
# If we find one, stop and mark item as offensive
|
||||
offensive = True
|
||||
@@ -430,8 +430,8 @@ class Item(EqBase):
|
||||
return self.__offensive
|
||||
|
||||
def requiresSkill(self, skill, level=None):
|
||||
for s, l in self.requiredSkills.iteritems():
|
||||
if isinstance(skill, basestring):
|
||||
for s, l in self.requiredSkills.items():
|
||||
if isinstance(skill, str):
|
||||
if s.name == skill and (level is None or l == level):
|
||||
return True
|
||||
|
||||
@@ -469,7 +469,7 @@ class Item(EqBase):
|
||||
return self.__price
|
||||
|
||||
def __repr__(self):
|
||||
return u"Item(ID={}, name={}) at {}".format(
|
||||
return "Item(ID={}, name={}) at {}".format(
|
||||
self.ID, self.name, hex(id(self))
|
||||
)
|
||||
|
||||
@@ -523,7 +523,7 @@ class Icon(EqBase):
|
||||
|
||||
class MarketGroup(EqBase):
|
||||
def __repr__(self):
|
||||
return u"MarketGroup(ID={}, name={}, parent={}) at {}".format(
|
||||
return "MarketGroup(ID={}, name={}, parent={}) at {}".format(
|
||||
self.ID, self.name, getattr(self.parent, "name", None), self.name, hex(id(self))
|
||||
).encode('utf8')
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class Graph(object):
|
||||
self.fit = fit
|
||||
self.data = {}
|
||||
if data is not None:
|
||||
for name, d in data.iteritems():
|
||||
for name, d in data.items():
|
||||
self.setData(Data(name, d))
|
||||
|
||||
self.function = function
|
||||
@@ -39,7 +39,7 @@ class Graph(object):
|
||||
def getIterator(self):
|
||||
pointNames = []
|
||||
pointIterators = []
|
||||
for data in self.data.itervalues():
|
||||
for data in self.data.values():
|
||||
pointNames.append(data.name)
|
||||
pointIterators.append(data)
|
||||
|
||||
@@ -48,7 +48,7 @@ class Graph(object):
|
||||
def _iterator(self, pointNames, pointIterators):
|
||||
for pointValues in itertools.product(*pointIterators):
|
||||
point = {}
|
||||
for i in xrange(len(pointValues)):
|
||||
for i in range(len(pointValues)):
|
||||
point[pointNames[i]] = pointValues[i]
|
||||
|
||||
yield point, self.function(point)
|
||||
@@ -61,12 +61,12 @@ class Data(object):
|
||||
self.data = self.parseString(dataString)
|
||||
|
||||
def parseString(self, dataString):
|
||||
if not isinstance(dataString, basestring):
|
||||
if not isinstance(dataString, str):
|
||||
return Constant(dataString),
|
||||
|
||||
dataList = []
|
||||
for data in dataString.split(";"):
|
||||
if isinstance(data, basestring) and "-" in data:
|
||||
if isinstance(data, str) and "-" in data:
|
||||
# Dealing with a range
|
||||
dataList.append(Range(data, self.step))
|
||||
else:
|
||||
@@ -85,7 +85,7 @@ class Data(object):
|
||||
|
||||
class Constant(object):
|
||||
def __init__(self, const):
|
||||
if isinstance(const, basestring):
|
||||
if isinstance(const, str):
|
||||
self.value = None if const == "" else float(const)
|
||||
else:
|
||||
self.value = const
|
||||
|
||||
@@ -63,10 +63,10 @@ class FitDpsGraph(Graph):
|
||||
ew['signatureRadius'].sort(key=abssort)
|
||||
ew['velocity'].sort(key=abssort)
|
||||
|
||||
for attr, values in ew.iteritems():
|
||||
for attr, values in ew.items():
|
||||
val = data[attr]
|
||||
try:
|
||||
for i in xrange(len(values)):
|
||||
for i in range(len(values)):
|
||||
bonus = values[i]
|
||||
val *= 1 + (bonus - 1) * exp(- i ** 2 / 7.1289)
|
||||
data[attr] = val
|
||||
|
||||
@@ -162,9 +162,9 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
|
||||
def __len__(self):
|
||||
keys = set()
|
||||
keys.update(self.original.iterkeys())
|
||||
keys.update(self.__modified.iterkeys())
|
||||
keys.update(self.__intermediary.iterkeys())
|
||||
keys.update(iter(self.original.keys()))
|
||||
keys.update(iter(self.__modified.keys()))
|
||||
keys.update(iter(self.__intermediary.keys()))
|
||||
return len(keys)
|
||||
|
||||
def __calculateValue(self, key):
|
||||
@@ -228,11 +228,11 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
val *= multiplier
|
||||
# Each group is penalized independently
|
||||
# Things in different groups will not be stack penalized between each other
|
||||
for penalizedMultipliers in penalizedMultiplierGroups.itervalues():
|
||||
for penalizedMultipliers in penalizedMultiplierGroups.values():
|
||||
# A quick explanation of how this works:
|
||||
# 1: Bonuses and penalties are calculated seperately, so we'll have to filter each of them
|
||||
l1 = filter(lambda _val: _val > 1, penalizedMultipliers)
|
||||
l2 = filter(lambda _val: _val < 1, penalizedMultipliers)
|
||||
l1 = [_val for _val in penalizedMultipliers if _val > 1]
|
||||
l2 = [_val for _val in penalizedMultipliers if _val < 1]
|
||||
# 2: The most significant bonuses take the smallest penalty,
|
||||
# This means we'll have to sort
|
||||
abssort = lambda _val: -abs(_val - 1)
|
||||
@@ -242,7 +242,7 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
# Any module after the first takes penalties according to:
|
||||
# 1 + (multiplier - 1) * math.exp(- math.pow(i, 2) / 7.1289)
|
||||
for l in (l1, l2):
|
||||
for i in xrange(len(l)):
|
||||
for i in range(len(l)):
|
||||
bonus = l[i]
|
||||
val *= 1 + (bonus - 1) * exp(- i ** 2 / 7.1289)
|
||||
val += postIncrease
|
||||
@@ -380,7 +380,7 @@ class ModifiedAttributeDict(collections.MutableMapping):
|
||||
"""Force value to attribute and prohibit any changes to it"""
|
||||
self.__forced[attributeName] = value
|
||||
self.__placehold(attributeName)
|
||||
self.__afflict(attributeName, u"\u2263", value)
|
||||
self.__afflict(attributeName, "\u2263", value)
|
||||
|
||||
@staticmethod
|
||||
def getResistance(fit, effect):
|
||||
|
||||
@@ -118,7 +118,7 @@ class Booster(HandledItem, ItemAttrShortcut):
|
||||
return
|
||||
if not self.active:
|
||||
return
|
||||
for effect in self.item.effects.itervalues():
|
||||
for effect in self.item.effects.values():
|
||||
if effect.runTime == runTime and \
|
||||
(effect.isType("passive") or effect.isType("boosterSideEffect")) and \
|
||||
effect.activeByDefault:
|
||||
|
||||
@@ -77,8 +77,8 @@ class Cargo(HandledItem, ItemAttrShortcut):
|
||||
"amount": lambda _val: isinstance(_val, int)
|
||||
}
|
||||
|
||||
if key == "amount" and val > sys.maxint:
|
||||
val = sys.maxint
|
||||
if key == "amount" and val > sys.maxsize:
|
||||
val = sys.maxsize
|
||||
|
||||
if not map[key](val):
|
||||
raise ValueError(str(val) + " is not a valid value for " + key)
|
||||
|
||||
@@ -160,7 +160,7 @@ class Character(object):
|
||||
if self.alphaCloneID:
|
||||
clone = eos.db.getAlphaClone(self.alphaCloneID)
|
||||
type = clone.alphaCloneName.split()[1]
|
||||
name += u' (\u03B1{})'.format(type[0].upper())
|
||||
name += ' (\u03B1{})'.format(type[0].upper())
|
||||
|
||||
return name
|
||||
|
||||
@@ -197,7 +197,7 @@ class Character(object):
|
||||
del self.__skillIdMap[skill.itemID]
|
||||
|
||||
def getSkill(self, item):
|
||||
if isinstance(item, basestring):
|
||||
if isinstance(item, str):
|
||||
item = self.getSkillNameMap()[item]
|
||||
elif isinstance(item, int):
|
||||
item = self.getSkillIDMap()[item]
|
||||
@@ -236,17 +236,17 @@ class Character(object):
|
||||
|
||||
def filteredSkillIncrease(self, filter, *args, **kwargs):
|
||||
for element in self.skills:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.increaseItemAttr(*args, **kwargs)
|
||||
|
||||
def filteredSkillMultiply(self, filter, *args, **kwargs):
|
||||
for element in self.skills:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.multiplyItemAttr(*args, **kwargs)
|
||||
|
||||
def filteredSkillBoost(self, filter, *args, **kwargs):
|
||||
for element in self.skills:
|
||||
if filter(element):
|
||||
if list(filter(element)):
|
||||
element.boostItemAttr(*args, **kwargs)
|
||||
|
||||
def calculateModifiedAttributes(self, fit, runTime, forceProjected=False):
|
||||
@@ -280,7 +280,7 @@ class Character(object):
|
||||
map = {
|
||||
"ID" : lambda _val: isinstance(_val, int),
|
||||
"name" : lambda _val: True,
|
||||
"apiKey" : lambda _val: _val is None or (isinstance(_val, basestring) and len(_val) > 0),
|
||||
"apiKey" : lambda _val: _val is None or (isinstance(_val, str) and len(_val) > 0),
|
||||
"ownerID": lambda _val: isinstance(_val, int) or _val is None
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ class Skill(HandledItem):
|
||||
|
||||
if eos.config.settings['strictSkillLevels']:
|
||||
start = time.time()
|
||||
for item, rlevel in self.item.requiredFor.iteritems():
|
||||
for item, rlevel in self.item.requiredFor.items():
|
||||
if item.group.category.ID == 16: # Skill category
|
||||
if level < rlevel:
|
||||
skill = self.character.getSkill(item.ID)
|
||||
@@ -395,7 +395,7 @@ class Skill(HandledItem):
|
||||
if item is None:
|
||||
return
|
||||
|
||||
for effect in item.effects.itervalues():
|
||||
for effect in item.effects.values():
|
||||
if effect.runTime == runTime and \
|
||||
effect.isType("passive") and \
|
||||
(not fit.isStructure or effect.isType("structure")) and \
|
||||
|
||||
@@ -138,8 +138,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
cycleTime = self.getModifiedItemAttr(attr)
|
||||
|
||||
volley = sum(
|
||||
map(lambda d: (getter("%sDamage" % d) or 0) * (1 - getattr(targetResists, "%sAmount" % d, 0)),
|
||||
self.DAMAGE_TYPES))
|
||||
[(getter("%sDamage" % d) or 0) * (1 - getattr(targetResists, "%sAmount" % d, 0)) for d in self.DAMAGE_TYPES])
|
||||
volley *= self.amountActive
|
||||
volley *= self.getModifiedItemAttr("damageMultiplier") or 1
|
||||
self.__volley = volley
|
||||
@@ -155,7 +154,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
getter = self.getModifiedItemAttr
|
||||
|
||||
cycleTime = self.getModifiedItemAttr(attr)
|
||||
volley = sum(map(lambda d: getter(d), self.MINING_ATTRIBUTES)) * self.amountActive
|
||||
volley = sum([getter(d) for d in self.MINING_ATTRIBUTES]) * self.amountActive
|
||||
self.__miningyield = volley / (cycleTime / 1000.0)
|
||||
else:
|
||||
self.__miningyield = 0
|
||||
@@ -236,7 +235,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
context = ("drone",)
|
||||
projected = False
|
||||
|
||||
for effect in self.item.effects.itervalues():
|
||||
for effect in self.item.effects.values():
|
||||
if effect.runTime == runTime and \
|
||||
effect.activeByDefault and \
|
||||
((projected is True and effect.isType("projected")) or
|
||||
@@ -251,7 +250,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
i += 1
|
||||
|
||||
if self.charge:
|
||||
for effect in self.charge.effects.itervalues():
|
||||
for effect in self.charge.effects.values():
|
||||
if effect.runTime == runTime and effect.activeByDefault:
|
||||
effect.handler(fit, self, ("droneCharge",))
|
||||
|
||||
@@ -263,7 +262,7 @@ class Drone(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
def fits(self, fit):
|
||||
fitDroneGroupLimits = set()
|
||||
for i in xrange(1, 3):
|
||||
for i in range(1, 3):
|
||||
groneGrp = fit.ship.getModifiedItemAttr("allowedDroneGroup%d" % i)
|
||||
if groneGrp is not None:
|
||||
fitDroneGroupLimits.add(int(groneGrp))
|
||||
|
||||
@@ -98,7 +98,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
def __getAbilities(self):
|
||||
"""Returns list of FighterAbilities that are loaded with data"""
|
||||
return [FighterAbility(effect) for effect in self.item.effects.values()]
|
||||
return [FighterAbility(effect) for effect in list(self.item.effects.values())]
|
||||
|
||||
def __calculateSlot(self, item):
|
||||
types = {
|
||||
@@ -107,7 +107,7 @@ class Fighter(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
"Heavy" : Slot.F_HEAVY
|
||||
}
|
||||
|
||||
for t, slot in types.iteritems():
|
||||
for t, slot in types.items():
|
||||
if self.getModifiedItemAttr("fighterSquadronIs{}".format(t)):
|
||||
return slot
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class FighterAbility(object):
|
||||
self.__effect = None
|
||||
|
||||
if self.effectID:
|
||||
self.__effect = next((x for x in self.fighter.item.effects.itervalues() if x.ID == self.effectID), None)
|
||||
self.__effect = next((x for x in self.fighter.item.effects.values() if x.ID == self.effectID), None)
|
||||
if self.__effect is None:
|
||||
pyfalog.error("Effect (id: {0}) does not exist", self.effectID)
|
||||
return
|
||||
@@ -127,8 +127,8 @@ class FighterAbility(object):
|
||||
|
||||
if self.attrPrefix == "fighterAbilityLaunchBomb":
|
||||
# bomb calcs
|
||||
volley = sum(map(lambda attr: (self.fighter.getModifiedChargeAttr("%sDamage" % attr) or 0) * (
|
||||
1 - getattr(targetResists, "%sAmount" % attr, 0)), self.DAMAGE_TYPES))
|
||||
volley = sum([(self.fighter.getModifiedChargeAttr("%sDamage" % attr) or 0) * (
|
||||
1 - getattr(targetResists, "%sAmount" % attr, 0)) for attr in self.DAMAGE_TYPES])
|
||||
else:
|
||||
volley = sum(map(lambda d2, d:
|
||||
(self.fighter.getModifiedItemAttr(
|
||||
|
||||
@@ -258,11 +258,11 @@ class Fit(object):
|
||||
def projectedFits(self):
|
||||
# only in extreme edge cases will the fit be invalid, but to be sure do
|
||||
# not return them.
|
||||
return [fit for fit in self.__projectedFits.values() if not fit.isInvalid]
|
||||
return [fit for fit in list(self.__projectedFits.values()) if not fit.isInvalid]
|
||||
|
||||
@property
|
||||
def commandFits(self):
|
||||
return [fit for fit in self.__commandFits.values() if not fit.isInvalid]
|
||||
return [fit for fit in list(self.__commandFits.values()) if not fit.isInvalid]
|
||||
|
||||
def getProjectionInfo(self, fitID):
|
||||
return self.projectedOnto.get(fitID, None)
|
||||
@@ -492,7 +492,7 @@ class Fit(object):
|
||||
|
||||
def __runCommandBoosts(self, runTime="normal"):
|
||||
pyfalog.debug("Applying gang boosts for {0}", repr(self))
|
||||
for warfareBuffID in self.commandBonuses.keys():
|
||||
for warfareBuffID in list(self.commandBonuses.keys()):
|
||||
# Unpack all data required to run effect properly
|
||||
effect_runTime, value, thing, effect = self.commandBonuses[warfareBuffID]
|
||||
|
||||
@@ -676,7 +676,7 @@ class Fit(object):
|
||||
|
||||
def __resetDependentCalcs(self):
|
||||
self.calculated = False
|
||||
for value in self.projectedOnto.values():
|
||||
for value in list(self.projectedOnto.values()):
|
||||
if value.victim_fit: # removing a self-projected fit causes victim fit to be None. @todo: look into why. :3
|
||||
value.victim_fit.calculated = False
|
||||
|
||||
@@ -707,14 +707,14 @@ class Fit(object):
|
||||
self.__resetDependentCalcs()
|
||||
|
||||
# For fits that are under local's Command, we do the same thing
|
||||
for value in self.boostedOnto.values():
|
||||
for value in list(self.boostedOnto.values()):
|
||||
# apparently this is a thing that happens when removing a command fit from a fit and then switching to
|
||||
# that command fit. Same as projected clears, figure out why.
|
||||
if value.boosted_fit:
|
||||
value.boosted_fit.__resetDependentCalcs()
|
||||
|
||||
if targetFit and type == CalcType.PROJECTED:
|
||||
pyfalog.debug(u"Calculating projections from {0} to target {1}", repr(self), repr(targetFit))
|
||||
pyfalog.debug("Calculating projections from {0} to target {1}", repr(self), repr(targetFit))
|
||||
projectionInfo = self.getProjectionInfo(targetFit.ID)
|
||||
|
||||
# Start applying any command fits that we may have.
|
||||
@@ -838,7 +838,7 @@ class Fit(object):
|
||||
for item in c:
|
||||
if item is not None:
|
||||
# apply effects onto target fit x amount of times
|
||||
for _ in xrange(projectionInfo.amount):
|
||||
for _ in range(projectionInfo.amount):
|
||||
targetFit.register(item, origin=self)
|
||||
item.calculateModifiedAttributes(targetFit, runTime, True)
|
||||
|
||||
@@ -854,7 +854,7 @@ class Fit(object):
|
||||
for slotType in (Slot.LOW, Slot.MED, Slot.HIGH, Slot.RIG, Slot.SUBSYSTEM, Slot.SERVICE):
|
||||
amount = self.getSlotsFree(slotType, True)
|
||||
if amount > 0:
|
||||
for _ in xrange(int(amount)):
|
||||
for _ in range(int(amount)):
|
||||
self.modules.append(Module.buildEmpty(slotType))
|
||||
|
||||
if amount < 0:
|
||||
@@ -870,7 +870,7 @@ class Fit(object):
|
||||
self.modules.remove(mod)
|
||||
|
||||
def unfill(self):
|
||||
for i in xrange(len(self.modules) - 1, -1, -1):
|
||||
for i in range(len(self.modules) - 1, -1, -1):
|
||||
mod = self.modules[i]
|
||||
if mod.isEmpty:
|
||||
del self.modules[i]
|
||||
@@ -878,7 +878,7 @@ class Fit(object):
|
||||
@property
|
||||
def modCount(self):
|
||||
x = 0
|
||||
for i in xrange(len(self.modules) - 1, -1, -1):
|
||||
for i in range(len(self.modules) - 1, -1, -1):
|
||||
mod = self.modules[i]
|
||||
if not mod.isEmpty:
|
||||
x += 1
|
||||
@@ -1486,11 +1486,11 @@ class Fit(object):
|
||||
return copy_ship
|
||||
|
||||
def __repr__(self):
|
||||
return u"Fit(ID={}, ship={}, name={}) at {}".format(
|
||||
return "Fit(ID={}, ship={}, name={}) at {}".format(
|
||||
self.ID, self.ship.item.name, self.name, hex(id(self))
|
||||
).encode('utf8')
|
||||
|
||||
def __str__(self):
|
||||
return u"{} ({})".format(
|
||||
return "{} ({})".format(
|
||||
self.name, self.ship.item.name
|
||||
).encode('utf8')
|
||||
|
||||
@@ -93,7 +93,7 @@ class Implant(HandledItem, ItemAttrShortcut):
|
||||
return
|
||||
if not self.active:
|
||||
return
|
||||
for effect in self.item.effects.itervalues():
|
||||
for effect in self.item.effects.values():
|
||||
if effect.runTime == runTime and effect.isType("passive") and effect.activeByDefault:
|
||||
effect.handler(fit, self, ("implant",))
|
||||
|
||||
|
||||
@@ -50,6 +50,6 @@ class Mode(ItemAttrShortcut, HandledItem):
|
||||
|
||||
def calculateModifiedAttributes(self, fit, runTime, forceProjected=False):
|
||||
if self.item:
|
||||
for effect in self.item.effects.itervalues():
|
||||
for effect in self.item.effects.values():
|
||||
if effect.runTime == runTime and effect.activeByDefault:
|
||||
effect.handler(fit, self, context=("module",))
|
||||
|
||||
@@ -329,9 +329,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
else:
|
||||
func = self.getModifiedItemAttr
|
||||
|
||||
volley = sum(map(
|
||||
lambda attr: (func("%sDamage" % attr) or 0) * (1 - getattr(targetResists, "%sAmount" % attr, 0)),
|
||||
self.DAMAGE_TYPES))
|
||||
volley = sum([(func("%sDamage" % attr) or 0) * (1 - getattr(targetResists, "%sAmount" % attr, 0)) for attr in self.DAMAGE_TYPES])
|
||||
volley *= self.getModifiedItemAttr("damageMultiplier") or 1
|
||||
if volley:
|
||||
cycleTime = self.cycleTime
|
||||
@@ -415,13 +413,13 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
if shipType is not None:
|
||||
fitsOnType.add(shipType)
|
||||
|
||||
for attr in self.itemModifiedAttributes.keys():
|
||||
for attr in list(self.itemModifiedAttributes.keys()):
|
||||
if attr.startswith("canFitShipType"):
|
||||
shipType = self.getModifiedItemAttr(attr)
|
||||
if shipType is not None:
|
||||
fitsOnType.add(shipType)
|
||||
|
||||
for attr in self.itemModifiedAttributes.keys():
|
||||
for attr in list(self.itemModifiedAttributes.keys()):
|
||||
if attr.startswith("canFitShipGroup"):
|
||||
shipGroup = self.getModifiedItemAttr(attr)
|
||||
if shipGroup is not None:
|
||||
@@ -582,7 +580,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
if item is None:
|
||||
return Hardpoint.NONE
|
||||
|
||||
for effectName, slot in effectHardpointMap.iteritems():
|
||||
for effectName, slot in effectHardpointMap.items():
|
||||
if effectName in item.effects:
|
||||
return slot
|
||||
|
||||
@@ -600,7 +598,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
}
|
||||
if item is None:
|
||||
return None
|
||||
for effectName, slot in effectSlotMap.iteritems():
|
||||
for effectName, slot in effectSlotMap.items():
|
||||
if effectName in item.effects:
|
||||
return slot
|
||||
if item.group.name == "Effect Beacon":
|
||||
@@ -654,7 +652,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
if self.charge is not None:
|
||||
# fix for #82 and it's regression #106
|
||||
if not projected or (self.projected and not forceProjected) or gang:
|
||||
for effect in self.charge.effects.itervalues():
|
||||
for effect in self.charge.effects.values():
|
||||
if effect.runTime == runTime and \
|
||||
effect.activeByDefault and \
|
||||
(effect.isType("offline") or
|
||||
@@ -673,7 +671,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
if self.item:
|
||||
if self.state >= State.OVERHEATED:
|
||||
for effect in self.item.effects.itervalues():
|
||||
for effect in self.item.effects.values():
|
||||
if effect.runTime == runTime and \
|
||||
effect.isType("overheat") \
|
||||
and not forceProjected \
|
||||
@@ -681,7 +679,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
and ((gang and effect.isType("gang")) or not gang):
|
||||
effect.handler(fit, self, context)
|
||||
|
||||
for effect in self.item.effects.itervalues():
|
||||
for effect in self.item.effects.values():
|
||||
if effect.runTime == runTime and \
|
||||
effect.activeByDefault and \
|
||||
(effect.isType("offline") or
|
||||
@@ -781,7 +779,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
|
||||
|
||||
def __repr__(self):
|
||||
if self.item:
|
||||
return u"Module(ID={}, name={}) at {}".format(
|
||||
return "Module(ID={}, name={}) at {}".format(
|
||||
self.item.ID, self.item.name, hex(id(self))
|
||||
)
|
||||
else:
|
||||
|
||||
@@ -87,7 +87,7 @@ class Ship(ItemAttrShortcut, HandledItem):
|
||||
def calculateModifiedAttributes(self, fit, runTime, forceProjected=False):
|
||||
if forceProjected:
|
||||
return
|
||||
for effect in self.item.effects.itervalues():
|
||||
for effect in self.item.effects.values():
|
||||
if effect.runTime == runTime and \
|
||||
effect.isType("passive") and \
|
||||
effect.activeByDefault:
|
||||
|
||||
@@ -33,7 +33,7 @@ class User(object):
|
||||
|
||||
def encodeAndSetPassword(self, pw):
|
||||
h = hashlib.new("sha256")
|
||||
salt = "".join([random.choice(string.letters) for _ in xrange(32)])
|
||||
salt = "".join([random.choice(string.letters) for _ in range(32)])
|
||||
h.update(pw)
|
||||
h.update(salt)
|
||||
self.password = ("%s%s" % (h.hexdigest(), salt))
|
||||
@@ -45,14 +45,14 @@ class User(object):
|
||||
h = hashlib.new("sha256")
|
||||
h.update(pw)
|
||||
h.update(salt)
|
||||
return self.password == (u"%s%s" % (h.hexdigest(), salt))
|
||||
return self.password == ("%s%s" % (h.hexdigest(), salt))
|
||||
|
||||
@validates("ID", "username", "password", "admin")
|
||||
def validator(self, key, val):
|
||||
map = {
|
||||
"ID" : lambda _val: isinstance(_val, int),
|
||||
"username": lambda _val: isinstance(_val, basestring),
|
||||
"password": lambda _val: isinstance(_val, basestring) and len(_val) == 96,
|
||||
"username": lambda _val: isinstance(_val, str),
|
||||
"password": lambda _val: isinstance(_val, str) and len(_val) == 96,
|
||||
"admin" : lambda _val: isinstance(_val, bool)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user