Skip to content

Commit

Permalink
Remove trailing spaces...
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris 'billiob' Faure committed May 18, 2009
1 parent 3764c22 commit d18e9b7
Show file tree
Hide file tree
Showing 72 changed files with 707 additions and 692 deletions.
44 changes: 22 additions & 22 deletions amsn2/core/lang.py
Expand Up @@ -7,37 +7,37 @@ class aMSNLang(object):
lang_dirs = []
base_lang = 'en'
lang_code = base_lang

default_encoding = 'utf-8'

lineRe = re.compile('\s*([^\s]+)\s+(.+)', re.UNICODE) # whitespace? + key + whitespace + value
langRe = re.compile('(.+)-.+', re.UNICODE) # code or code-variant

def loadLang(self, lang_code, force_reload=False):
if self.lang_code is lang_code and force_reload is False:
# Don't reload the same lang unless forced.
return

hasVariant = bool(self.langRe.match(lang_code) is not None)

# Check for lang variants.
if hasVariant is True:
root = str(self.langRe.split(lang_code)[1])
else:
root = str(lang_code)

if lang_code is self.base_lang:
# Clear the keys if we're loading the base lang.
self.clearKeys()

if root is not self.base_lang:
# If it's not the default lang, load the base first.
self.loadLang(self.base_lang)

if hasVariant is True:
# Then we have a variant, so load the root.
self.loadLang(root)

# Load the langfile from each langdir.
fileWasLoaded = False
for dir in self.getLangDirs():
Expand All @@ -47,26 +47,26 @@ def loadLang(self, lang_code, force_reload=False):
except IOError:
# file doesn't exist.
continue

line = f.readline()
while line:
if self.lineRe.match(line) is not None:
components = self.lineRe.split(line)
self.setKey(unicode(components[1], self.default_encoding), unicode(components[2], self.default_encoding))

# Get the next line...
line = f.readline()

f.close()

# If we've loaded a lang file, set the new lang code.
if fileWasLoaded is True:
self.lang_code = str(lang_code)

def addLangDir(self, lang_dir):
self.lang_dirs.append(str(lang_dir))
self.reloadKeys()

def removeLangDir(self, lang_dir):
try:
# Remove the lang_dir from the lang_dirs list, and reload keys.
Expand All @@ -76,7 +76,7 @@ def removeLangDir(self, lang_dir):
except ValueError:
# Dir not in list.
return False

def getLangDirs(self):
# Return a copy for them to play with.
return self.lang_dirs[:]
Expand All @@ -90,14 +90,14 @@ def reloadKeys(self):

def setKey(self, key, val):
self.lang_keys[key] = val

def getKey(self, key, replacements=[]):
try:
r = self.lang_keys[key]
except KeyError:
# Key doesn't exist.
return key

# Perform any replacements necessary.
if self._isDict(replacements):
# Replace from a dictionary.
Expand All @@ -109,19 +109,19 @@ def getKey(self, key, replacements=[]):
for replacement in replacements:
r = r.replace('$' + str(i), replacement)
i += 1

return r

def _isDict(self, test):
try:
test.keys()
return True
except AttributeError:
return False

def clearKeys(self):
self.lang_keys = {}

def printKeys(self):
print self.lang_code
print '{'
Expand Down
2 changes: 1 addition & 1 deletion amsn2/core/oim_manager.py
Expand Up @@ -21,4 +21,4 @@
class aMSNOIMManager:
def __init__(self, core):
self._core = core

8 changes: 4 additions & 4 deletions amsn2/core/personalinfo_manager.py
Expand Up @@ -19,23 +19,23 @@ def _onNickUpdated(self, new_nick):
# TODO: parsing
self._papyon_profile.display_name = new_nick.toString()
self._em.emit(self._em.events.PERSONALINFO_UPDATED, self._personalinfoview)

def _onPMUpdated(self, new_pm):
# TODO: parsing
self._papyon_profile.personal_message = new_pm.toString()
self._em.emit(self._em.events.PERSONALINFO_UPDATED, self._personalinfoview)

def _onDPUpdated(self, new_dp):
# TODO: manage msn_objects
self._em.emit(self._em.events.PERSONALINFO_UPDATED, self._personalinfoview)

def _onPresenceUpdated(self, new_presence):
for key in self._core.p2s:
if self._core.p2s[key] == new_presence:
break
self._papyon_profile.presence = key
self._em.emit(self._em.events.PERSONALINFO_UPDATED, self._personalinfoview)

""" actions from the core """
def _onCMUpdated(self, new_media):
self._papyon_profile.current_media = new_media
Expand Down

0 comments on commit d18e9b7

Please sign in to comment.