Update schema and db_update to support translations.
(language setting from preferences is borked for some reason)
This commit is contained in:
@@ -184,7 +184,7 @@ def defPaths(customSavePath=None):
|
||||
# saveddata db location modifier, shouldn't ever need to touch this
|
||||
eos.config.saveddata_connectionstring = "sqlite:///" + saveDB + "?check_same_thread=False"
|
||||
eos.config.gamedata_connectionstring = "sqlite:///" + gameDB + "?check_same_thread=False"
|
||||
eos.config.lang = language or eos.config.lang
|
||||
eos.config.set_lang(language)
|
||||
|
||||
# initialize the settings
|
||||
from service.settings import EOSSettings
|
||||
|
||||
41
db_update.py
41
db_update.py
@@ -121,13 +121,13 @@ def update_db():
|
||||
for row in data:
|
||||
if (
|
||||
# Apparently people really want Civilian modules available
|
||||
(row['typeName'].startswith('Civilian') and "Shuttle" not in row['typeName']) or
|
||||
row['typeName'] == 'Capsule' or
|
||||
(row['typeName_en-us'].startswith('Civilian') and "Shuttle" not in row['typeName_en-us']) or
|
||||
row['typeName_en-us'] == 'Capsule' or
|
||||
row['groupID'] == 4033 # destructible effect beacons
|
||||
):
|
||||
row['published'] = True
|
||||
# Nearly useless and clutter search results too much
|
||||
elif row['typeName'].startswith('Limited Synth '):
|
||||
elif row['typeName_en-us'].startswith('Limited Synth '):
|
||||
row['published'] = False
|
||||
|
||||
newData = []
|
||||
@@ -147,24 +147,30 @@ def update_db():
|
||||
):
|
||||
newData.append(row)
|
||||
|
||||
_addRows(newData, eos.gamedata.Item)
|
||||
_addRows(newData, eos.gamedata.Item, fieldMap={'typeName_en-us': 'typeName', 'description_en-us': 'description'})
|
||||
return newData
|
||||
|
||||
def processEveGroups():
|
||||
print('processing evegroups')
|
||||
data = _readData('fsd_lite', 'evegroups', keyIdName='groupID')
|
||||
_addRows(data, eos.gamedata.Group)
|
||||
_addRows(data, eos.gamedata.Group, fieldMap={'groupName_en-us': 'groupName'})
|
||||
return data
|
||||
|
||||
def processEveCategories():
|
||||
print('processing evecategories')
|
||||
data = _readData('fsd_lite', 'evecategories', keyIdName='categoryID')
|
||||
_addRows(data, eos.gamedata.Category)
|
||||
_addRows(data, eos.gamedata.Category, fieldMap={
|
||||
'categoryName_en-us': 'displayName',
|
||||
'categoryName_zh': 'name_zh'
|
||||
})
|
||||
|
||||
def processDogmaAttributes():
|
||||
print('processing dogmaattributes')
|
||||
data = _readData('fsd_binary', 'dogmaattributes', keyIdName='attributeID')
|
||||
_addRows(data, eos.gamedata.AttributeInfo)
|
||||
_addRows(data, eos.gamedata.AttributeInfo, fieldMap={
|
||||
'displayName_en-us': 'displayName',
|
||||
'tooltipDescription_en-us': 'tooltipDescription'
|
||||
})
|
||||
|
||||
def processDogmaTypeAttributes(eveTypesData):
|
||||
print('processing dogmatypeattributes')
|
||||
@@ -239,17 +245,28 @@ def update_db():
|
||||
def processDogmaUnits():
|
||||
print('processing dogmaunits')
|
||||
data = _readData('fsd_binary', 'dogmaunits', keyIdName='unitID')
|
||||
_addRows(data, eos.gamedata.Unit, fieldMap={'name': 'unitName'})
|
||||
_addRows(data, eos.gamedata.Unit, fieldMap={
|
||||
'name': 'unitName',
|
||||
'displayName_en-us': 'displayName'
|
||||
})
|
||||
|
||||
def processMarketGroups():
|
||||
print('processing marketgroups')
|
||||
data = _readData('fsd_binary', 'marketgroups', keyIdName='marketGroupID')
|
||||
_addRows(data, eos.gamedata.MarketGroup, fieldMap={'name': 'marketGroupName'})
|
||||
_addRows(data, eos.gamedata.MarketGroup, fieldMap={
|
||||
'name_en-us': 'name',
|
||||
'name_zh': 'marketGroupName_zh',
|
||||
'description_en-us': 'description',
|
||||
'description_zh': 'marketGroupDescription_zh'
|
||||
})
|
||||
|
||||
def processMetaGroups():
|
||||
print('processing metagroups')
|
||||
data = _readData('fsd_binary', 'metagroups', keyIdName='metaGroupID')
|
||||
_addRows(data, eos.gamedata.MetaGroup)
|
||||
_addRows(data, eos.gamedata.MetaGroup, fieldMap={
|
||||
'name_en-us': 'metaGroupName',
|
||||
'name_zh': 'metaGroupName_zh'
|
||||
})
|
||||
|
||||
def processCloneGrades():
|
||||
print('processing clonegrades')
|
||||
@@ -305,7 +322,7 @@ def update_db():
|
||||
for row in data:
|
||||
typeLines = []
|
||||
typeId = row['typeID']
|
||||
traitData = row['traits']
|
||||
traitData = row['traits_en-us']
|
||||
for skillData in sorted(traitData.get('skills', ()), key=lambda i: i['header']):
|
||||
typeLines.append(convertSection(skillData))
|
||||
if 'role' in traitData:
|
||||
@@ -483,7 +500,7 @@ def update_db():
|
||||
continue
|
||||
if row.get('groupID') not in implant_groups:
|
||||
continue
|
||||
typeName = row.get('typeName', '')
|
||||
typeName = row.get('typeName_en-us', '')
|
||||
# Regular sets matching
|
||||
m = re.match('(?P<grade>(High|Mid|Low)-grade) (?P<set>\w+) (?P<implant>(Alpha|Beta|Gamma|Delta|Epsilon|Omega))', typeName, re.IGNORECASE)
|
||||
if m:
|
||||
|
||||
@@ -13,7 +13,18 @@ saveddataCache = True
|
||||
gamedata_version = ""
|
||||
gamedata_date = ""
|
||||
gamedata_connectionstring = 'sqlite:///' + realpath(join(dirname(abspath(__file__)), "..", "eve.db"))
|
||||
lang = "en_US"
|
||||
|
||||
lang = ""
|
||||
|
||||
# Maps supported langauges to their suffix in the database
|
||||
translation_mapping = {
|
||||
"en_US": "",
|
||||
"zh_CN": "_zh"
|
||||
}
|
||||
|
||||
def set_lang(i18n_lang):
|
||||
global lang
|
||||
lang = translation_mapping.get(i18n_lang, translation_mapping.get("en-US"))
|
||||
|
||||
pyfalog.debug("Gamedata connection string: {0}", gamedata_connectionstring)
|
||||
|
||||
|
||||
@@ -37,10 +37,11 @@ attributes_table = Table("dgmattribs", gamedata_meta,
|
||||
Column("description", Unicode),
|
||||
Column("published", Boolean),
|
||||
Column("displayName", String),
|
||||
Column("displayName_zh", String),
|
||||
Column("highIsGood", Boolean),
|
||||
Column("iconID", Integer),
|
||||
Column("attributeCategory", Integer),
|
||||
Column("tooltipDescription", Integer),
|
||||
Column("tooltipDescription", Integer), # deprecated...?
|
||||
Column("unitID", Integer, ForeignKey("dgmunits.unitID")))
|
||||
|
||||
mapper(Attribute, typeattributes_table,
|
||||
@@ -51,7 +52,7 @@ mapper(AttributeInfo, attributes_table,
|
||||
"unit" : relation(Unit),
|
||||
"ID" : synonym("attributeID"),
|
||||
"name" : synonym("attributeName"),
|
||||
"description": deferred(attributes_table.c.description)
|
||||
"description": deferred(attributes_table.c.description),
|
||||
})
|
||||
|
||||
Attribute.ID = association_proxy("info", "attributeID")
|
||||
|
||||
@@ -22,17 +22,19 @@ from sqlalchemy.orm import deferred, mapper, synonym
|
||||
|
||||
from eos.db import gamedata_meta
|
||||
from eos.gamedata import Category
|
||||
import eos.config
|
||||
|
||||
categories_table = Table("invcategories", gamedata_meta,
|
||||
Column("categoryID", Integer, primary_key=True),
|
||||
Column("categoryName", String),
|
||||
Column("description", String),
|
||||
Column("name", String),
|
||||
Column("name_zh", String),
|
||||
Column("description", String), # deprecated
|
||||
Column("published", Boolean),
|
||||
Column("iconID", Integer))
|
||||
|
||||
mapper(Category, categories_table,
|
||||
properties={
|
||||
"ID" : synonym("categoryID"),
|
||||
"name" : synonym("categoryName"),
|
||||
"description": deferred(categories_table.c.description)
|
||||
"displayName": synonym("name{}".format(eos.config.lang)),
|
||||
"description": deferred(categories_table.c.description) # deprecated
|
||||
})
|
||||
|
||||
@@ -22,11 +22,13 @@ from sqlalchemy.orm import relation, mapper, synonym, deferred, backref
|
||||
|
||||
from eos.db import gamedata_meta
|
||||
from eos.gamedata import Category, Group
|
||||
import eos.config
|
||||
|
||||
groups_table = Table("invgroups", gamedata_meta,
|
||||
Column("groupID", Integer, primary_key=True),
|
||||
Column("groupName", String),
|
||||
Column("description", String),
|
||||
Column("groupName_zh", String),
|
||||
Column("description", String), # deprecated
|
||||
Column("published", Boolean),
|
||||
Column("categoryID", Integer, ForeignKey("invcategories.categoryID")),
|
||||
Column("iconID", Integer))
|
||||
@@ -35,6 +37,6 @@ mapper(Group, groups_table,
|
||||
properties={
|
||||
"category" : relation(Category, backref=backref("groups", cascade="all,delete")),
|
||||
"ID" : synonym("groupID"),
|
||||
"name" : synonym("groupName"),
|
||||
"description": deferred(groups_table.c.description)
|
||||
"name" : synonym("groupName{}".format(eos.config.lang)),
|
||||
"description": deferred(groups_table.c.description) # deprecated
|
||||
})
|
||||
|
||||
@@ -27,10 +27,14 @@ from eos.db.gamedata.dynamicAttributes import dynamicApplicable_table
|
||||
from eos.db.gamedata.effect import typeeffects_table
|
||||
from eos.gamedata import Attribute, DynamicItem, Effect, Group, Item, Traits, MetaGroup
|
||||
|
||||
import eos.config
|
||||
|
||||
items_table = Table("invtypes", gamedata_meta,
|
||||
Column("typeID", Integer, primary_key=True),
|
||||
Column("typeName", String, index=True),
|
||||
Column("typeName_zh", String),
|
||||
Column("description", String),
|
||||
Column("description_zh", String),
|
||||
Column("raceID", Integer),
|
||||
Column("factionID", Integer),
|
||||
Column("published", Boolean),
|
||||
@@ -43,7 +47,8 @@ items_table = Table("invtypes", gamedata_meta,
|
||||
Column("variationParentTypeID", Integer, ForeignKey("invtypes.typeID"), index=True),
|
||||
Column("replacements", String),
|
||||
Column("reqskills", String),
|
||||
Column("requiredfor", String))
|
||||
Column("requiredfor", String),
|
||||
)
|
||||
|
||||
from .traits import traits_table # noqa
|
||||
|
||||
@@ -55,8 +60,8 @@ mapper(Item, items_table,
|
||||
"metaGroup" : relation(MetaGroup, backref=backref("items", cascade="all,delete")),
|
||||
"varParent" : relation(Item, backref=backref("varChildren", cascade="all,delete"), remote_side=items_table.c.typeID),
|
||||
"ID" : synonym("typeID"),
|
||||
"name" : synonym("typeName"),
|
||||
"description" : deferred(items_table.c.description),
|
||||
"name" : synonym("typeName{}".format(eos.config.lang)),
|
||||
"description" : deferred(items_table.c["description"]), # point this to the translated one doesn't work, need a solution
|
||||
"traits" : relation(Traits,
|
||||
primaryjoin=traits_table.c.typeID == items_table.c.typeID,
|
||||
uselist=False),
|
||||
|
||||
@@ -22,14 +22,17 @@ from sqlalchemy.orm import relation, mapper, synonym, deferred
|
||||
|
||||
from eos.db import gamedata_meta
|
||||
from eos.gamedata import Item, MarketGroup
|
||||
import eos.config
|
||||
|
||||
marketgroups_table = Table("invmarketgroups", gamedata_meta,
|
||||
Column("marketGroupID", Integer, primary_key=True),
|
||||
Column("marketGroupName", String),
|
||||
Column("description", String),
|
||||
Column("marketGroupName_zh", String),
|
||||
Column("marketGroupDescription", String),
|
||||
Column("marketGroupDescription_zh", String),
|
||||
Column("hasTypes", Boolean),
|
||||
Column("parentGroupID", Integer,
|
||||
ForeignKey("invmarketgroups.marketGroupID", initially="DEFERRED", deferrable=True)),
|
||||
ForeignKey("invmarketgroups.marketGroupID", initially="DEFERRED", deferrable=True)),
|
||||
Column("iconID", Integer))
|
||||
|
||||
mapper(MarketGroup, marketgroups_table,
|
||||
@@ -38,6 +41,8 @@ mapper(MarketGroup, marketgroups_table,
|
||||
"parent" : relation(MarketGroup, backref="children",
|
||||
remote_side=[marketgroups_table.c.marketGroupID]),
|
||||
"ID" : synonym("marketGroupID"),
|
||||
"name" : synonym("marketGroupName"),
|
||||
"description": deferred(marketgroups_table.c.description)
|
||||
"name" : synonym("marketGroupName{}".format(eos.config.lang)),
|
||||
# "name_en-us" : synonym("marketGroupName_en-us"),
|
||||
"description": deferred(marketgroups_table.c["marketGroupDescription{}".format(eos.config.lang)]),
|
||||
})
|
||||
|
||||
|
||||
@@ -22,12 +22,15 @@ from sqlalchemy.orm import mapper, synonym
|
||||
|
||||
from eos.db import gamedata_meta
|
||||
from eos.gamedata import MetaGroup
|
||||
import eos.config
|
||||
|
||||
metagroups_table = Table("invmetagroups", gamedata_meta,
|
||||
Column("metaGroupID", Integer, primary_key=True),
|
||||
Column("metaGroupName", String))
|
||||
Column("metaGroupName", String),
|
||||
Column("metaGroupName_zh", String),
|
||||
)
|
||||
|
||||
mapper(MetaGroup, metagroups_table,
|
||||
properties={
|
||||
"ID" : synonym("metaGroupID"),
|
||||
"name": synonym("metaGroupName")})
|
||||
"name": synonym("metaGroupName{}".format(eos.config.lang))})
|
||||
|
||||
@@ -91,7 +91,7 @@ def getItem(lookfor, eager=None):
|
||||
item = get_gamedata_session().query(Item).options(*processEager(eager)).filter(Item.ID == id).first()
|
||||
else:
|
||||
# Item names are unique, so we can use first() instead of one()
|
||||
item = get_gamedata_session().query(Item).options(*processEager(eager)).filter(Item.name == lookfor).first()
|
||||
item = get_gamedata_session().query(Item).options(*processEager(eager)).filter(Item.typeName == lookfor).first()
|
||||
if item is not None:
|
||||
itemNameMap[lookfor] = item.ID
|
||||
else:
|
||||
@@ -205,7 +205,7 @@ def getGroup(lookfor, eager=None):
|
||||
group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.ID == id).first()
|
||||
else:
|
||||
# Group names are unique, so we can use first() instead of one()
|
||||
group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.name == lookfor).first()
|
||||
group = get_gamedata_session().query(Group).options(*processEager(eager)).filter(Group.groupName == lookfor).first()
|
||||
if group is not None:
|
||||
groupNameMap[lookfor] = group.ID
|
||||
else:
|
||||
@@ -265,7 +265,7 @@ def getMetaGroup(lookfor, eager=None):
|
||||
else:
|
||||
# MetaGroup names are unique, so we can use first() instead of one()
|
||||
metaGroup = get_gamedata_session().query(MetaGroup).options(*processEager(eager)).filter(
|
||||
MetaGroup.name == lookfor).first()
|
||||
MetaGroup.metaGroupName == lookfor).first()
|
||||
if metaGroup is not None:
|
||||
metaGroupNameMap[lookfor] = metaGroup.ID
|
||||
else:
|
||||
|
||||
@@ -26,7 +26,9 @@ from eos.gamedata import Unit
|
||||
groups_table = Table("dgmunits", gamedata_meta,
|
||||
Column("unitID", Integer, primary_key=True),
|
||||
Column("unitName", String),
|
||||
Column("displayName", String))
|
||||
Column("displayName", String),
|
||||
Column("displayName_zh", String),
|
||||
)
|
||||
|
||||
mapper(Unit, groups_table,
|
||||
properties={
|
||||
|
||||
7
pyfa.py
7
pyfa.py
@@ -74,7 +74,7 @@ parser.add_option("-s", "--savepath", action="store", dest="savepath", help="Set
|
||||
parser.add_option("-l", "--logginglevel", action="store", dest="logginglevel", help="Set desired logging level [Critical|Error|Warning|Info|Debug]", default="Error")
|
||||
parser.add_option("-p", "--profile", action="store", dest="profile_path", help="Set location to save profileing.", default=None)
|
||||
|
||||
parser.add_option("-i", "--language", action="store", dest="language", help="Set the language for pyfa", default=None)
|
||||
parser.add_option("-i", "--language", action="store", dest="language", help="Set the language for pyfa", default='zh_CN')
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
@@ -105,12 +105,13 @@ if __name__ == "__main__":
|
||||
|
||||
config.debug = options.debug
|
||||
config.loggingLevel = config.LOGLEVEL_MAP.get(options.logginglevel.lower(), config.LOGLEVEL_MAP['error'])
|
||||
config.defPaths(options.savepath)
|
||||
config.defLogging()
|
||||
|
||||
from service.settings import LocaleSettings
|
||||
config.language = options.language or LocaleSettings.getInstance().get('locale')
|
||||
|
||||
config.defPaths(options.savepath)
|
||||
config.defLogging()
|
||||
|
||||
with config.logging_setup.threadbound():
|
||||
|
||||
pyfalog.info("Starting Pyfa")
|
||||
|
||||
@@ -508,7 +508,7 @@ class Market:
|
||||
# Check custom groups
|
||||
for cgrp in self.customGroups:
|
||||
# During first comparison we need exact int, not float for matching
|
||||
if cgrp.ID == identity or cgrp.name == identity:
|
||||
if cgrp.ID == identity or cgrp.groupName == identity:
|
||||
# Return first match
|
||||
return cgrp
|
||||
# Return eos group if everything else returned nothing
|
||||
|
||||
Reference in New Issue
Block a user