[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8408 - trunk/gnue-common/src/apps
From: |
reinhard |
Subject: |
[gnue] r8408 - trunk/gnue-common/src/apps |
Date: |
Fri, 14 Apr 2006 18:27:27 -0500 (CDT) |
Author: reinhard
Date: 2006-04-14 18:27:27 -0500 (Fri, 14 Apr 2006)
New Revision: 8408
Modified:
trunk/gnue-common/src/apps/errors.py
trunk/gnue-common/src/apps/i18n.py
Log:
A little pylint cleanup.
Modified: trunk/gnue-common/src/apps/errors.py
===================================================================
--- trunk/gnue-common/src/apps/errors.py 2006-04-14 23:04:56 UTC (rev
8407)
+++ trunk/gnue-common/src/apps/errors.py 2006-04-14 23:27:27 UTC (rev
8408)
@@ -268,11 +268,3 @@
if isinstance (detail, types.StringType):
detail = unicode (detail, i18n.getencoding (), 'replace')
return ('system', name, message, detail)
-
-
-# =============================================================================
-# Code executed once per module load
-# =============================================================================
-
-import __builtin__
-__builtin__.__dict__['gException'] = gException
Modified: trunk/gnue-common/src/apps/i18n.py
===================================================================
--- trunk/gnue-common/src/apps/i18n.py 2006-04-14 23:04:56 UTC (rev 8407)
+++ trunk/gnue-common/src/apps/i18n.py 2006-04-14 23:27:27 UTC (rev 8408)
@@ -28,18 +28,17 @@
@var encoding: Encoding of the current locale
"""
-from types import *
-
-import exceptions
import gettext
import locale
import os.path
-import string
import sys
from gnue import paths
+__all__ = ['language', 'encoding', 'outconv', 'utranslate', 'translate',
+ 'getlanguage', 'getencoding', 'getuserlocale', 'setcurrentlocale']
+
# -----------------------------------------------------------------------------
# Global variables
# -----------------------------------------------------------------------------
@@ -60,7 +59,7 @@
Encodes a message to L{encoding} (the current locale's encoding). This
function is available as the builtin function "o()".
"""
- if isinstance (message, UnicodeType):
+ if isinstance (message, unicode):
return message.encode (encoding, 'replace')
else:
return message
@@ -76,10 +75,10 @@
for mod in sys.modules.values ():
if hasattr (mod, '__file__'):
# mod.__file__ can be .pyc if the module is already compiled
- f = mod.__file__
- if f [-1:] == 'c':
- f = f [:-1]
- if os.path.normcase (f) == os.path.normcase (filename):
+ mod_filename = mod.__file__
+ if mod_filename.endswith('c'):
+ mod_filename = mod_filename [:-1]
+ if os.path.normcase (mod_filename) == os.path.normcase (filename):
__modules [filename] = mod
return mod
@@ -100,9 +99,9 @@
return None
# make 'gnue-common' from 'gnue.common.foo.bar'
- x = string.replace (caller_module.__name__, '.', '-', 1)
- i = string.find (x, '.')
- domain = x [:i]
+ module_name = caller_module.__name__.replace('.', '-', 1)
+ i = module_name.find('.')
+ domain = module_name [:i]
if __catalogs.has_key (domain + ':' + language):
return __catalogs [domain + ':' + language]
@@ -196,8 +195,8 @@
if os.environ.has_key (key):
# Some systems (most notably Debian...) set $LANGUAGE to a *list* of
# locales, separated by a ":".
- envLang = (os.environ [key]).split (':') [0]
- return locale.locale_alias.get (envLang, envLang)
+ env_lang = (os.environ [key]).split (':') [0]
+ return locale.locale_alias.get (env_lang, env_lang)
# Now this should only happen on Windows, where getdefaultlocale seems to
# work ok.
@@ -219,7 +218,7 @@
# On win32, getlocale is broken - it returns strings like Hungarian_Hungary
# instead of hu_HU.
- if sys.platform in ['win32','Pocket PC']:
+ if sys.platform in ['win32', 'Pocket PC']:
(language, encoding) = locale.getdefaultlocale ()
else:
(language, encoding) = locale.getlocale ()
@@ -235,7 +234,7 @@
# Change the current locale
# -----------------------------------------------------------------------------
-def setcurrentlocale (newLocale):
+def setcurrentlocale (new_locale):
"""
Set the current locale.
@@ -243,21 +242,21 @@
locale, i.e. if 'address@hidden' fails, 'de_AT' will be tried next. If that
fails
too, 'de' will be tried.
- @param newLocale: string of the locale to be set, e.g. address@hidden
+ @param new_locale: string of the locale to be set, e.g. address@hidden
(full blown) or 'de_AT' or 'en_AU'
"""
# Setting a locale different than the current locale doesn't work on Windows.
if sys.platform == 'win32':
return
- if newLocale is None:
- newLocale = ''
+ if new_locale is None:
+ new_locale = ''
- newLocale = newLocale.encode ()
+ new_locale = new_locale.encode ()
parts = []
add = []
- normal = locale.normalize (newLocale) # address@hidden
+ normal = locale.normalize (new_locale) # address@hidden
next = normal.split ('@') [0] # lc_CC.ENCODING
lang = next.split ('.') [0] # lc_CC
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8408 - trunk/gnue-common/src/apps,
reinhard <=