Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSayamindu Dasgupta <sayamindu@gmail.com>2010-02-09 11:43:04 (GMT)
committer Sayamindu Dasgupta <sayamindu@gmail.com>2010-02-09 11:43:04 (GMT)
commit1817caf30f16712c59475db2af98030f9456cebf (patch)
tree6723671c43483ecdf5b689edd3f22a5ae8943e34
parentffe3504e0aba59f7bf7ae65e8f427647f3a4600a (diff)
Consistent variable names
-rw-r--r--src/sugar/activity/i18n.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/sugar/activity/i18n.py b/src/sugar/activity/i18n.py
index a91b912..d235a55 100644
--- a/src/sugar/activity/i18n.py
+++ b/src/sugar/activity/i18n.py
@@ -31,19 +31,19 @@ _MO_BIG_ENDIAN = 0xde120495
_MO_LITTLE_ENDIAN = 0x950412de
-def _readbin(handle, fmt, bytecount):
+def _read_bin(handle, fmt, bytecount):
read_bytes = handle.read(bytecount)
- retvalue = struct.unpack(fmt, read_bytes)
- if len(retvalue) == 1:
- return retvalue[0]
+ ret_value = struct.unpack(fmt, read_bytes)
+ if len(ret_value) == 1:
+ return ret_value[0]
else:
- return retvalue
+ return ret_value
def _extract_header(filepath):
header = ''
handle = open(filepath, 'rb')
- magic_number = _readbin(handle, '<I', 4)
+ magic_number = _read_bin(handle, '<I', 4)
if magic_number == _MO_BIG_ENDIAN:
fmt = '>II'
@@ -52,21 +52,21 @@ def _extract_header(filepath):
else:
raise IOError('File does not seem to be valid MO file')
- version_, numofstrings = _readbin(handle, fmt, 8)
+ version_, num_of_strings = _read_bin(handle, fmt, 8)
- msgids_hash_offset, msgstrs_hash_offset = _readbin(handle, fmt, 8)
+ msgids_hash_offset, msgstrs_hash_offset = _read_bin(handle, fmt, 8)
handle.seek(msgids_hash_offset)
msgids_index = []
- for i in range(numofstrings):
- msgids_index.append(_readbin(handle, fmt, 8))
+ for i in range(num_of_strings):
+ msgids_index.append(_read_bin(handle, fmt, 8))
handle.seek(msgstrs_hash_offset)
msgstrs_index = []
- for i in range(numofstrings):
- msgstrs_index.append(_readbin(handle, fmt, 8))
+ for i in range(num_of_strings):
+ msgstrs_index.append(_read_bin(handle, fmt, 8))
- for i in range(numofstrings):
+ for i in range(num_of_strings):
handle.seek(msgids_index[i][1])
msgid = handle.read(msgids_index[i][0])
if msgid == '':
@@ -86,9 +86,9 @@ def _extract_modification_time(filepath):
items = header.split('\n')
for item in items:
if item.startswith('PO-Revision-Date:'):
- timestr = item.split(': ')[1]
- parsedtime = dateutil.parser.parse(timestr)
- return time.mktime(parsedtime.timetuple())
+ time_str = item.split(': ')[1]
+ parsed_time = dateutil.parser.parse(time_str)
+ return time.mktime(parsed_time.timetuple())
raise ValueError('Could not find revision date')
return -1
@@ -124,13 +124,13 @@ def get_locale_path(bundle_id):
for candidate_dir in candidate_dirs.keys():
if os.path.exists(candidate_dir):
- fullpath = os.path.join(candidate_dir, \
+ full_path = os.path.join(candidate_dir, \
locale.getdefaultlocale()[0], 'LC_MESSAGES', \
bundle_id + '.mo')
- if os.path.exists(fullpath):
+ if os.path.exists(full_path):
try:
candidate_dirs[candidate_dir] = \
- _extract_modification_time(fullpath)
+ _extract_modification_time(full_path)
except (IOError, ValueError):
# The mo file is damaged or has not been initialized
# Set lowest priority