Reformatting eos.db.saveddata
This commit is contained in:
@@ -17,4 +17,3 @@ __all__ = [
|
|||||||
"implantSet",
|
"implantSet",
|
||||||
"loadDefaultDatabaseValues"
|
"loadDefaultDatabaseValues"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,25 +15,26 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, ForeignKey, Integer, UniqueConstraint, Boolean
|
from sqlalchemy import Table, Column, ForeignKey, Integer, Boolean
|
||||||
from sqlalchemy.orm import mapper, relation
|
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
|
from sqlalchemy.orm import mapper, relation
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.types import Booster
|
from eos.types import Booster
|
||||||
|
|
||||||
boosters_table = Table("boosters", saveddata_meta,
|
boosters_table = Table("boosters", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("itemID", Integer),
|
Column("itemID", Integer),
|
||||||
Column("fitID", Integer, ForeignKey("fits.ID"), nullable = False),
|
Column("fitID", Integer, ForeignKey("fits.ID"), nullable=False),
|
||||||
Column("active", Boolean),
|
Column("active", Boolean),
|
||||||
)
|
)
|
||||||
|
|
||||||
activeSideEffects_table = Table("boostersActiveSideEffects", saveddata_meta,
|
activeSideEffects_table = Table("boostersActiveSideEffects", saveddata_meta,
|
||||||
Column("boosterID", ForeignKey("boosters.ID"), primary_key = True),
|
Column("boosterID", ForeignKey("boosters.ID"), primary_key=True),
|
||||||
Column("effectID", Integer, primary_key = True))
|
Column("effectID", Integer, primary_key=True))
|
||||||
|
|
||||||
|
|
||||||
class ActiveSideEffectsDummy(object):
|
class ActiveSideEffectsDummy(object):
|
||||||
def __init__(self, effectID):
|
def __init__(self, effectID):
|
||||||
@@ -42,6 +43,6 @@ class ActiveSideEffectsDummy(object):
|
|||||||
|
|
||||||
mapper(ActiveSideEffectsDummy, activeSideEffects_table)
|
mapper(ActiveSideEffectsDummy, activeSideEffects_table)
|
||||||
mapper(Booster, boosters_table,
|
mapper(Booster, boosters_table,
|
||||||
properties = {"_Booster__activeSideEffectDummies" : relation(ActiveSideEffectsDummy)})
|
properties={"_Booster__activeSideEffectDummies": relation(ActiveSideEffectsDummy)})
|
||||||
|
|
||||||
Booster._Booster__activeSideEffectIDs = association_proxy("_Booster__activeSideEffectDummies", "effectID")
|
Booster._Booster__activeSideEffectIDs = association_proxy("_Booster__activeSideEffectDummies", "effectID")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,18 +15,18 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
from sqlalchemy import Table, Column, Integer, ForeignKey
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.types import Cargo
|
from eos.types import Cargo
|
||||||
|
|
||||||
cargo_table = Table("cargo", saveddata_meta,
|
cargo_table = Table("cargo", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key=True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("fitID", Integer, ForeignKey("fits.ID"), nullable = False, index = True),
|
Column("fitID", Integer, ForeignKey("fits.ID"), nullable=False, index=True),
|
||||||
Column("itemID", Integer, nullable = False),
|
Column("itemID", Integer, nullable=False),
|
||||||
Column("amount", Integer, nullable = False))
|
Column("amount", Integer, nullable=False))
|
||||||
|
|
||||||
mapper(Cargo, cargo_table)
|
mapper(Cargo, cargo_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,44 +15,44 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, String
|
from sqlalchemy import Table, Column, Integer, ForeignKey, String
|
||||||
from sqlalchemy.orm import relation, mapper
|
from sqlalchemy.orm import relation, mapper
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.db.saveddata.implant import charImplants_table
|
from eos.db.saveddata.implant import charImplants_table
|
||||||
from eos.types import Character, User, Skill, Implant
|
|
||||||
from eos.effectHandlerHelpers import HandledImplantBoosterList
|
from eos.effectHandlerHelpers import HandledImplantBoosterList
|
||||||
|
from eos.types import Character, User, Skill, Implant
|
||||||
|
|
||||||
characters_table = Table("characters", saveddata_meta,
|
characters_table = Table("characters", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("name", String, nullable = False),
|
Column("name", String, nullable=False),
|
||||||
Column("apiID", Integer),
|
Column("apiID", Integer),
|
||||||
Column("apiKey", String),
|
Column("apiKey", String),
|
||||||
Column("defaultChar", Integer),
|
Column("defaultChar", Integer),
|
||||||
Column("chars", String, nullable = True),
|
Column("chars", String, nullable=True),
|
||||||
Column("defaultLevel", Integer, nullable=True),
|
Column("defaultLevel", Integer, nullable=True),
|
||||||
Column("ownerID", ForeignKey("users.ID"), nullable = True))
|
Column("ownerID", ForeignKey("users.ID"), nullable=True))
|
||||||
|
|
||||||
mapper(Character, characters_table,
|
mapper(Character, characters_table,
|
||||||
properties = {
|
properties={
|
||||||
"savedName": characters_table.c.name,
|
"savedName": characters_table.c.name,
|
||||||
"_Character__owner": relation(
|
"_Character__owner": relation(
|
||||||
User,
|
User,
|
||||||
backref = "characters"),
|
backref="characters"),
|
||||||
"_Character__skills": relation(
|
"_Character__skills": relation(
|
||||||
Skill,
|
Skill,
|
||||||
backref="character",
|
backref="character",
|
||||||
cascade = "all,delete-orphan"),
|
cascade="all,delete-orphan"),
|
||||||
"_Character__implants": relation(
|
"_Character__implants": relation(
|
||||||
Implant,
|
Implant,
|
||||||
collection_class = HandledImplantBoosterList,
|
collection_class=HandledImplantBoosterList,
|
||||||
cascade='all,delete-orphan',
|
cascade='all,delete-orphan',
|
||||||
backref='character',
|
backref='character',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin = charImplants_table.c.charID == characters_table.c.ID,
|
primaryjoin=charImplants_table.c.charID == characters_table.c.ID,
|
||||||
secondaryjoin = charImplants_table.c.implantID == Implant.ID,
|
secondaryjoin=charImplants_table.c.implantID == Implant.ID,
|
||||||
secondary = charImplants_table),
|
secondary=charImplants_table),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,17 +15,17 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, String, Boolean
|
from sqlalchemy import Table, Column, Integer, String
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.types import CrestChar
|
from eos.types import CrestChar
|
||||||
|
|
||||||
crest_table = Table("crest", saveddata_meta,
|
crest_table = Table("crest", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("name", String, nullable = False, unique = True),
|
Column("name", String, nullable=False, unique=True),
|
||||||
Column("refresh_token", String, nullable = False))
|
Column("refresh_token", String, nullable=False))
|
||||||
|
|
||||||
mapper(CrestChar, crest_table)
|
mapper(CrestChar, crest_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, String
|
from sqlalchemy import Table, Column, Integer, ForeignKey, String
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
@@ -24,7 +24,7 @@ from eos.db import saveddata_meta
|
|||||||
from eos.types import DamagePattern
|
from eos.types import DamagePattern
|
||||||
|
|
||||||
damagePatterns_table = Table("damagePatterns", saveddata_meta,
|
damagePatterns_table = Table("damagePatterns", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("name", String),
|
Column("name", String),
|
||||||
Column("emAmount", Integer),
|
Column("emAmount", Integer),
|
||||||
Column("thermalAmount", Integer),
|
Column("thermalAmount", Integer),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,19 +15,20 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.types import Drone
|
from eos.types import Drone
|
||||||
|
|
||||||
drones_table = Table("drones", saveddata_meta,
|
drones_table = Table("drones", saveddata_meta,
|
||||||
Column("groupID", Integer, primary_key=True),
|
Column("groupID", Integer, primary_key=True),
|
||||||
Column("fitID", Integer, ForeignKey("fits.ID"), nullable = False, index = True),
|
Column("fitID", Integer, ForeignKey("fits.ID"), nullable=False, index=True),
|
||||||
Column("itemID", Integer, nullable = False),
|
Column("itemID", Integer, nullable=False),
|
||||||
Column("amount", Integer, nullable = False),
|
Column("amount", Integer, nullable=False),
|
||||||
Column("amountActive", Integer, nullable = False),
|
Column("amountActive", Integer, nullable=False),
|
||||||
Column("projected", Boolean, default = False))
|
Column("projected", Boolean, default=False))
|
||||||
|
|
||||||
mapper(Drone, drones_table)
|
mapper(Drone, drones_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,38 +15,36 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import *
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.types import Fighter, Fit
|
from eos.types import Fighter, Fit
|
||||||
from sqlalchemy.orm import *
|
|
||||||
from sqlalchemy.sql import and_
|
|
||||||
from eos.effectHandlerHelpers import *
|
|
||||||
from eos.types import FighterAbility
|
from eos.types import FighterAbility
|
||||||
|
|
||||||
|
|
||||||
fighters_table = Table("fighters", saveddata_meta,
|
fighters_table = Table("fighters", saveddata_meta,
|
||||||
Column("groupID", Integer, primary_key=True),
|
Column("groupID", Integer, primary_key=True),
|
||||||
Column("fitID", Integer, ForeignKey("fits.ID"), nullable = False, index = True),
|
Column("fitID", Integer, ForeignKey("fits.ID"), nullable=False, index=True),
|
||||||
Column("itemID", Integer, nullable = False),
|
Column("itemID", Integer, nullable=False),
|
||||||
Column("active", Boolean, nullable=True),
|
Column("active", Boolean, nullable=True),
|
||||||
Column("amount", Integer, nullable = False),
|
Column("amount", Integer, nullable=False),
|
||||||
Column("projected", Boolean, default = False))
|
Column("projected", Boolean, default=False))
|
||||||
|
|
||||||
fighter_abilities_table = Table("fightersAbilities", saveddata_meta,
|
fighter_abilities_table = Table("fightersAbilities", saveddata_meta,
|
||||||
Column("groupID", Integer, ForeignKey("fighters.groupID"), primary_key=True, index = True),
|
Column("groupID", Integer, ForeignKey("fighters.groupID"), primary_key=True,
|
||||||
Column("effectID", Integer, nullable = False, primary_key=True),
|
index=True),
|
||||||
Column("active", Boolean, default = False))
|
Column("effectID", Integer, nullable=False, primary_key=True),
|
||||||
|
Column("active", Boolean, default=False))
|
||||||
|
|
||||||
mapper(Fighter, fighters_table,
|
mapper(Fighter, fighters_table,
|
||||||
properties = {
|
properties={
|
||||||
"owner": relation(Fit),
|
"owner": relation(Fit),
|
||||||
"_Fighter__abilities": relation(
|
"_Fighter__abilities": relation(
|
||||||
FighterAbility,
|
FighterAbility,
|
||||||
backref="fighter",
|
backref="fighter",
|
||||||
cascade='all, delete, delete-orphan'),
|
cascade='all, delete, delete-orphan'),
|
||||||
})
|
})
|
||||||
|
|
||||||
mapper(FighterAbility, fighter_abilities_table)
|
mapper(FighterAbility, fighter_abilities_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,43 +15,45 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import *
|
from sqlalchemy import *
|
||||||
from sqlalchemy.orm import *
|
|
||||||
from sqlalchemy.sql import and_
|
|
||||||
from sqlalchemy.ext.associationproxy import association_proxy
|
from sqlalchemy.ext.associationproxy import association_proxy
|
||||||
|
from sqlalchemy.orm import *
|
||||||
from sqlalchemy.orm.collections import attribute_mapped_collection
|
from sqlalchemy.orm.collections import attribute_mapped_collection
|
||||||
|
from sqlalchemy.sql import and_
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.db.saveddata.module import modules_table
|
from eos.db.saveddata.cargo import cargo_table
|
||||||
from eos.db.saveddata.drone import drones_table
|
from eos.db.saveddata.drone import drones_table
|
||||||
from eos.db.saveddata.fighter import fighters_table
|
from eos.db.saveddata.fighter import fighters_table
|
||||||
from eos.db.saveddata.cargo import cargo_table
|
|
||||||
from eos.db.saveddata.implant import fitImplants_table
|
from eos.db.saveddata.implant import fitImplants_table
|
||||||
from eos.types import Fit, Module, User, Booster, Drone, Fighter, Cargo, Implant, Character, DamagePattern, TargetResists, ImplantLocation
|
from eos.db.saveddata.module import modules_table
|
||||||
from eos.effectHandlerHelpers import *
|
from eos.effectHandlerHelpers import *
|
||||||
|
from eos.types import Fit, Module, User, Booster, Drone, Fighter, Cargo, Implant, Character, DamagePattern, \
|
||||||
|
TargetResists, ImplantLocation
|
||||||
|
|
||||||
fits_table = Table("fits", saveddata_meta,
|
fits_table = Table("fits", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("ownerID", ForeignKey("users.ID"), nullable = True, index = True),
|
Column("ownerID", ForeignKey("users.ID"), nullable=True, index=True),
|
||||||
Column("shipID", Integer, nullable = False, index = True),
|
Column("shipID", Integer, nullable=False, index=True),
|
||||||
Column("name", String, nullable = False),
|
Column("name", String, nullable=False),
|
||||||
Column("timestamp", Integer, nullable = False),
|
Column("timestamp", Integer, nullable=False),
|
||||||
Column("characterID", ForeignKey("characters.ID"), nullable = True),
|
Column("characterID", ForeignKey("characters.ID"), nullable=True),
|
||||||
Column("damagePatternID", ForeignKey("damagePatterns.ID"), nullable=True),
|
Column("damagePatternID", ForeignKey("damagePatterns.ID"), nullable=True),
|
||||||
Column("booster", Boolean, nullable = False, index = True, default = 0),
|
Column("booster", Boolean, nullable=False, index=True, default=0),
|
||||||
Column("targetResistsID", ForeignKey("targetResists.ID"), nullable=True),
|
Column("targetResistsID", ForeignKey("targetResists.ID"), nullable=True),
|
||||||
Column("modeID", Integer, nullable=True),
|
Column("modeID", Integer, nullable=True),
|
||||||
Column("implantLocation", Integer, nullable=False, default=ImplantLocation.FIT),
|
Column("implantLocation", Integer, nullable=False, default=ImplantLocation.FIT),
|
||||||
)
|
)
|
||||||
|
|
||||||
projectedFits_table = Table("projectedFits", saveddata_meta,
|
projectedFits_table = Table("projectedFits", saveddata_meta,
|
||||||
Column("sourceID", ForeignKey("fits.ID"), primary_key = True),
|
Column("sourceID", ForeignKey("fits.ID"), primary_key=True),
|
||||||
Column("victimID", ForeignKey("fits.ID"), primary_key = True),
|
Column("victimID", ForeignKey("fits.ID"), primary_key=True),
|
||||||
Column("amount", Integer, nullable = False, default = 1),
|
Column("amount", Integer, nullable=False, default=1),
|
||||||
Column("active", Boolean, nullable = False, default = 1),
|
Column("active", Boolean, nullable=False, default=1),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ProjectedFit(object):
|
class ProjectedFit(object):
|
||||||
def __init__(self, sourceID, source_fit, amount=1, active=True):
|
def __init__(self, sourceID, source_fit, amount=1, active=True):
|
||||||
@@ -83,6 +85,7 @@ class ProjectedFit(object):
|
|||||||
self.sourceID, self.victimID, self.amount, self.active, hex(id(self))
|
self.sourceID, self.victimID, self.amount, self.active, hex(id(self))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
Fit._Fit__projectedFits = association_proxy(
|
Fit._Fit__projectedFits = association_proxy(
|
||||||
"victimOf", # look at the victimOf association...
|
"victimOf", # look at the victimOf association...
|
||||||
"source_fit", # .. and return the source fits
|
"source_fit", # .. and return the source fits
|
||||||
@@ -90,90 +93,90 @@ Fit._Fit__projectedFits = association_proxy(
|
|||||||
)
|
)
|
||||||
|
|
||||||
mapper(Fit, fits_table,
|
mapper(Fit, fits_table,
|
||||||
properties = {
|
properties={
|
||||||
"_Fit__modules": relation(
|
"_Fit__modules": relation(
|
||||||
Module,
|
Module,
|
||||||
collection_class=HandledModuleList,
|
collection_class=HandledModuleList,
|
||||||
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == False),
|
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == False),
|
||||||
order_by=modules_table.c.position,
|
order_by=modules_table.c.position,
|
||||||
cascade='all, delete, delete-orphan'),
|
cascade='all, delete, delete-orphan'),
|
||||||
"_Fit__projectedModules": relation(
|
"_Fit__projectedModules": relation(
|
||||||
Module,
|
Module,
|
||||||
collection_class=HandledProjectedModList,
|
collection_class=HandledProjectedModList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == True)),
|
primaryjoin=and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == True)),
|
||||||
"owner": relation(
|
"owner": relation(
|
||||||
User,
|
User,
|
||||||
backref="fits"),
|
backref="fits"),
|
||||||
"itemID": fits_table.c.shipID,
|
"itemID": fits_table.c.shipID,
|
||||||
"shipID": fits_table.c.shipID,
|
"shipID": fits_table.c.shipID,
|
||||||
"_Fit__boosters": relation(
|
"_Fit__boosters": relation(
|
||||||
Booster,
|
Booster,
|
||||||
collection_class=HandledImplantBoosterList,
|
collection_class=HandledImplantBoosterList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
single_parent=True),
|
single_parent=True),
|
||||||
"_Fit__drones": relation(
|
"_Fit__drones": relation(
|
||||||
Drone,
|
Drone,
|
||||||
collection_class=HandledDroneCargoList,
|
collection_class=HandledDroneCargoList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == False)),
|
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == False)),
|
||||||
"_Fit__fighters": relation(
|
"_Fit__fighters": relation(
|
||||||
Fighter,
|
Fighter,
|
||||||
collection_class=HandledDroneCargoList,
|
collection_class=HandledDroneCargoList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == False)),
|
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == False)),
|
||||||
"_Fit__cargo": relation(
|
"_Fit__cargo": relation(
|
||||||
Cargo,
|
Cargo,
|
||||||
collection_class=HandledDroneCargoList,
|
collection_class=HandledDroneCargoList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin=and_(cargo_table.c.fitID == fits_table.c.ID)),
|
primaryjoin=and_(cargo_table.c.fitID == fits_table.c.ID)),
|
||||||
"_Fit__projectedDrones": relation(
|
"_Fit__projectedDrones": relation(
|
||||||
Drone,
|
Drone,
|
||||||
collection_class=HandledProjectedDroneList,
|
collection_class=HandledProjectedDroneList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == True)),
|
primaryjoin=and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == True)),
|
||||||
"_Fit__projectedFighters": relation(
|
"_Fit__projectedFighters": relation(
|
||||||
Fighter,
|
Fighter,
|
||||||
collection_class=HandledProjectedDroneList,
|
collection_class=HandledProjectedDroneList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == True)),
|
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == True)),
|
||||||
"_Fit__implants": relation(
|
"_Fit__implants": relation(
|
||||||
Implant,
|
Implant,
|
||||||
collection_class=HandledImplantBoosterList,
|
collection_class=HandledImplantBoosterList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
backref='fit',
|
backref='fit',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin=fitImplants_table.c.fitID == fits_table.c.ID,
|
primaryjoin=fitImplants_table.c.fitID == fits_table.c.ID,
|
||||||
secondaryjoin=fitImplants_table.c.implantID == Implant.ID,
|
secondaryjoin=fitImplants_table.c.implantID == Implant.ID,
|
||||||
secondary=fitImplants_table),
|
secondary=fitImplants_table),
|
||||||
"_Fit__character": relation(
|
"_Fit__character": relation(
|
||||||
Character,
|
Character,
|
||||||
backref="fits"),
|
backref="fits"),
|
||||||
"_Fit__damagePattern": relation(DamagePattern),
|
"_Fit__damagePattern": relation(DamagePattern),
|
||||||
"_Fit__targetResists": relation(TargetResists),
|
"_Fit__targetResists": relation(TargetResists),
|
||||||
"projectedOnto": relationship(
|
"projectedOnto": relationship(
|
||||||
ProjectedFit,
|
ProjectedFit,
|
||||||
primaryjoin=projectedFits_table.c.sourceID == fits_table.c.ID,
|
primaryjoin=projectedFits_table.c.sourceID == fits_table.c.ID,
|
||||||
backref='source_fit',
|
backref='source_fit',
|
||||||
collection_class=attribute_mapped_collection('victimID'),
|
collection_class=attribute_mapped_collection('victimID'),
|
||||||
cascade='all, delete, delete-orphan'),
|
cascade='all, delete, delete-orphan'),
|
||||||
"victimOf": relationship(
|
"victimOf": relationship(
|
||||||
ProjectedFit,
|
ProjectedFit,
|
||||||
primaryjoin=fits_table.c.ID == projectedFits_table.c.victimID,
|
primaryjoin=fits_table.c.ID == projectedFits_table.c.victimID,
|
||||||
backref='victim_fit',
|
backref='victim_fit',
|
||||||
collection_class=attribute_mapped_collection('sourceID'),
|
collection_class=attribute_mapped_collection('sourceID'),
|
||||||
cascade='all, delete, delete-orphan'),
|
cascade='all, delete, delete-orphan'),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
mapper(ProjectedFit, projectedFits_table,
|
mapper(ProjectedFit, projectedFits_table,
|
||||||
properties = {
|
properties={
|
||||||
"_ProjectedFit__amount": projectedFits_table.c.amount,
|
"_ProjectedFit__amount": projectedFits_table.c.amount,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,52 +15,51 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, String
|
from sqlalchemy import Table, Column, Integer, ForeignKey, String
|
||||||
from sqlalchemy.orm import mapper, relation
|
from sqlalchemy.orm import mapper, relation
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.types import Fleet, Wing, Squad, Fit
|
|
||||||
from eos.db.saveddata.fit import fits_table
|
from eos.db.saveddata.fit import fits_table
|
||||||
|
from eos.types import Fleet, Wing, Squad, Fit
|
||||||
|
|
||||||
gangs_table = Table("gangs", saveddata_meta,
|
gangs_table = Table("gangs", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("leaderID", ForeignKey("fits.ID")),
|
Column("leaderID", ForeignKey("fits.ID")),
|
||||||
Column("boosterID", ForeignKey("fits.ID")),
|
Column("boosterID", ForeignKey("fits.ID")),
|
||||||
Column("name", String))
|
Column("name", String))
|
||||||
|
|
||||||
wings_table = Table("wings", saveddata_meta,
|
wings_table = Table("wings", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("gangID", ForeignKey("gangs.ID")),
|
Column("gangID", ForeignKey("gangs.ID")),
|
||||||
Column("boosterID", ForeignKey("fits.ID")),
|
Column("boosterID", ForeignKey("fits.ID")),
|
||||||
Column("leaderID", ForeignKey("fits.ID")))
|
Column("leaderID", ForeignKey("fits.ID")))
|
||||||
|
|
||||||
squads_table = Table("squads", saveddata_meta,
|
squads_table = Table("squads", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("wingID", ForeignKey("wings.ID")),
|
Column("wingID", ForeignKey("wings.ID")),
|
||||||
Column("leaderID", ForeignKey("fits.ID")),
|
Column("leaderID", ForeignKey("fits.ID")),
|
||||||
Column("boosterID", ForeignKey("fits.ID")))
|
Column("boosterID", ForeignKey("fits.ID")))
|
||||||
|
|
||||||
squadmembers_table = Table("squadmembers", saveddata_meta,
|
squadmembers_table = Table("squadmembers", saveddata_meta,
|
||||||
Column("squadID", ForeignKey("squads.ID"), primary_key = True),
|
Column("squadID", ForeignKey("squads.ID"), primary_key=True),
|
||||||
Column("memberID", ForeignKey("fits.ID"), primary_key = True))
|
Column("memberID", ForeignKey("fits.ID"), primary_key=True))
|
||||||
|
|
||||||
mapper(Fleet, gangs_table,
|
mapper(Fleet, gangs_table,
|
||||||
properties = {"wings" : relation(Wing, backref="gang"),
|
properties={"wings": relation(Wing, backref="gang"),
|
||||||
"leader" : relation(Fit, primaryjoin = gangs_table.c.leaderID == fits_table.c.ID),
|
"leader": relation(Fit, primaryjoin=gangs_table.c.leaderID == fits_table.c.ID),
|
||||||
"booster": relation(Fit, primaryjoin = gangs_table.c.boosterID == fits_table.c.ID)})
|
"booster": relation(Fit, primaryjoin=gangs_table.c.boosterID == fits_table.c.ID)})
|
||||||
|
|
||||||
mapper(Wing, wings_table,
|
mapper(Wing, wings_table,
|
||||||
properties = {"squads" : relation(Squad, backref="wing"),
|
properties={"squads": relation(Squad, backref="wing"),
|
||||||
"leader" : relation(Fit, primaryjoin = wings_table.c.leaderID == fits_table.c.ID),
|
"leader": relation(Fit, primaryjoin=wings_table.c.leaderID == fits_table.c.ID),
|
||||||
"booster": relation(Fit, primaryjoin = wings_table.c.boosterID == fits_table.c.ID)})
|
"booster": relation(Fit, primaryjoin=wings_table.c.boosterID == fits_table.c.ID)})
|
||||||
|
|
||||||
mapper(Squad, squads_table,
|
mapper(Squad, squads_table,
|
||||||
properties = {"leader" : relation(Fit, primaryjoin = squads_table.c.leaderID == fits_table.c.ID),
|
properties={"leader": relation(Fit, primaryjoin=squads_table.c.leaderID == fits_table.c.ID),
|
||||||
"booster" : relation(Fit, primaryjoin = squads_table.c.boosterID == fits_table.c.ID),
|
"booster": relation(Fit, primaryjoin=squads_table.c.boosterID == fits_table.c.ID),
|
||||||
"members" : relation(Fit,
|
"members": relation(Fit,
|
||||||
primaryjoin = squads_table.c.ID == squadmembers_table.c.squadID,
|
primaryjoin=squads_table.c.ID == squadmembers_table.c.squadID,
|
||||||
secondaryjoin = squadmembers_table.c.memberID == fits_table.c.ID,
|
secondaryjoin=squadmembers_table.c.memberID == fits_table.c.ID,
|
||||||
secondary = squadmembers_table)})
|
secondary=squadmembers_table)})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
from sqlalchemy import Table, Column, Integer, ForeignKey, Boolean
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
@@ -24,20 +24,20 @@ from eos.db import saveddata_meta
|
|||||||
from eos.types import Implant
|
from eos.types import Implant
|
||||||
|
|
||||||
implants_table = Table("implants", saveddata_meta,
|
implants_table = Table("implants", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("itemID", Integer),
|
Column("itemID", Integer),
|
||||||
Column("active", Boolean))
|
Column("active", Boolean))
|
||||||
|
|
||||||
fitImplants_table = Table("fitImplants", saveddata_meta,
|
fitImplants_table = Table("fitImplants", saveddata_meta,
|
||||||
Column("fitID", ForeignKey("fits.ID"), index = True),
|
Column("fitID", ForeignKey("fits.ID"), index=True),
|
||||||
Column("implantID", ForeignKey("implants.ID"), primary_key = True))
|
Column("implantID", ForeignKey("implants.ID"), primary_key=True))
|
||||||
|
|
||||||
charImplants_table = Table("charImplants", saveddata_meta,
|
charImplants_table = Table("charImplants", saveddata_meta,
|
||||||
Column("charID", ForeignKey("characters.ID"), index = True),
|
Column("charID", ForeignKey("characters.ID"), index=True),
|
||||||
Column("implantID", ForeignKey("implants.ID"), primary_key = True))
|
Column("implantID", ForeignKey("implants.ID"), primary_key=True))
|
||||||
|
|
||||||
implantsSetMap_table = Table("implantSetMap", saveddata_meta,
|
implantsSetMap_table = Table("implantSetMap", saveddata_meta,
|
||||||
Column("setID", ForeignKey("implantSets.ID"), index = True),
|
Column("setID", ForeignKey("implantSets.ID"), index=True),
|
||||||
Column("implantID", ForeignKey("implants.ID"), primary_key = True))
|
Column("implantID", ForeignKey("implants.ID"), primary_key=True))
|
||||||
|
|
||||||
mapper(Implant, implants_table)
|
mapper(Implant, implants_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2016 Ryan Holmes
|
# Copyright (C) 2016 Ryan Holmes
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,31 +15,31 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, String
|
from sqlalchemy import Table, Column, Integer, String
|
||||||
from sqlalchemy.orm import relation, mapper
|
from sqlalchemy.orm import relation, mapper
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.db.saveddata.implant import implantsSetMap_table
|
from eos.db.saveddata.implant import implantsSetMap_table
|
||||||
from eos.types import Implant, ImplantSet
|
|
||||||
from eos.effectHandlerHelpers import HandledImplantBoosterList
|
from eos.effectHandlerHelpers import HandledImplantBoosterList
|
||||||
|
from eos.types import Implant, ImplantSet
|
||||||
|
|
||||||
implant_set_table = Table("implantSets", saveddata_meta,
|
implant_set_table = Table("implantSets", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("name", String, nullable = False),
|
Column("name", String, nullable=False),
|
||||||
)
|
)
|
||||||
|
|
||||||
mapper(ImplantSet, implant_set_table,
|
mapper(ImplantSet, implant_set_table,
|
||||||
properties = {
|
properties={
|
||||||
"_ImplantSet__implants": relation(
|
"_ImplantSet__implants": relation(
|
||||||
Implant,
|
Implant,
|
||||||
collection_class = HandledImplantBoosterList,
|
collection_class=HandledImplantBoosterList,
|
||||||
cascade='all, delete, delete-orphan',
|
cascade='all, delete, delete-orphan',
|
||||||
backref='set',
|
backref='set',
|
||||||
single_parent=True,
|
single_parent=True,
|
||||||
primaryjoin = implantsSetMap_table.c.setID == implant_set_table.c.ID,
|
primaryjoin=implantsSetMap_table.c.setID == implant_set_table.c.ID,
|
||||||
secondaryjoin = implantsSetMap_table.c.implantID == Implant.ID,
|
secondaryjoin=implantsSetMap_table.c.implantID == Implant.ID,
|
||||||
secondary = implantsSetMap_table),
|
secondary=implantsSetMap_table),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of pyfa.
|
# This file is part of pyfa.
|
||||||
@@ -15,14 +15,16 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
import eos.db
|
import eos.db
|
||||||
import eos.types
|
import eos.types
|
||||||
|
|
||||||
|
|
||||||
class ImportError(Exception):
|
class ImportError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DefaultDatabaseValues():
|
class DefaultDatabaseValues():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2011 Anton Vorobyov
|
# Copyright (C) 2011 Anton Vorobyov
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,15 +15,16 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Column, Table, String
|
from sqlalchemy import Column, Table, String
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
from eos.types import MiscData
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
|
from eos.types import MiscData
|
||||||
|
|
||||||
miscdata_table = Table("miscdata", saveddata_meta,
|
miscdata_table = Table("miscdata", saveddata_meta,
|
||||||
Column("fieldName", String, primary_key=True),
|
Column("fieldName", String, primary_key=True),
|
||||||
Column("fieldValue", String))
|
Column("fieldValue", String))
|
||||||
|
|
||||||
mapper(MiscData, miscdata_table)
|
mapper(MiscData, miscdata_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey, CheckConstraint, Boolean
|
from sqlalchemy import Table, Column, Integer, ForeignKey, CheckConstraint, Boolean
|
||||||
from sqlalchemy.orm import relation, mapper
|
from sqlalchemy.orm import relation, mapper
|
||||||
@@ -24,16 +24,15 @@ from eos.db import saveddata_meta
|
|||||||
from eos.types import Module, Fit
|
from eos.types import Module, Fit
|
||||||
|
|
||||||
modules_table = Table("modules", saveddata_meta,
|
modules_table = Table("modules", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("fitID", Integer, ForeignKey("fits.ID"), nullable = False, index = True),
|
Column("fitID", Integer, ForeignKey("fits.ID"), nullable=False, index=True),
|
||||||
Column("itemID", Integer, nullable = True),
|
Column("itemID", Integer, nullable=True),
|
||||||
Column("dummySlot", Integer, nullable = True, default = None),
|
Column("dummySlot", Integer, nullable=True, default=None),
|
||||||
Column("chargeID", Integer),
|
Column("chargeID", Integer),
|
||||||
Column("state", Integer, CheckConstraint("state >= -1"), CheckConstraint("state <= 2")),
|
Column("state", Integer, CheckConstraint("state >= -1"), CheckConstraint("state <= 2")),
|
||||||
Column("projected", Boolean, default = False, nullable = False),
|
Column("projected", Boolean, default=False, nullable=False),
|
||||||
Column("position", Integer),
|
Column("position", Integer),
|
||||||
CheckConstraint('("dummySlot" = NULL OR "itemID" = NULL) AND "dummySlot" != "itemID"'))
|
CheckConstraint('("dummySlot" = NULL OR "itemID" = NULL) AND "dummySlot" != "itemID"'))
|
||||||
|
|
||||||
mapper(Module, modules_table,
|
mapper(Module, modules_table,
|
||||||
properties = {"owner" : relation(Fit)})
|
properties={"owner": relation(Fit)})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, Float
|
from sqlalchemy import Table, Column, Integer, Float
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
@@ -24,8 +24,8 @@ from eos.db import saveddata_meta
|
|||||||
from eos.types import Override
|
from eos.types import Override
|
||||||
|
|
||||||
overrides_table = Table("overrides", saveddata_meta,
|
overrides_table = Table("overrides", saveddata_meta,
|
||||||
Column("itemID", Integer, primary_key=True, index = True),
|
Column("itemID", Integer, primary_key=True, index=True),
|
||||||
Column("attrID", Integer, primary_key=True, index = True),
|
Column("attrID", Integer, primary_key=True, index=True),
|
||||||
Column("value", Float, nullable = False))
|
Column("value", Float, nullable=False))
|
||||||
|
|
||||||
mapper(Override, overrides_table)
|
mapper(Override, overrides_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,17 +15,18 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Float, Integer
|
from sqlalchemy import Table, Column, Float, Integer
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
|
|
||||||
from eos.db import saveddata_meta
|
from eos.db import saveddata_meta
|
||||||
from eos.types import Price
|
from eos.types import Price
|
||||||
|
|
||||||
prices_table = Table("prices", saveddata_meta,
|
prices_table = Table("prices", saveddata_meta,
|
||||||
Column("typeID", Integer, primary_key=True),
|
Column("typeID", Integer, primary_key=True),
|
||||||
Column("price", Float),
|
Column("price", Float),
|
||||||
Column("time", Integer, nullable = False),
|
Column("time", Integer, nullable=False),
|
||||||
Column("failed", Integer))
|
Column("failed", Integer))
|
||||||
|
|
||||||
mapper(Price, prices_table)
|
mapper(Price, prices_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,27 +15,32 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from eos.db.util import processEager, processWhere
|
|
||||||
from eos.db import saveddata_session, sd_lock
|
|
||||||
|
|
||||||
from eos.types import *
|
|
||||||
from eos.db.saveddata.fleet import squadmembers_table
|
|
||||||
from eos.db.saveddata.fit import projectedFits_table
|
|
||||||
from sqlalchemy.sql import and_
|
from sqlalchemy.sql import and_
|
||||||
|
|
||||||
import eos.config
|
import eos.config
|
||||||
|
from eos.db import saveddata_session, sd_lock
|
||||||
|
from eos.db.saveddata.fit import projectedFits_table
|
||||||
|
from eos.db.saveddata.fleet import squadmembers_table
|
||||||
|
from eos.db.util import processEager, processWhere
|
||||||
|
from eos.types import *
|
||||||
|
|
||||||
configVal = getattr(eos.config, "saveddataCache", None)
|
configVal = getattr(eos.config, "saveddataCache", None)
|
||||||
if configVal is True:
|
if configVal is True:
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
itemCache = {}
|
itemCache = {}
|
||||||
queryCache = {}
|
queryCache = {}
|
||||||
|
|
||||||
|
|
||||||
def cachedQuery(type, amount, *keywords):
|
def cachedQuery(type, amount, *keywords):
|
||||||
itemCache[type] = localItemCache = weakref.WeakValueDictionary()
|
itemCache[type] = localItemCache = weakref.WeakValueDictionary()
|
||||||
queryCache[type] = typeQueryCache = {}
|
queryCache[type] = typeQueryCache = {}
|
||||||
|
|
||||||
def deco(function):
|
def deco(function):
|
||||||
localQueryCache = typeQueryCache[function] = {}
|
localQueryCache = typeQueryCache[function] = {}
|
||||||
|
|
||||||
def setCache(cacheKey, args, kwargs):
|
def setCache(cacheKey, args, kwargs):
|
||||||
items = function(*args, **kwargs)
|
items = function(*args, **kwargs)
|
||||||
IDs = set()
|
IDs = set()
|
||||||
@@ -44,7 +49,7 @@ if configVal is True:
|
|||||||
for item in stuff:
|
for item in stuff:
|
||||||
ID = getattr(item, "ID", None)
|
ID = getattr(item, "ID", None)
|
||||||
if ID is None:
|
if ID is None:
|
||||||
#Some uncachable data, don't cache this query
|
# Some uncachable data, don't cache this query
|
||||||
del localQueryCache[cacheKey]
|
del localQueryCache[cacheKey]
|
||||||
break
|
break
|
||||||
localItemCache[ID] = item
|
localItemCache[ID] = item
|
||||||
@@ -70,7 +75,7 @@ if configVal is True:
|
|||||||
for ID in IDs:
|
for ID in IDs:
|
||||||
data = localItemCache.get(ID)
|
data = localItemCache.get(ID)
|
||||||
if data is None:
|
if data is None:
|
||||||
#Fuck, some of our stuff isn't cached it seems.
|
# Fuck, some of our stuff isn't cached it seems.
|
||||||
items = setCache(cacheKey, args, kwargs)
|
items = setCache(cacheKey, args, kwargs)
|
||||||
break
|
break
|
||||||
items.append(data)
|
items.append(data)
|
||||||
@@ -82,9 +87,12 @@ if configVal is True:
|
|||||||
break
|
break
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
return checkAndReturn
|
return checkAndReturn
|
||||||
|
|
||||||
return deco
|
return deco
|
||||||
|
|
||||||
|
|
||||||
def removeCachedEntry(type, ID):
|
def removeCachedEntry(type, ID):
|
||||||
if not type in queryCache:
|
if not type in queryCache:
|
||||||
return
|
return
|
||||||
@@ -111,11 +119,14 @@ else:
|
|||||||
return function(*args, **kwargs)
|
return function(*args, **kwargs)
|
||||||
|
|
||||||
return checkAndReturn
|
return checkAndReturn
|
||||||
|
|
||||||
return deco
|
return deco
|
||||||
|
|
||||||
|
|
||||||
def removeCachedEntry(*args, **kwargs):
|
def removeCachedEntry(*args, **kwargs):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def sqlizeString(line):
|
def sqlizeString(line):
|
||||||
# Escape backslashes first, as they will be as escape symbol in queries
|
# Escape backslashes first, as they will be as escape symbol in queries
|
||||||
# Then escape percent and underscore signs
|
# Then escape percent and underscore signs
|
||||||
@@ -123,6 +134,7 @@ def sqlizeString(line):
|
|||||||
line = line.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_").replace("*", "%")
|
line = line.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_").replace("*", "%")
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(User, 1, "lookfor")
|
@cachedQuery(User, 1, "lookfor")
|
||||||
def getUser(lookfor, eager=None):
|
def getUser(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
@@ -141,6 +153,7 @@ def getUser(lookfor, eager=None):
|
|||||||
raise TypeError("Need integer or string as argument")
|
raise TypeError("Need integer or string as argument")
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(Character, 1, "lookfor")
|
@cachedQuery(Character, 1, "lookfor")
|
||||||
def getCharacter(lookfor, eager=None):
|
def getCharacter(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
@@ -154,17 +167,20 @@ def getCharacter(lookfor, eager=None):
|
|||||||
elif isinstance(lookfor, basestring):
|
elif isinstance(lookfor, basestring):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
character = saveddata_session.query(Character).options(*eager).filter(Character.savedName == lookfor).first()
|
character = saveddata_session.query(Character).options(*eager).filter(
|
||||||
|
Character.savedName == lookfor).first()
|
||||||
else:
|
else:
|
||||||
raise TypeError("Need integer or string as argument")
|
raise TypeError("Need integer or string as argument")
|
||||||
return character
|
return character
|
||||||
|
|
||||||
|
|
||||||
def getCharacterList(eager=None):
|
def getCharacterList(eager=None):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
characters = saveddata_session.query(Character).options(*eager).all()
|
characters = saveddata_session.query(Character).options(*eager).all()
|
||||||
return characters
|
return characters
|
||||||
|
|
||||||
|
|
||||||
def getCharactersForUser(lookfor, eager=None):
|
def getCharactersForUser(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
@@ -174,6 +190,7 @@ def getCharactersForUser(lookfor, eager=None):
|
|||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
return characters
|
return characters
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(Fit, 1, "lookfor")
|
@cachedQuery(Fit, 1, "lookfor")
|
||||||
def getFit(lookfor, eager=None):
|
def getFit(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
@@ -194,6 +211,7 @@ def getFit(lookfor, eager=None):
|
|||||||
|
|
||||||
return fit
|
return fit
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(Fleet, 1, "fleetID")
|
@cachedQuery(Fleet, 1, "fleetID")
|
||||||
def getFleet(fleetID, eager=None):
|
def getFleet(fleetID, eager=None):
|
||||||
if isinstance(fleetID, int):
|
if isinstance(fleetID, int):
|
||||||
@@ -208,6 +226,7 @@ def getFleet(fleetID, eager=None):
|
|||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
return fleet
|
return fleet
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(Wing, 1, "wingID")
|
@cachedQuery(Wing, 1, "wingID")
|
||||||
def getWing(wingID, eager=None):
|
def getWing(wingID, eager=None):
|
||||||
if isinstance(wingID, int):
|
if isinstance(wingID, int):
|
||||||
@@ -222,6 +241,7 @@ def getWing(wingID, eager=None):
|
|||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
return wing
|
return wing
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(Squad, 1, "squadID")
|
@cachedQuery(Squad, 1, "squadID")
|
||||||
def getSquad(squadID, eager=None):
|
def getSquad(squadID, eager=None):
|
||||||
if isinstance(squadID, int):
|
if isinstance(squadID, int):
|
||||||
@@ -236,6 +256,7 @@ def getSquad(squadID, eager=None):
|
|||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
return squad
|
return squad
|
||||||
|
|
||||||
|
|
||||||
def getFitsWithShip(shipID, ownerID=None, where=None, eager=None):
|
def getFitsWithShip(shipID, ownerID=None, where=None, eager=None):
|
||||||
"""
|
"""
|
||||||
Get all the fits using a certain ship.
|
Get all the fits using a certain ship.
|
||||||
@@ -257,6 +278,7 @@ def getFitsWithShip(shipID, ownerID=None, where=None, eager=None):
|
|||||||
|
|
||||||
return fits
|
return fits
|
||||||
|
|
||||||
|
|
||||||
def getBoosterFits(ownerID=None, where=None, eager=None):
|
def getBoosterFits(ownerID=None, where=None, eager=None):
|
||||||
"""
|
"""
|
||||||
Get all the fits that are flagged as a boosting ship
|
Get all the fits that are flagged as a boosting ship
|
||||||
@@ -276,11 +298,13 @@ def getBoosterFits(ownerID=None, where=None, eager=None):
|
|||||||
|
|
||||||
return fits
|
return fits
|
||||||
|
|
||||||
|
|
||||||
def countAllFits():
|
def countAllFits():
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
count = saveddata_session.query(Fit).count()
|
count = saveddata_session.query(Fit).count()
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|
||||||
def countFitsWithShip(shipID, ownerID=None, where=None, eager=None):
|
def countFitsWithShip(shipID, ownerID=None, where=None, eager=None):
|
||||||
"""
|
"""
|
||||||
Get all the fits using a certain ship.
|
Get all the fits using a certain ship.
|
||||||
@@ -301,6 +325,7 @@ def countFitsWithShip(shipID, ownerID=None, where=None, eager=None):
|
|||||||
raise TypeError("ShipID must be integer")
|
raise TypeError("ShipID must be integer")
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|
||||||
def getFitList(eager=None):
|
def getFitList(eager=None):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
@@ -308,12 +333,14 @@ def getFitList(eager=None):
|
|||||||
|
|
||||||
return fits
|
return fits
|
||||||
|
|
||||||
|
|
||||||
def getFleetList(eager=None):
|
def getFleetList(eager=None):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
fleets = saveddata_session.query(Fleet).options(*eager).all()
|
fleets = saveddata_session.query(Fleet).options(*eager).all()
|
||||||
return fleets
|
return fleets
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(Price, 1, "typeID")
|
@cachedQuery(Price, 1, "typeID")
|
||||||
def getPrice(typeID):
|
def getPrice(typeID):
|
||||||
if isinstance(typeID, int):
|
if isinstance(typeID, int):
|
||||||
@@ -323,12 +350,14 @@ def getPrice(typeID):
|
|||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
return price
|
return price
|
||||||
|
|
||||||
|
|
||||||
def clearPrices():
|
def clearPrices():
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
deleted_rows = saveddata_session.query(Price).delete()
|
deleted_rows = saveddata_session.query(Price).delete()
|
||||||
commit()
|
commit()
|
||||||
return deleted_rows
|
return deleted_rows
|
||||||
|
|
||||||
|
|
||||||
def getMiscData(field):
|
def getMiscData(field):
|
||||||
if isinstance(field, basestring):
|
if isinstance(field, basestring):
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
@@ -337,24 +366,28 @@ def getMiscData(field):
|
|||||||
raise TypeError("Need string as argument")
|
raise TypeError("Need string as argument")
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def getDamagePatternList(eager=None):
|
def getDamagePatternList(eager=None):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
patterns = saveddata_session.query(DamagePattern).options(*eager).all()
|
patterns = saveddata_session.query(DamagePattern).options(*eager).all()
|
||||||
return patterns
|
return patterns
|
||||||
|
|
||||||
|
|
||||||
def getTargetResistsList(eager=None):
|
def getTargetResistsList(eager=None):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
patterns = saveddata_session.query(TargetResists).options(*eager).all()
|
patterns = saveddata_session.query(TargetResists).options(*eager).all()
|
||||||
return patterns
|
return patterns
|
||||||
|
|
||||||
|
|
||||||
def getImplantSetList(eager=None):
|
def getImplantSetList(eager=None):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
sets = saveddata_session.query(ImplantSet).options(*eager).all()
|
sets = saveddata_session.query(ImplantSet).options(*eager).all()
|
||||||
return sets
|
return sets
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(DamagePattern, 1, "lookfor")
|
@cachedQuery(DamagePattern, 1, "lookfor")
|
||||||
def getDamagePattern(lookfor, eager=None):
|
def getDamagePattern(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
@@ -364,15 +397,18 @@ def getDamagePattern(lookfor, eager=None):
|
|||||||
else:
|
else:
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
pattern = saveddata_session.query(DamagePattern).options(*eager).filter(DamagePattern.ID == lookfor).first()
|
pattern = saveddata_session.query(DamagePattern).options(*eager).filter(
|
||||||
|
DamagePattern.ID == lookfor).first()
|
||||||
elif isinstance(lookfor, basestring):
|
elif isinstance(lookfor, basestring):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
pattern = saveddata_session.query(DamagePattern).options(*eager).filter(DamagePattern.name == lookfor).first()
|
pattern = saveddata_session.query(DamagePattern).options(*eager).filter(
|
||||||
|
DamagePattern.name == lookfor).first()
|
||||||
else:
|
else:
|
||||||
raise TypeError("Need integer or string as argument")
|
raise TypeError("Need integer or string as argument")
|
||||||
return pattern
|
return pattern
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(TargetResists, 1, "lookfor")
|
@cachedQuery(TargetResists, 1, "lookfor")
|
||||||
def getTargetResists(lookfor, eager=None):
|
def getTargetResists(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
@@ -382,15 +418,18 @@ def getTargetResists(lookfor, eager=None):
|
|||||||
else:
|
else:
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
pattern = saveddata_session.query(TargetResists).options(*eager).filter(TargetResists.ID == lookfor).first()
|
pattern = saveddata_session.query(TargetResists).options(*eager).filter(
|
||||||
|
TargetResists.ID == lookfor).first()
|
||||||
elif isinstance(lookfor, basestring):
|
elif isinstance(lookfor, basestring):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
pattern = saveddata_session.query(TargetResists).options(*eager).filter(TargetResists.name == lookfor).first()
|
pattern = saveddata_session.query(TargetResists).options(*eager).filter(
|
||||||
|
TargetResists.name == lookfor).first()
|
||||||
else:
|
else:
|
||||||
raise TypeError("Need integer or string as argument")
|
raise TypeError("Need integer or string as argument")
|
||||||
return pattern
|
return pattern
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(ImplantSet, 1, "lookfor")
|
@cachedQuery(ImplantSet, 1, "lookfor")
|
||||||
def getImplantSet(lookfor, eager=None):
|
def getImplantSet(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
@@ -400,7 +439,8 @@ def getImplantSet(lookfor, eager=None):
|
|||||||
else:
|
else:
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
pattern = saveddata_session.query(ImplantSet).options(*eager).filter(TargetResists.ID == lookfor).first()
|
pattern = saveddata_session.query(ImplantSet).options(*eager).filter(
|
||||||
|
TargetResists.ID == lookfor).first()
|
||||||
elif isinstance(lookfor, basestring):
|
elif isinstance(lookfor, basestring):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
@@ -409,13 +449,14 @@ def getImplantSet(lookfor, eager=None):
|
|||||||
raise TypeError("Improper argument")
|
raise TypeError("Improper argument")
|
||||||
return pattern
|
return pattern
|
||||||
|
|
||||||
|
|
||||||
def searchFits(nameLike, where=None, eager=None):
|
def searchFits(nameLike, where=None, eager=None):
|
||||||
if not isinstance(nameLike, basestring):
|
if not isinstance(nameLike, basestring):
|
||||||
raise TypeError("Need string as argument")
|
raise TypeError("Need string as argument")
|
||||||
# Prepare our string for request
|
# Prepare our string for request
|
||||||
nameLike = u"%{0}%".format(sqlizeString(nameLike))
|
nameLike = u"%{0}%".format(sqlizeString(nameLike))
|
||||||
|
|
||||||
#Add any extra components to the search to our where clause
|
# Add any extra components to the search to our where clause
|
||||||
filter = processWhere(Fit.name.like(nameLike, escape="\\"), where)
|
filter = processWhere(Fit.name.like(nameLike, escape="\\"), where)
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
@@ -423,15 +464,18 @@ def searchFits(nameLike, where=None, eager=None):
|
|||||||
|
|
||||||
return fits
|
return fits
|
||||||
|
|
||||||
|
|
||||||
def getSquadsIDsWithFitID(fitID):
|
def getSquadsIDsWithFitID(fitID):
|
||||||
if isinstance(fitID, int):
|
if isinstance(fitID, int):
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
squads = saveddata_session.query(squadmembers_table.c.squadID).filter(squadmembers_table.c.memberID == fitID).all()
|
squads = saveddata_session.query(squadmembers_table.c.squadID).filter(
|
||||||
|
squadmembers_table.c.memberID == fitID).all()
|
||||||
squads = tuple(entry[0] for entry in squads)
|
squads = tuple(entry[0] for entry in squads)
|
||||||
return squads
|
return squads
|
||||||
else:
|
else:
|
||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
|
|
||||||
|
|
||||||
def getProjectedFits(fitID):
|
def getProjectedFits(fitID):
|
||||||
if isinstance(fitID, int):
|
if isinstance(fitID, int):
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
@@ -441,12 +485,14 @@ def getProjectedFits(fitID):
|
|||||||
else:
|
else:
|
||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
|
|
||||||
|
|
||||||
def getCrestCharacters(eager=None):
|
def getCrestCharacters(eager=None):
|
||||||
eager = processEager(eager)
|
eager = processEager(eager)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
characters = saveddata_session.query(CrestChar).options(*eager).all()
|
characters = saveddata_session.query(CrestChar).options(*eager).all()
|
||||||
return characters
|
return characters
|
||||||
|
|
||||||
|
|
||||||
@cachedQuery(CrestChar, 1, "lookfor")
|
@cachedQuery(CrestChar, 1, "lookfor")
|
||||||
def getCrestCharacter(lookfor, eager=None):
|
def getCrestCharacter(lookfor, eager=None):
|
||||||
if isinstance(lookfor, int):
|
if isinstance(lookfor, int):
|
||||||
@@ -465,21 +511,25 @@ def getCrestCharacter(lookfor, eager=None):
|
|||||||
raise TypeError("Need integer or string as argument")
|
raise TypeError("Need integer or string as argument")
|
||||||
return character
|
return character
|
||||||
|
|
||||||
|
|
||||||
def getOverrides(itemID, eager=None):
|
def getOverrides(itemID, eager=None):
|
||||||
if isinstance(itemID, int):
|
if isinstance(itemID, int):
|
||||||
return saveddata_session.query(Override).filter(Override.itemID == itemID).all()
|
return saveddata_session.query(Override).filter(Override.itemID == itemID).all()
|
||||||
else:
|
else:
|
||||||
raise TypeError("Need integer as argument")
|
raise TypeError("Need integer as argument")
|
||||||
|
|
||||||
|
|
||||||
def clearOverrides():
|
def clearOverrides():
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
deleted_rows = saveddata_session.query(Override).delete()
|
deleted_rows = saveddata_session.query(Override).delete()
|
||||||
commit()
|
commit()
|
||||||
return deleted_rows
|
return deleted_rows
|
||||||
|
|
||||||
|
|
||||||
def getAllOverrides(eager=None):
|
def getAllOverrides(eager=None):
|
||||||
return saveddata_session.query(Override).all()
|
return saveddata_session.query(Override).all()
|
||||||
|
|
||||||
|
|
||||||
def removeInvalid(fits):
|
def removeInvalid(fits):
|
||||||
invalids = [f for f in fits if f.isInvalid]
|
invalids = [f for f in fits if f.isInvalid]
|
||||||
|
|
||||||
@@ -490,14 +540,17 @@ def removeInvalid(fits):
|
|||||||
|
|
||||||
return fits
|
return fits
|
||||||
|
|
||||||
|
|
||||||
def add(stuff):
|
def add(stuff):
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
saveddata_session.add(stuff)
|
saveddata_session.add(stuff)
|
||||||
|
|
||||||
|
|
||||||
def save(stuff):
|
def save(stuff):
|
||||||
add(stuff)
|
add(stuff)
|
||||||
commit()
|
commit()
|
||||||
|
|
||||||
|
|
||||||
def remove(stuff):
|
def remove(stuff):
|
||||||
removeCachedEntry(type(stuff), stuff.ID)
|
removeCachedEntry(type(stuff), stuff.ID)
|
||||||
with sd_lock:
|
with sd_lock:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, ForeignKey
|
from sqlalchemy import Table, Column, Integer, ForeignKey
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
@@ -24,8 +24,8 @@ from eos.db import saveddata_meta
|
|||||||
from eos.types import Skill
|
from eos.types import Skill
|
||||||
|
|
||||||
skills_table = Table("characterSkills", saveddata_meta,
|
skills_table = Table("characterSkills", saveddata_meta,
|
||||||
Column("characterID", ForeignKey("characters.ID"), primary_key = True, index = True),
|
Column("characterID", ForeignKey("characters.ID"), primary_key=True, index=True),
|
||||||
Column("itemID", Integer, primary_key = True),
|
Column("itemID", Integer, primary_key=True),
|
||||||
Column("_Skill__level", Integer, nullable = True))
|
Column("_Skill__level", Integer, nullable=True))
|
||||||
|
|
||||||
mapper(Skill, skills_table)
|
mapper(Skill, skills_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2014 Ryan Holmes
|
# Copyright (C) 2014 Ryan Holmes
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, Float, ForeignKey, String
|
from sqlalchemy import Table, Column, Integer, Float, ForeignKey, String
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
@@ -24,12 +24,12 @@ from eos.db import saveddata_meta
|
|||||||
from eos.types import TargetResists
|
from eos.types import TargetResists
|
||||||
|
|
||||||
targetResists_table = Table("targetResists", saveddata_meta,
|
targetResists_table = Table("targetResists", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("name", String),
|
Column("name", String),
|
||||||
Column("emAmount", Float),
|
Column("emAmount", Float),
|
||||||
Column("thermalAmount", Float),
|
Column("thermalAmount", Float),
|
||||||
Column("kineticAmount", Float),
|
Column("kineticAmount", Float),
|
||||||
Column("explosiveAmount", Float),
|
Column("explosiveAmount", Float),
|
||||||
Column("ownerID", ForeignKey("users.ID"), nullable=True))
|
Column("ownerID", ForeignKey("users.ID"), nullable=True))
|
||||||
|
|
||||||
mapper(TargetResists, targetResists_table)
|
mapper(TargetResists, targetResists_table)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#===============================================================================
|
# ===============================================================================
|
||||||
# Copyright (C) 2010 Diego Duclos
|
# Copyright (C) 2010 Diego Duclos
|
||||||
#
|
#
|
||||||
# This file is part of eos.
|
# This file is part of eos.
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#===============================================================================
|
# ===============================================================================
|
||||||
|
|
||||||
from sqlalchemy import Table, Column, Integer, String, Boolean
|
from sqlalchemy import Table, Column, Integer, String, Boolean
|
||||||
from sqlalchemy.orm import mapper
|
from sqlalchemy.orm import mapper
|
||||||
@@ -24,9 +24,9 @@ from eos.db import saveddata_meta
|
|||||||
from eos.types import User
|
from eos.types import User
|
||||||
|
|
||||||
users_table = Table("users", saveddata_meta,
|
users_table = Table("users", saveddata_meta,
|
||||||
Column("ID", Integer, primary_key = True),
|
Column("ID", Integer, primary_key=True),
|
||||||
Column("username", String, nullable = False, unique = True),
|
Column("username", String, nullable=False, unique=True),
|
||||||
Column("password", String, nullable = False),
|
Column("password", String, nullable=False),
|
||||||
Column("admin", Boolean, nullable = False))
|
Column("admin", Boolean, nullable=False))
|
||||||
|
|
||||||
mapper(User, users_table)
|
mapper(User, users_table)
|
||||||
|
|||||||
Reference in New Issue
Block a user