Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated utf 8 hack #7

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 6 additions & 31 deletions Load.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,67 +1,42 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy import create_engine,Table
from tableloader.tableFunctions import *
from tableloader.tables import metadataCreator
import ConfigParser, os
import warnings

import sys





warnings.filterwarnings('ignore', '^Unicode type received non-unicode bind param value')


if len(sys.argv)<2:
print "Load.py destination"
print "Load.py db_engine"
exit()


database=sys.argv[1]


import ConfigParser, os
fileLocation = os.path.dirname(os.path.realpath(__file__))
inifile=fileLocation+'/sdeloader.cfg'
config = ConfigParser.ConfigParser()
config.read(inifile)
destination=config.get('Database',database)
sourcePath=config.get('Files','sourcePath')






from tableloader.tableFunctions import *



print "connecting to DB"


engine = create_engine(destination)
connection = engine.connect()



from tableloader.tables import metadataCreator

schema=None
if database=="postgresschema":
schema="evesde"

metadata=metadataCreator(schema)



print "Creating Tables"

metadata.drop_all(engine,checkfirst=True)
metadata.create_all(engine,checkfirst=True)

print "created"

import tableloader.tableFunctions

blueprints.importyaml(connection,metadata,sourcePath)
categories.importyaml(connection,metadata,sourcePath)
certificates.importyaml(connection,metadata,sourcePath)
Expand Down
3 changes: 0 additions & 3 deletions tableloader/tableFunctions/bsdTables.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import os
import yaml
import glob
Expand Down
10 changes: 4 additions & 6 deletions tableloader/tableFunctions/categories.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
import yaml
from sqlalchemy import Table

Expand All @@ -21,14 +18,15 @@ def importyaml(connection,metadata,sourcePath):
for categoryid in categoryids:
connection.execute(invCategories.insert(),
categoryID=categoryid,
categoryName=categoryids[categoryid].get('name',{}).get('en','').decode('utf-8'),
categoryName=categoryids[categoryid].get('name',{}).get('en',''),
iconID=categoryids[categoryid].get('iconID'),
published=categoryids[categoryid].get('published',0))

if (categoryids[categoryid].has_key('name')):
for lang in categoryids[categoryid]['name']:
try:
connection.execute(trnTranslations.insert(),tcID=6,keyID=categoryid,languageID=lang,text=categoryids[categoryid]['name'][lang].decode('utf-8'));
category_text = categoryids[categoryid]['name'][lang]
connection.execute(trnTranslations.insert(),tcID=6,keyID=categoryid,languageID=lang,text=category_text);
except:
print '{} {} has a category problem'.format(categoryid,lang)
print '{} {} has a category problem: {}'.format(categoryid, lang, category_text)
trans.commit()
3 changes: 0 additions & 3 deletions tableloader/tableFunctions/certificates.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
import sys
import os
from sqlalchemy import Table
reload(sys)
sys.setdefaultencoding("utf-8")
import yaml

def importyaml(connection,metadata,sourcePath):
Expand Down
3 changes: 0 additions & 3 deletions tableloader/tableFunctions/graphics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
import yaml
from sqlalchemy import Table

Expand Down
7 changes: 2 additions & 5 deletions tableloader/tableFunctions/groups.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
import yaml
from sqlalchemy import Table

Expand All @@ -19,7 +16,7 @@ def importyaml(connection,metadata,sourcePath):
connection.execute(invGroups.insert(),
groupID=groupid,
categoryID=groupids[groupid].get('categoryID',0),
groupName=groupids[groupid].get('name',{}).get('en','').decode('utf-8'),
groupName=groupids[groupid].get('name',{}).get('en',''),
iconID=groupids[groupid].get('iconID'),
useBasePrice=groupids[groupid].get('useBasePrice'),
anchored=groupids[groupid].get('anchored',0),
Expand All @@ -28,5 +25,5 @@ def importyaml(connection,metadata,sourcePath):
published=groupids[groupid].get('published',0))
if (groupids[groupid].has_key('name')):
for lang in groupids[groupid]['name']:
connection.execute(trnTranslations.insert(),tcID=7,keyID=groupid,languageID=lang,text=groupids[groupid]['name'][lang].decode('utf-8'));
connection.execute(trnTranslations.insert(),tcID=7,keyID=groupid,languageID=lang,text=groupids[groupid]['name'][lang]);
trans.commit()
3 changes: 0 additions & 3 deletions tableloader/tableFunctions/icons.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
import yaml
from sqlalchemy import Table

Expand Down
3 changes: 0 additions & 3 deletions tableloader/tableFunctions/skins.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
import yaml
from sqlalchemy import Table

Expand Down
15 changes: 6 additions & 9 deletions tableloader/tableFunctions/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import os
reload(sys)
sys.setdefaultencoding("utf-8")
import yaml
from sqlalchemy import Table

Expand All @@ -21,8 +18,8 @@ def importyaml(connection,metadata,sourcePath):
connection.execute(invTypes.insert(),
typeID=typeid,
groupID=typeids[typeid].get('groupID',0),
typeName=typeids[typeid].get('name',{}).get('en','').decode('utf-8'),
description=typeids[typeid].get('description',{}).get('en','').decode('utf-8'),
typeName=typeids[typeid].get('name',{}).get('en',''),
description=typeids[typeid].get('description',{}).get('en',''),
mass=typeids[typeid].get('mass',0),
volume=typeids[typeid].get('volume',0),
capacity=typeids[typeid].get('capacity',0),
Expand All @@ -43,10 +40,10 @@ def importyaml(connection,metadata,sourcePath):
certID=cert)
if (typeids[typeid].has_key('name')):
for lang in typeids[typeid]['name']:
connection.execute(trnTranslations.insert(),tcID=8,keyID=typeid,languageID=lang.decode('utf-8'),text=typeids[typeid]['name'][lang].decode('utf-8'))
connection.execute(trnTranslations.insert(),tcID=8,keyID=typeid,languageID=lang,text=typeids[typeid]['name'][lang])
if (typeids[typeid].has_key('description')):
for lang in typeids[typeid]['description']:
connection.execute(trnTranslations.insert(),tcID=33,keyID=typeid,languageID=lang.decode('utf-8'),text=typeids[typeid]['description'][lang].decode('utf-8'))
connection.execute(trnTranslations.insert(),tcID=33,keyID=typeid,languageID=lang,text=typeids[typeid]['description'][lang])
if (typeids[typeid].has_key('traits')):
if typeids[typeid]['traits'].has_key('types'):
for skill in typeids[typeid]['traits']['types']:
Expand All @@ -59,7 +56,7 @@ def importyaml(connection,metadata,sourcePath):
unitID=trait.get('unitID'))
traitid=result.inserted_primary_key
for languageid in trait.get('bonusText',{}):
connection.execute(trnTranslations.insert(),tcID=1002,keyID=traitid[0],languageID=languageid.decode('utf-8'),text=trait['bonusText'][languageid].decode('utf-8'))
connection.execute(trnTranslations.insert(),tcID=1002,keyID=traitid[0],languageID=languageid,text=trait['bonusText'][languageid])
if typeids[typeid]['traits'].has_key('roleBonuses'):
for trait in typeids[typeid]['traits']['roleBonuses']:
result=connection.execute(invTraits.insert(),
Expand All @@ -70,5 +67,5 @@ def importyaml(connection,metadata,sourcePath):
unitID=trait.get('unitID'))
traitid=result.inserted_primary_key
for languageid in trait.get('bonusText',{}):
connection.execute(trnTranslations.insert(),tcID=1002,keyID=traitid[0],languageID=languageid.decode('utf-8'),text=trait['bonusText'][languageid].decode('utf-8'))
connection.execute(trnTranslations.insert(),tcID=1002,keyID=traitid[0],languageID=languageid,text=trait['bonusText'][languageid])
trans.commit()
3 changes: 0 additions & 3 deletions tableloader/tableFunctions/universe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import os
import glob
import yaml
Expand Down