Merge pull request #853 from BuhtigithuB/pep8-languages-py

Improve PEP8 gluon/languages.py
This commit is contained in:
mdipierro
2015-03-19 11:56:06 -05:00
+12 -5
View File
@@ -75,11 +75,13 @@ regex_plural_tuple = re.compile(
'^{(?P<w>[^[\]()]+)(?:\[(?P<i>\d+)\])?}$') # %%{word[index]} or %%{word}
regex_plural_file = re.compile('^plural-[a-zA-Z]{2}(-[a-zA-Z]{2})?\.py$')
def is_writable():
""" returns True if and only if the filesystem is writable """
from gluon.settings import global_settings
return not global_settings.web2py_runtime_gae
def safe_eval(text):
if text.strip():
try:
@@ -314,9 +316,11 @@ def write_plural_dict(filename, contents):
if fp:
fp.close()
def sort_function(x,y):
def sort_function(x, y):
return cmp(unicode(x, 'utf-8').lower(), unicode(y, 'utf-8').lower())
def write_dict(filename, contents):
if '__corrupted__' in contents:
return
@@ -432,11 +436,13 @@ class lazyT(object):
return lazyT(self)
return lazyT(self.m, symbols, self.T, self.f, self.t, self.M)
def pickle_lazyT(c):
return str, (c.xml(),)
copy_reg.pickle(lazyT, pickle_lazyT)
class translator(object):
"""
This class is instantiated by gluon.compileapp.build_environment
@@ -461,7 +467,7 @@ class translator(object):
self.langpath = langpath
self.http_accept_language = http_accept_language
# filled in self.force():
#------------------------
# ------------------------
# self.cache
# self.accepted_language
# self.language_file
@@ -472,9 +478,9 @@ class translator(object):
# self.plural_file
# self.plural_dict
# self.requested_languages
#----------------------------------------
# ----------------------------------------
# filled in self.set_current_languages():
#----------------------------------------
# ----------------------------------------
# self.default_language_file
# self.default_t
# self.current_languages
@@ -723,7 +729,7 @@ class translator(object):
try:
otherT = self.otherTs[index]
except KeyError:
otherT = self.otherTs[index] = translator(self.langpath, \
otherT = self.otherTs[index] = translator(self.langpath,
self.http_accept_language)
if language:
otherT.force(language)
@@ -977,6 +983,7 @@ def findT(path, language=DEFAULT_LANGUAGE):
else sentences['!langcode!'])
write_dict(lang_file, sentences)
def update_all_languages(application_path):
"""
Note: