The SSH host key has changed on 8 April, 2022 to this one: SHA256:573uTBSeh74kvOo0HJXi5ijdzRm8me27suzNEDlGyrQ
master
Gergely Polonkai 7 years ago
parent 3b0d244255
commit 9ee1f567a5
  1. 2
      .gitignore
  2. 7
      einstein
  3. 20
      einsteingame/i18n.py
  4. 8
      einsteingame/resources.py

2
.gitignore vendored

@ -1,2 +1,2 @@
*.o
einstein
__pycache__

@ -0,0 +1,7 @@
#! /usr/bin/env python3
import sys
from einsteingame.main import main
main(*sys.argv)

@ -1,10 +1,12 @@
from locale import setlocale, LC_ALL, LC_NUMERIC
class Locale(object):
def __init__(self):
self.parseLocale(setlocale(LC_ALL, ""))
# hack because of numbers in Lua
setlocale(LC_NUMERIC, "C")
def parseLocale(name):
def parseLocale(self, name):
pos = name.find('.')
langAndCountry = None
@ -80,15 +82,17 @@ def splitFileName(fileName):
return name, ext, lang, country
def getScore(lang, country, locale):
if len(country) == 0 and len(locale) == 0:
if len(country) == 0 and len(lang) == 0:
return 1
score = 0
if (locale.getCountry().length() && (locale.getCountry() == country))
score += 2;
if (locale.getLanguage().length() && (locale.getLanguage() == lang))
score += 4;
if locale.getCountry() == country:
score += 2
if locale.getLanguage() == lang:
score += 4
return score
return score;
}
locale = Locale()

@ -3,7 +3,7 @@ import struct
import io
from .buffer import Buffer
from .i18n import splitFileName, getScore
from .i18n import splitFileName, getScore, locale
class ResourceError(Exception):
def __init__(self, code=None):
@ -88,6 +88,7 @@ class ResourcesCollection:
def __init__(self, directories):
self.__files = []
self.__buffer = None
self.__resources = {}
self.loadResourceFiles(directories)
self.processFiles()
@ -112,10 +113,11 @@ class ResourcesCollection:
if score > 0:
resName = name + '.' + ext
res = resources[resName];
res = self.__resources.get(resName, None)
if not res:
res = Resource(res_file, score, de, resName)
resources[resName] = res;
self.__resources[resName] = res
if len(de.group) > 0:
groups[de.group].append(res)

Loading…
Cancel
Save