Get alpha clones in the database
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
__all__ = ["attribute", "category", "effect", "group", "metaData",
|
||||
"icon", "item", "marketGroup", "metaGroup", "unit"]
|
||||
"icon", "item", "marketGroup", "metaGroup", "unit", "alphaClones"]
|
||||
|
||||
45
eos/db/gamedata/alphaClones.py
Normal file
45
eos/db/gamedata/alphaClones.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# ===============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of eos.
|
||||
#
|
||||
# eos is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# eos is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with eos. If not, see <http://www.gnu.org/licenses/>.
|
||||
# ===============================================================================
|
||||
|
||||
from sqlalchemy import Column, String, Integer, Table, ForeignKey
|
||||
from sqlalchemy.orm import relation, mapper
|
||||
|
||||
from eos.db import gamedata_meta
|
||||
from eos.types import AlphaClone, AlphaCloneSkill
|
||||
|
||||
alphaclones_table = Table("alphaClones", gamedata_meta,
|
||||
Column("alphaCloneID", Integer, primary_key=True),
|
||||
Column("alphaCloneName", String),
|
||||
)
|
||||
|
||||
alphacloneskskills_table = Table("alphaCloneSkills", gamedata_meta,
|
||||
Column("alphaCloneID", Integer, ForeignKey("alphaClones.alphaCloneID"), primary_key=True),
|
||||
Column("typeID", Integer, primary_key=True),
|
||||
Column("level", Integer),
|
||||
)
|
||||
|
||||
mapper(AlphaClone, alphaclones_table,
|
||||
properties={
|
||||
"_AlphaClone__skills": relation(
|
||||
AlphaCloneSkill,
|
||||
cascade="all,delete-orphan",
|
||||
backref="clone")
|
||||
})
|
||||
|
||||
mapper(AlphaCloneSkill, alphacloneskskills_table)
|
||||
@@ -33,6 +33,7 @@ characters_table = Table("characters", saveddata_meta,
|
||||
Column("defaultChar", Integer),
|
||||
Column("chars", String, nullable=True),
|
||||
Column("defaultLevel", Integer, nullable=True),
|
||||
Column("alphaClone", Integer, nullable=True),
|
||||
Column("ownerID", ForeignKey("users.ID"), nullable=True))
|
||||
|
||||
mapper(Character, characters_table,
|
||||
|
||||
@@ -444,6 +444,14 @@ class Category(EqBase):
|
||||
pass
|
||||
|
||||
|
||||
class AlphaClone(EqBase):
|
||||
pass
|
||||
|
||||
|
||||
class AlphaCloneSkill(EqBase):
|
||||
pass
|
||||
|
||||
|
||||
class Group(EqBase):
|
||||
pass
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
# ===============================================================================
|
||||
|
||||
from eos.gamedata import Attribute, Category, Effect, Group, Icon, Item, MarketGroup, \
|
||||
MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData, Traits
|
||||
MetaGroup, AttributeInfo, Unit, EffectInfo, MetaType, MetaData, Traits, AlphaClone, \
|
||||
AlphaCloneSkill
|
||||
from eos.saveddata.price import Price
|
||||
from eos.saveddata.user import User
|
||||
from eos.saveddata.crestchar import CrestChar
|
||||
|
||||
@@ -47,6 +47,7 @@ def main(db, json_path):
|
||||
|
||||
# Config dict
|
||||
tables = {
|
||||
"clonegrades": eos.gamedata.AlphaCloneSkill,
|
||||
"dgmattribs": eos.gamedata.AttributeInfo,
|
||||
"dgmeffects": eos.gamedata.EffectInfo,
|
||||
"dgmtypeattribs": eos.gamedata.Attribute,
|
||||
@@ -60,7 +61,8 @@ def main(db, json_path):
|
||||
"evetypes": eos.gamedata.Item,
|
||||
"phbtraits": eos.gamedata.Traits,
|
||||
"phbmetadata": eos.gamedata.MetaData,
|
||||
"mapbulk_marketGroups": eos.gamedata.MarketGroup
|
||||
"mapbulk_marketGroups": eos.gamedata.MarketGroup,
|
||||
|
||||
}
|
||||
|
||||
fieldMapping = {
|
||||
@@ -109,6 +111,19 @@ def main(db, json_path):
|
||||
new.append(v)
|
||||
return new
|
||||
|
||||
def convertClones(data):
|
||||
newData = []
|
||||
|
||||
for ID in data:
|
||||
for skill in data[ID]["skills"]:
|
||||
newData.append({
|
||||
"alphaCloneID": int(ID),
|
||||
"alphaCloneName": data[ID]["internalDescription"],
|
||||
"typeID": skill["typeID"],
|
||||
"level": skill["level"]})
|
||||
|
||||
return newData
|
||||
|
||||
def convertTraits(data):
|
||||
|
||||
def convertSection(sectionData):
|
||||
@@ -167,6 +182,8 @@ def main(db, json_path):
|
||||
tableData = convertTraits(tableData)
|
||||
if jsonName == "evetypes":
|
||||
tableData = convertTypes(tableData)
|
||||
if jsonName == "clonegrades":
|
||||
tableData = convertClones(tableData)
|
||||
data[jsonName] = tableData
|
||||
|
||||
# Set with typeIDs which we will have in our database
|
||||
@@ -191,7 +208,10 @@ def main(db, json_path):
|
||||
# Loop through each json file and write it away, checking ignored rows
|
||||
for jsonName, table in data.iteritems():
|
||||
fieldMap = fieldMapping.get(jsonName, {})
|
||||
tmp = []
|
||||
|
||||
print "processing {}".format(jsonName)
|
||||
|
||||
for row in table:
|
||||
# We don't care about some kind of rows, filter it out if so
|
||||
if not isIgnored(jsonName, row):
|
||||
@@ -207,6 +227,14 @@ def main(db, json_path):
|
||||
if jsonName is "icons" and "modules/" in str(row["iconFile"]).lower():
|
||||
row["iconFile"] = row["iconFile"].lower().replace("modules/", "").replace(".png", "")
|
||||
|
||||
if jsonName is "clonegrades":
|
||||
if (row["alphaCloneID"] not in tmp):
|
||||
cloneParent = eos.gamedata.AlphaClone()
|
||||
setattr(cloneParent, "alphaCloneID", row["alphaCloneID"])
|
||||
setattr(cloneParent, "alphaCloneName", row["alphaCloneName"])
|
||||
eos.db.gamedata_session.add(cloneParent)
|
||||
tmp.append(row['alphaCloneID'])
|
||||
|
||||
for k, v in row.iteritems():
|
||||
if (isinstance(v, basestring)):
|
||||
v = v.strip()
|
||||
|
||||
Reference in New Issue
Block a user