oh god this isn't gonna work
Merge branch 'ebag_importchanges' into test_import Conflicts: config.py eos/db/saveddata/queries.py eos/effects/chargebonuswarfarecharge.py eos/effects/elitebonuscommandshipinformationhiddencs3.py eos/effects/elitebonuslogisticremotearmorrepairoptimalfalloff1.py eos/effects/energydestabilizationnew.py eos/effects/iceharvestingdroneoperationdurationbonus.py eos/effects/miningforemanstrengthbonus.py eos/effects/modulebonuswarfarelinkarmor.py eos/effects/modulebonuswarfarelinkinfo.py eos/effects/modulebonuswarfarelinkmining.py eos/effects/modulebonuswarfarelinkshield.py eos/effects/modulebonuswarfarelinkskirmish.py eos/effects/moduletitaneffectgenerator.py eos/effects/remotehullrepair.py eos/effects/rolebonusremotearmorrepairoptimalfalloff.py eos/effects/shipbonusforceauxiliarya4warfarelinksbonus.py eos/effects/shipmodesmallmissiledamagepostdiv.py eos/effects/structureenergyneutralizerfalloff.py eos/effects/structuremoduleeffectstasiswebifier.py eos/effects/structurerigmaxtargets.py eos/effects/subsystembonusamarrdefensiveinformationwarfarehidden.py eos/effects/subsystembonuscaldaridefensiveinformationwarfarehidden.py eos/effects/subsystembonusgallentedefensiveinformationwarfarehidden.py eos/effects/techtwocommandburstbonus.py eos/saveddata/fighter.py eos/saveddata/fit.py eos/saveddata/module.py eve.db gui/bitmapLoader.py gui/builtinContextMenus/itemStats.py gui/builtinStatsViews/miningyieldViewFull.py gui/builtinViewColumns/misc.py gui/builtinViews/__init__.py gui/builtinViews/fittingView.py gui/contextMenu.py gui/graphFrame.py gui/itemStats.py gui/mainFrame.py gui/marketBrowser.py service/__init__.py service/character.py service/fit.py service/port.py service/prefetch.py service/pycrest/eve.py service/settings.py
This commit is contained in:
@@ -39,8 +39,8 @@ items_table = Table("invtypes", gamedata_meta,
|
||||
Column("iconID", Integer, ForeignKey("icons.iconID")),
|
||||
Column("groupID", Integer, ForeignKey("invgroups.groupID"), index=True))
|
||||
|
||||
from .metaGroup import metatypes_table
|
||||
from .traits import traits_table
|
||||
from .metaGroup import metatypes_table # noqa
|
||||
from .traits import traits_table # noqa
|
||||
|
||||
mapper(Item, items_table,
|
||||
properties={"group": relation(Group, backref="items"),
|
||||
|
||||
@@ -21,6 +21,9 @@ from sqlalchemy.orm import join, exc
|
||||
from sqlalchemy.sql import and_, or_, select
|
||||
|
||||
import eos.config
|
||||
# TODO: Unsure which item the code below needs :(
|
||||
# from eos.gamedata import Item
|
||||
from eos.gamedata import Attribute
|
||||
from eos.db import gamedata_session
|
||||
from eos.db.gamedata.metaGroup import metatypes_table, items_table
|
||||
from eos.db.util import processEager, processWhere
|
||||
@@ -280,9 +283,9 @@ def directAttributeRequest(itemIDs, attrIDs):
|
||||
if not isinstance(itemID, int):
|
||||
raise TypeError("All itemIDs must be integer")
|
||||
|
||||
q = select((eos.types.Item.typeID, eos.types.Attribute.attributeID, eos.types.Attribute.value),
|
||||
and_(eos.types.Attribute.attributeID.in_(attrIDs), eos.types.Item.typeID.in_(itemIDs)),
|
||||
from_obj=[join(eos.types.Attribute, eos.types.Item)])
|
||||
q = select((Item.typeID, Attribute.attributeID, Attribute.value),
|
||||
and_(Attribute.attributeID.in_(attrIDs), Item.typeID.in_(itemIDs)),
|
||||
from_obj=[join(Attribute, Item)])
|
||||
|
||||
result = gamedata_session.execute(q).fetchall()
|
||||
return result
|
||||
|
||||
@@ -45,7 +45,7 @@ CONVERSIONS = {
|
||||
8746, # Quantum Co-Processor
|
||||
8745, # Photonic CPU Enhancer
|
||||
15425, # Naiyon's Modified Co-Processor (never existed but convert
|
||||
# anyway as some fits may include it)
|
||||
# anyway as some fits may include it)
|
||||
],
|
||||
8748: [ # Upgraded Co-Processor
|
||||
8747, # Nanomechanical CPU Enhancer I
|
||||
@@ -70,7 +70,7 @@ CONVERSIONS = {
|
||||
16543, # Micro 'Vigor' Core Augmentation
|
||||
],
|
||||
8089: [ # Compact Light Missile Launcher
|
||||
8093, # Prototype 'Arbalest' Light Missile Launcher
|
||||
8093, # Prototype 'Arbalest' Light Missile Launcher
|
||||
],
|
||||
8091: [ # Ample Light Missile Launcher
|
||||
7993, # Experimental TE-2100 Light Missile Launcher
|
||||
@@ -82,6 +82,7 @@ CONVERSIONS = {
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Update fits schema to include target resists attribute
|
||||
try:
|
||||
@@ -92,6 +93,7 @@ def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -6,6 +6,7 @@ Migration 10
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Update projectedFits schema to include active attribute
|
||||
try:
|
||||
|
||||
@@ -7,7 +7,6 @@ Migration 11
|
||||
modules with their new replacements
|
||||
"""
|
||||
|
||||
|
||||
CONVERSIONS = {
|
||||
16467: ( # Medium Gremlin Compact Energy Neutralizer
|
||||
16471, # Medium Unstable Power Fluctuator I
|
||||
@@ -106,11 +105,12 @@ CONVERSIONS = {
|
||||
),
|
||||
}
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -7,7 +7,6 @@ Migration 12
|
||||
modules with their new replacements
|
||||
"""
|
||||
|
||||
|
||||
CONVERSIONS = {
|
||||
16457: ( # Crosslink Compact Ballistic Control System
|
||||
16459, # Muon Coil Bolt Array I
|
||||
@@ -330,11 +329,12 @@ CONVERSIONS = {
|
||||
),
|
||||
}
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -6,10 +6,11 @@ Migration 13
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Update fits schema to include implant location attribute
|
||||
try:
|
||||
saveddata_engine.execute("SELECT implantLocation FROM fits LIMIT 1")
|
||||
except sqlalchemy.exc.DatabaseError:
|
||||
saveddata_engine.execute("ALTER TABLE fits ADD COLUMN implantLocation INTEGER;")
|
||||
saveddata_engine.execute("UPDATE fits SET implantLocation = 0")
|
||||
saveddata_engine.execute("UPDATE fits SET implantLocation = 0")
|
||||
|
||||
@@ -6,8 +6,10 @@ Migration 14
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
if saveddata_engine.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='fighters'").scalar() == 'fighters':
|
||||
if saveddata_engine.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='table' AND name='fighters'").scalar() == 'fighters':
|
||||
# Fighters table exists
|
||||
try:
|
||||
saveddata_engine.execute("SELECT active FROM fighters LIMIT 1")
|
||||
@@ -16,4 +18,4 @@ def upgrade(saveddata_engine):
|
||||
# (they will be recreated)
|
||||
|
||||
saveddata_engine.execute("DROP TABLE fighters")
|
||||
saveddata_engine.execute("DROP TABLE fightersAbilities")
|
||||
saveddata_engine.execute("DROP TABLE fightersAbilities")
|
||||
|
||||
@@ -6,8 +6,8 @@ Migration 15
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
sql = """
|
||||
DELETE FROM modules WHERE ID IN
|
||||
(
|
||||
|
||||
@@ -6,6 +6,7 @@ Migration 16
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Update fits schema to include notes attribute
|
||||
try:
|
||||
|
||||
@@ -33,7 +33,8 @@ def upgrade(saveddata_engine):
|
||||
|
||||
inserts.append({"boosterID": value, "boostedID": boosted, "active": 1})
|
||||
try:
|
||||
saveddata_session.execute(commandFits_table.insert(), {"boosterID": value, "boostedID": boosted, "active": 1})
|
||||
except Exception, e:
|
||||
saveddata_session.execute(commandFits_table.insert(),
|
||||
{"boosterID": value, "boostedID": boosted, "active": 1})
|
||||
except Exception:
|
||||
pass
|
||||
saveddata_session.commit()
|
||||
|
||||
@@ -4,27 +4,26 @@ Migration 8
|
||||
- Converts modules from old Warfare Links to Command Modules
|
||||
"""
|
||||
|
||||
|
||||
CONVERSIONS = {
|
||||
42526: ( # Armor Command Burst I
|
||||
20069, # Armored Warfare Link - Damage Control I
|
||||
20409, # Armored Warfare Link - Passive Defense I
|
||||
22227, # Armored Warfare Link - Rapid Repair I
|
||||
20069, # Armored Warfare Link - Damage Control I
|
||||
20409, # Armored Warfare Link - Passive Defense I
|
||||
22227, # Armored Warfare Link - Rapid Repair I
|
||||
),
|
||||
43552: ( # Armor Command Burst II
|
||||
4264, # Armored Warfare Link - Damage Control II
|
||||
4266, # Armored Warfare Link - Passive Defense II
|
||||
4266, # Armored Warfare Link - Rapid Repair II
|
||||
4264, # Armored Warfare Link - Damage Control II
|
||||
4266, # Armored Warfare Link - Passive Defense II
|
||||
4266, # Armored Warfare Link - Rapid Repair II
|
||||
),
|
||||
42527: ( # Information Command Burst I
|
||||
11052, # Information Warfare Link - Sensor Integrity I
|
||||
20405, # Information Warfare Link - Recon Operation I
|
||||
20406, # Information Warfare Link - Electronic Superiority I
|
||||
11052, # Information Warfare Link - Sensor Integrity I
|
||||
20405, # Information Warfare Link - Recon Operation I
|
||||
20406, # Information Warfare Link - Electronic Superiority I
|
||||
),
|
||||
43554: ( # Information Command Burst II
|
||||
4268, # Information Warfare Link - Electronic Superiority II
|
||||
4270, # Information Warfare Link - Recon Operation II
|
||||
4272, # Information Warfare Link - Sensor Integrity II
|
||||
4268, # Information Warfare Link - Electronic Superiority II
|
||||
4270, # Information Warfare Link - Recon Operation II
|
||||
4272, # Information Warfare Link - Sensor Integrity II
|
||||
),
|
||||
42529: ( # Shield Command Burst I
|
||||
20124, # Siege Warfare Link - Active Shielding I
|
||||
@@ -34,17 +33,17 @@ CONVERSIONS = {
|
||||
43555: ( # Shield Command Burst II
|
||||
4280, # Siege Warfare Link - Active Shielding II
|
||||
4282, # Siege Warfare Link - Shield Efficiency II
|
||||
4284 # Siege Warfare Link - Shield Harmonizing II
|
||||
4284 # Siege Warfare Link - Shield Harmonizing II
|
||||
),
|
||||
42530: ( # Skirmish Command Burst I
|
||||
11017, # Skirmish Warfare Link - Interdiction Maneuvers I
|
||||
20070, # Skirmish Warfare Link - Evasive Maneuvers I
|
||||
20408, # Skirmish Warfare Link - Rapid Deployment I
|
||||
11017, # Skirmish Warfare Link - Interdiction Maneuvers I
|
||||
20070, # Skirmish Warfare Link - Evasive Maneuvers I
|
||||
20408, # Skirmish Warfare Link - Rapid Deployment I
|
||||
),
|
||||
43556: ( # Skirmish Command Burst II
|
||||
4286, # Skirmish Warfare Link - Evasive Maneuvers II
|
||||
4288, # Skirmish Warfare Link - Interdiction Maneuvers II
|
||||
4290 # Skirmish Warfare Link - Rapid Deployment II
|
||||
4290 # Skirmish Warfare Link - Rapid Deployment II
|
||||
),
|
||||
42528: ( # Mining Foreman Burst I
|
||||
22553, # Mining Foreman Link - Harvester Capacitor Efficiency I
|
||||
@@ -54,15 +53,16 @@ CONVERSIONS = {
|
||||
43551: ( # Mining Foreman Burst II
|
||||
4274, # Mining Foreman Link - Harvester Capacitor Efficiency II
|
||||
4276, # Mining Foreman Link - Laser Optimization II
|
||||
4278 # Mining Foreman Link - Mining Laser Field Enhancement II
|
||||
4278 # Mining Foreman Link - Mining Laser Field Enhancement II
|
||||
),
|
||||
}
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -11,10 +11,10 @@ def upgrade(saveddata_engine):
|
||||
from eos.db import saveddata_session
|
||||
|
||||
sql = """
|
||||
DELETE FROM commandFits
|
||||
WHERE boosterID NOT IN (select ID from fits)
|
||||
OR boostedID NOT IN (select ID from fits)
|
||||
"""
|
||||
DELETE FROM commandFits
|
||||
WHERE boosterID NOT IN (select ID from fits)
|
||||
OR boostedID NOT IN (select ID from fits)
|
||||
"""
|
||||
|
||||
saveddata_session.execute(sql)
|
||||
saveddata_session.commit()
|
||||
|
||||
@@ -6,6 +6,7 @@ Migration 2
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Update characters schema to include default chars
|
||||
try:
|
||||
|
||||
@@ -6,6 +6,7 @@ Migration 3
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
try:
|
||||
saveddata_engine.execute("SELECT modeID FROM fits LIMIT 1")
|
||||
|
||||
@@ -10,7 +10,6 @@ Migration 4
|
||||
and output of itemDiff.py
|
||||
"""
|
||||
|
||||
|
||||
CONVERSIONS = {
|
||||
506: ( # 'Basic' Capacitor Power Relay
|
||||
8205, # Alpha Reactor Control: Capacitor Power Relay
|
||||
@@ -131,11 +130,12 @@ CONVERSIONS = {
|
||||
),
|
||||
}
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -4,5 +4,6 @@ Migration 5
|
||||
Simply deletes damage profiles with a blank name. See GH issue #256
|
||||
"""
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
saveddata_engine.execute('DELETE FROM damagePatterns WHERE name LIKE ?', ("",))
|
||||
|
||||
@@ -4,6 +4,8 @@ Migration 6
|
||||
Overwrites damage profile 0 to reset bad uniform values (bad values set with bug)
|
||||
"""
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
saveddata_engine.execute('DELETE FROM damagePatterns WHERE name LIKE ? OR ID LIKE ?', ("Uniform", "1"))
|
||||
saveddata_engine.execute('INSERT INTO damagePatterns VALUES (?, ?, ?, ?, ?, ?, ?)', (1, "Uniform", 25, 25, 25, 25, None))
|
||||
saveddata_engine.execute('INSERT INTO damagePatterns VALUES (?, ?, ?, ?, ?, ?, ?)',
|
||||
(1, "Uniform", 25, 25, 25, 25, None))
|
||||
|
||||
@@ -8,17 +8,16 @@ Migration 7
|
||||
Pyfa.
|
||||
"""
|
||||
|
||||
|
||||
CONVERSIONS = {
|
||||
640: ( # Scorpion
|
||||
4005, # Scorpion Ishukone Watch
|
||||
)
|
||||
}
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert ships
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "fits" SET "shipID" = ? WHERE "shipID" = ?', (replacement_item, retired_item))
|
||||
|
||||
saveddata_engine.execute('UPDATE "fits" SET "shipID" = ? WHERE "shipID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -7,7 +7,6 @@ Migration 8
|
||||
modules with their new replacements
|
||||
"""
|
||||
|
||||
|
||||
CONVERSIONS = {
|
||||
8529: ( # Large F-S9 Regolith Compact Shield Extender
|
||||
8409, # Large Subordinate Screen Stabilizer I
|
||||
@@ -71,15 +70,16 @@ CONVERSIONS = {
|
||||
11321, # 800mm Reinforced Nanofiber Plates I
|
||||
),
|
||||
11317: ( # 800mm Rolled Tungsten Compact Plates
|
||||
11315, # 800mm Reinforced Titanium Plates I
|
||||
11315, # 800mm Reinforced Titanium Plates I
|
||||
),
|
||||
}
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
# Convert modules
|
||||
for replacement_item, list in CONVERSIONS.iteritems():
|
||||
for retired_item in list:
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?', (replacement_item, retired_item))
|
||||
|
||||
saveddata_engine.execute('UPDATE "modules" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
saveddata_engine.execute('UPDATE "cargo" SET "itemID" = ? WHERE "itemID" = ?',
|
||||
(replacement_item, retired_item))
|
||||
|
||||
@@ -16,8 +16,10 @@ CREATE TABLE boostersTemp (
|
||||
)
|
||||
"""
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
saveddata_engine.execute(tmpTable)
|
||||
saveddata_engine.execute("INSERT INTO boostersTemp (ID, itemID, fitID, active) SELECT ID, itemID, fitID, active FROM boosters")
|
||||
saveddata_engine.execute(
|
||||
"INSERT INTO boostersTemp (ID, itemID, fitID, active) SELECT ID, itemID, fitID, active FROM boosters")
|
||||
saveddata_engine.execute("DROP TABLE boosters")
|
||||
saveddata_engine.execute("ALTER TABLE boostersTemp RENAME TO boosters")
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
# ===============================================================================
|
||||
|
||||
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
||||
from sqlalchemy.orm import *
|
||||
from sqlalchemy.orm import mapper, relation
|
||||
|
||||
from eos.db import saveddata_meta
|
||||
from eos.types import Fighter, Fit
|
||||
|
||||
@@ -17,20 +17,22 @@
|
||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||
# ===============================================================================
|
||||
|
||||
from sqlalchemy import *
|
||||
from sqlalchemy.ext.associationproxy import association_proxy
|
||||
from sqlalchemy.orm import *
|
||||
from sqlalchemy.orm.collections import attribute_mapped_collection
|
||||
from sqlalchemy.sql import and_
|
||||
from sqlalchemy.orm import relation, reconstructor, mapper, relationship
|
||||
from sqlalchemy import ForeignKey, Column, Integer, String, Table, Boolean
|
||||
|
||||
from eos.db import saveddata_meta
|
||||
from eos.db import saveddata_session
|
||||
from eos.db.saveddata.cargo import cargo_table
|
||||
from eos.db.saveddata.drone import drones_table
|
||||
from eos.db.saveddata.fighter import fighters_table
|
||||
from eos.db.saveddata.implant import fitImplants_table
|
||||
from eos.db.saveddata.module import modules_table
|
||||
from eos.effectHandlerHelpers import *
|
||||
from eos.types import Fit, Module, User, Booster, Drone, Fighter, Cargo, Implant, Character, DamagePattern, \
|
||||
from eos.effectHandlerHelpers import HandledModuleList, HandledImplantBoosterList, HandledProjectedModList, \
|
||||
HandledDroneCargoList, HandledProjectedDroneList
|
||||
from eos.types import Fit as es_Fit, Module, User, Booster, Drone, Fighter, Cargo, Implant, Character, DamagePattern, \
|
||||
TargetResists, ImplantLocation
|
||||
|
||||
fits_table = Table("fits", saveddata_meta,
|
||||
@@ -45,7 +47,7 @@ fits_table = Table("fits", saveddata_meta,
|
||||
Column("targetResistsID", ForeignKey("targetResists.ID"), nullable=True),
|
||||
Column("modeID", Integer, nullable=True),
|
||||
Column("implantLocation", Integer, nullable=False, default=ImplantLocation.FIT),
|
||||
Column("notes", String, nullable = True),
|
||||
Column("notes", String, nullable=True),
|
||||
)
|
||||
|
||||
projectedFits_table = Table("projectedFits", saveddata_meta,
|
||||
@@ -61,6 +63,7 @@ commandFits_table = Table("commandFits", saveddata_meta,
|
||||
Column("active", Boolean, nullable=False, default=1)
|
||||
)
|
||||
|
||||
|
||||
class ProjectedFit(object):
|
||||
def __init__(self, sourceID, source_fit, amount=1, active=True):
|
||||
self.sourceID = sourceID
|
||||
@@ -72,9 +75,9 @@ class ProjectedFit(object):
|
||||
def init(self):
|
||||
if self.source_fit.isInvalid:
|
||||
# Very rare for this to happen, but be prepared for it
|
||||
eos.db.saveddata_session.delete(self.source_fit)
|
||||
eos.db.saveddata_session.flush()
|
||||
eos.db.saveddata_session.refresh(self.victim_fit)
|
||||
saveddata_session.delete(self.source_fit)
|
||||
saveddata_session.flush()
|
||||
saveddata_session.refresh(self.victim_fit)
|
||||
|
||||
# We have a series of setters and getters here just in case someone
|
||||
# downgrades and screws up the table with NULL values
|
||||
@@ -91,6 +94,7 @@ class ProjectedFit(object):
|
||||
self.sourceID, self.victimID, self.amount, self.active, hex(id(self))
|
||||
)
|
||||
|
||||
|
||||
class CommandFit(object):
|
||||
def __init__(self, boosterID, booster_fit, active=True):
|
||||
self.boosterID = boosterID
|
||||
@@ -101,125 +105,126 @@ class CommandFit(object):
|
||||
def init(self):
|
||||
if self.booster_fit.isInvalid:
|
||||
# Very rare for this to happen, but be prepared for it
|
||||
eos.db.saveddata_session.delete(self.booster_fit)
|
||||
eos.db.saveddata_session.flush()
|
||||
eos.db.saveddata_session.refresh(self.boosted_fit)
|
||||
saveddata_session.delete(self.booster_fit)
|
||||
saveddata_session.flush()
|
||||
saveddata_session.refresh(self.boosted_fit)
|
||||
|
||||
def __repr__(self):
|
||||
return "CommandFit(boosterID={}, boostedID={}, active={}) at {}".format(
|
||||
self.boosterID, self.boostedID, self.active, hex(id(self))
|
||||
)
|
||||
|
||||
Fit._Fit__projectedFits = association_proxy(
|
||||
|
||||
es_Fit._Fit__projectedFits = association_proxy(
|
||||
"victimOf", # look at the victimOf association...
|
||||
"source_fit", # .. and return the source fits
|
||||
creator=lambda sourceID, source_fit: ProjectedFit(sourceID, source_fit)
|
||||
)
|
||||
|
||||
Fit._Fit__commandFits = association_proxy(
|
||||
es_Fit._Fit__commandFits = association_proxy(
|
||||
"boostedOf", # look at the boostedOf association...
|
||||
"booster_fit", # .. and return the booster fit
|
||||
creator=lambda boosterID, booster_fit: CommandFit(boosterID, booster_fit)
|
||||
)
|
||||
mapper(Fit, fits_table,
|
||||
properties={
|
||||
"_Fit__modules": relation(
|
||||
Module,
|
||||
collection_class=HandledModuleList,
|
||||
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == False),
|
||||
order_by=modules_table.c.position,
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"_Fit__projectedModules": relation(
|
||||
Module,
|
||||
collection_class=HandledProjectedModList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == True)),
|
||||
"owner": relation(
|
||||
User,
|
||||
backref="fits"),
|
||||
"itemID": fits_table.c.shipID,
|
||||
"shipID": fits_table.c.shipID,
|
||||
"_Fit__boosters": relation(
|
||||
Booster,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True),
|
||||
"_Fit__drones": relation(
|
||||
Drone,
|
||||
collection_class=HandledDroneCargoList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == False)),
|
||||
"_Fit__fighters": relation(
|
||||
Fighter,
|
||||
collection_class=HandledDroneCargoList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == False)),
|
||||
"_Fit__cargo": relation(
|
||||
Cargo,
|
||||
collection_class=HandledDroneCargoList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(cargo_table.c.fitID == fits_table.c.ID)),
|
||||
"_Fit__projectedDrones": relation(
|
||||
Drone,
|
||||
collection_class=HandledProjectedDroneList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == True)),
|
||||
"_Fit__projectedFighters": relation(
|
||||
Fighter,
|
||||
collection_class=HandledProjectedDroneList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == True)),
|
||||
"_Fit__implants": relation(
|
||||
Implant,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
backref='fit',
|
||||
single_parent=True,
|
||||
primaryjoin=fitImplants_table.c.fitID == fits_table.c.ID,
|
||||
secondaryjoin=fitImplants_table.c.implantID == Implant.ID,
|
||||
secondary=fitImplants_table),
|
||||
"_Fit__character": relation(
|
||||
Character,
|
||||
backref="fits"),
|
||||
"_Fit__damagePattern": relation(DamagePattern),
|
||||
"_Fit__targetResists": relation(TargetResists),
|
||||
"projectedOnto": relationship(
|
||||
ProjectedFit,
|
||||
primaryjoin=projectedFits_table.c.sourceID == fits_table.c.ID,
|
||||
backref='source_fit',
|
||||
collection_class=attribute_mapped_collection('victimID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"victimOf": relationship(
|
||||
ProjectedFit,
|
||||
primaryjoin=fits_table.c.ID == projectedFits_table.c.victimID,
|
||||
backref='victim_fit',
|
||||
collection_class=attribute_mapped_collection('sourceID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"boostedOnto": relationship(
|
||||
CommandFit,
|
||||
primaryjoin=commandFits_table.c.boosterID == fits_table.c.ID,
|
||||
backref='booster_fit',
|
||||
collection_class=attribute_mapped_collection('boostedID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"boostedOf": relationship(
|
||||
CommandFit,
|
||||
primaryjoin=fits_table.c.ID == commandFits_table.c.boostedID,
|
||||
backref='boosted_fit',
|
||||
collection_class=attribute_mapped_collection('boosterID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
}
|
||||
)
|
||||
mapper(es_Fit, fits_table,
|
||||
properties={
|
||||
"_Fit__modules": relation(
|
||||
Module,
|
||||
collection_class=HandledModuleList,
|
||||
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == False), # noqa
|
||||
order_by=modules_table.c.position,
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"_Fit__projectedModules": relation(
|
||||
Module,
|
||||
collection_class=HandledProjectedModList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == True)), # noqa
|
||||
"owner": relation(
|
||||
User,
|
||||
backref="fits"),
|
||||
"itemID": fits_table.c.shipID,
|
||||
"shipID": fits_table.c.shipID,
|
||||
"_Fit__boosters": relation(
|
||||
Booster,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True),
|
||||
"_Fit__drones": relation(
|
||||
Drone,
|
||||
collection_class=HandledDroneCargoList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == False)), # noqa
|
||||
"_Fit__fighters": relation(
|
||||
Fighter,
|
||||
collection_class=HandledDroneCargoList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == False)), # noqa
|
||||
"_Fit__cargo": relation(
|
||||
Cargo,
|
||||
collection_class=HandledDroneCargoList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(cargo_table.c.fitID == fits_table.c.ID)),
|
||||
"_Fit__projectedDrones": relation(
|
||||
Drone,
|
||||
collection_class=HandledProjectedDroneList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == True)), # noqa
|
||||
"_Fit__projectedFighters": relation(
|
||||
Fighter,
|
||||
collection_class=HandledProjectedDroneList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
single_parent=True,
|
||||
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == True)), # noqa
|
||||
"_Fit__implants": relation(
|
||||
Implant,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
backref='fit',
|
||||
single_parent=True,
|
||||
primaryjoin=fitImplants_table.c.fitID == fits_table.c.ID,
|
||||
secondaryjoin=fitImplants_table.c.implantID == Implant.ID,
|
||||
secondary=fitImplants_table),
|
||||
"_Fit__character": relation(
|
||||
Character,
|
||||
backref="fits"),
|
||||
"_Fit__damagePattern": relation(DamagePattern),
|
||||
"_Fit__targetResists": relation(TargetResists),
|
||||
"projectedOnto": relationship(
|
||||
ProjectedFit,
|
||||
primaryjoin=projectedFits_table.c.sourceID == fits_table.c.ID,
|
||||
backref='source_fit',
|
||||
collection_class=attribute_mapped_collection('victimID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"victimOf": relationship(
|
||||
ProjectedFit,
|
||||
primaryjoin=fits_table.c.ID == projectedFits_table.c.victimID,
|
||||
backref='victim_fit',
|
||||
collection_class=attribute_mapped_collection('sourceID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"boostedOnto": relationship(
|
||||
CommandFit,
|
||||
primaryjoin=commandFits_table.c.boosterID == fits_table.c.ID,
|
||||
backref='booster_fit',
|
||||
collection_class=attribute_mapped_collection('boostedID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
"boostedOf": relationship(
|
||||
CommandFit,
|
||||
primaryjoin=fits_table.c.ID == commandFits_table.c.boostedID,
|
||||
backref='boosted_fit',
|
||||
collection_class=attribute_mapped_collection('boosterID'),
|
||||
cascade='all, delete, delete-orphan'),
|
||||
}
|
||||
)
|
||||
|
||||
mapper(ProjectedFit, projectedFits_table,
|
||||
properties={
|
||||
"_ProjectedFit__amount": projectedFits_table.c.amount,
|
||||
}
|
||||
)
|
||||
properties={
|
||||
"_ProjectedFit__amount": projectedFits_table.c.amount,
|
||||
}
|
||||
)
|
||||
|
||||
mapper(CommandFit, commandFits_table)
|
||||
mapper(CommandFit, commandFits_table)
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
# ===============================================================================
|
||||
|
||||
import eos.db
|
||||
import eos.types
|
||||
from eos.saveddata.damagePattern import DamagePattern as es_DamagePattern
|
||||
from eos.saveddata.targetResists import TargetResists as es_TargetResists
|
||||
|
||||
|
||||
class ImportError(Exception):
|
||||
@@ -118,7 +119,7 @@ class DefaultDatabaseValues():
|
||||
name, em, therm, kin, exp = damageProfileRow
|
||||
damageProfile = eos.db.getDamagePattern(name)
|
||||
if damageProfile is None:
|
||||
damageProfile = eos.types.DamagePattern(em, therm, kin, exp)
|
||||
damageProfile = es_DamagePattern(em, therm, kin, exp)
|
||||
damageProfile.name = name
|
||||
eos.db.save(damageProfile)
|
||||
|
||||
@@ -180,7 +181,7 @@ class DefaultDatabaseValues():
|
||||
name, em, therm, kin, exp = targetResistProfileRow
|
||||
resistsProfile = eos.db.eos.db.getTargetResists(name)
|
||||
if resistsProfile is None:
|
||||
resistsProfile = eos.types.TargetResists(em, therm, kin, exp)
|
||||
resistsProfile = es_TargetResists(em, therm, kin, exp)
|
||||
resistsProfile.name = name
|
||||
eos.db.save(resistsProfile)
|
||||
|
||||
@@ -192,6 +193,6 @@ class DefaultDatabaseValues():
|
||||
name, em, therm, kin, exp = damageProfileRow
|
||||
damageProfile = eos.db.getDamagePattern(name)
|
||||
if damageProfile is None:
|
||||
damageProfile = eos.types.DamagePattern(em, therm, kin, exp)
|
||||
damageProfile = es_DamagePattern(em, therm, kin, exp)
|
||||
damageProfile.name = name
|
||||
eos.db.save(damageProfile)
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||
# ===============================================================================
|
||||
|
||||
from sqlalchemy.sql import and_
|
||||
|
||||
from eos.db import saveddata_session, sd_lock
|
||||
from eos.db.saveddata.fit import projectedFits_table
|
||||
from eos.db.util import processEager, processWhere
|
||||
from eos.db import saveddata_session, sd_lock
|
||||
|
||||
@@ -32,7 +36,6 @@ if configVal is True:
|
||||
itemCache = {}
|
||||
queryCache = {}
|
||||
|
||||
|
||||
def cachedQuery(type, amount, *keywords):
|
||||
itemCache[type] = localItemCache = weakref.WeakValueDictionary()
|
||||
queryCache[type] = typeQueryCache = {}
|
||||
@@ -91,7 +94,6 @@ if configVal is True:
|
||||
|
||||
return deco
|
||||
|
||||
|
||||
def removeCachedEntry(type, ID):
|
||||
if type not in queryCache:
|
||||
return
|
||||
@@ -121,7 +123,6 @@ else:
|
||||
|
||||
return deco
|
||||
|
||||
|
||||
def removeCachedEntry(*args, **kwargs):
|
||||
return
|
||||
|
||||
@@ -210,6 +211,7 @@ def getFit(lookfor, eager=None):
|
||||
|
||||
return fit
|
||||
|
||||
|
||||
def getFitsWithShip(shipID, ownerID=None, where=None, eager=None):
|
||||
"""
|
||||
Get all the fits using a certain ship.
|
||||
@@ -293,6 +295,7 @@ def getFitList(eager=None):
|
||||
|
||||
return fits
|
||||
|
||||
|
||||
@cachedQuery(Price, 1, "typeID")
|
||||
def getPrice(typeID):
|
||||
if isinstance(typeID, int):
|
||||
@@ -416,6 +419,7 @@ def searchFits(nameLike, where=None, eager=None):
|
||||
|
||||
return fits
|
||||
|
||||
|
||||
def getProjectedFits(fitID):
|
||||
if isinstance(fitID, int):
|
||||
with sd_lock:
|
||||
|
||||
Reference in New Issue
Block a user