Ticket #1684: 0002-Consistent-variable-names.patch

File 0002-Consistent-variable-names.patch, 3.6 KB (added by sayamindu, 14 years ago)

Consistent variable name underscoring

  • src/sugar/activity/i18n.py

    From 1817caf30f16712c59475db2af98030f9456cebf Mon Sep 17 00:00:00 2001
    From: Sayamindu Dasgupta <sayamindu@gmail.com>
    Date: Tue, 9 Feb 2010 17:13:04 +0530
    Subject: Consistent variable names
    
    ---
     src/sugar/activity/i18n.py |   38 +++++++++++++++++++-------------------
     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 b _MO_BIG_ENDIAN = 0xde120495 
    3131_MO_LITTLE_ENDIAN = 0x950412de
    3232
    3333
    34 def _readbin(handle, fmt, bytecount):
     34def _read_bin(handle, fmt, bytecount):
    3535    read_bytes = handle.read(bytecount)
    36     retvalue = struct.unpack(fmt, read_bytes)
    37     if len(retvalue) == 1:
    38         return retvalue[0]
     36    ret_value = struct.unpack(fmt, read_bytes)
     37    if len(ret_value) == 1:
     38        return ret_value[0]
    3939    else:
    40         return retvalue
     40        return ret_value
    4141
    4242
    4343def _extract_header(filepath):
    4444    header = ''
    4545    handle = open(filepath, 'rb')
    46     magic_number = _readbin(handle, '<I', 4)
     46    magic_number = _read_bin(handle, '<I', 4)
    4747
    4848    if magic_number == _MO_BIG_ENDIAN:
    4949        fmt = '>II'
    def _extract_header(filepath): 
    5252    else:
    5353        raise IOError('File does not seem to be valid MO file')
    5454
    55     version_, numofstrings = _readbin(handle, fmt, 8)
     55    version_, num_of_strings = _read_bin(handle, fmt, 8)
    5656
    57     msgids_hash_offset, msgstrs_hash_offset = _readbin(handle, fmt, 8)
     57    msgids_hash_offset, msgstrs_hash_offset = _read_bin(handle, fmt, 8)
    5858    handle.seek(msgids_hash_offset)
    5959
    6060    msgids_index = []
    61     for i in range(numofstrings):
    62         msgids_index.append(_readbin(handle, fmt, 8))
     61    for i in range(num_of_strings):
     62        msgids_index.append(_read_bin(handle, fmt, 8))
    6363    handle.seek(msgstrs_hash_offset)
    6464
    6565    msgstrs_index = []
    66     for i in range(numofstrings):
    67         msgstrs_index.append(_readbin(handle, fmt, 8))
     66    for i in range(num_of_strings):
     67        msgstrs_index.append(_read_bin(handle, fmt, 8))
    6868
    69     for i in range(numofstrings):
     69    for i in range(num_of_strings):
    7070        handle.seek(msgids_index[i][1])
    7171        msgid = handle.read(msgids_index[i][0])
    7272        if msgid == '':
    def _extract_modification_time(filepath): 
    8686    items = header.split('\n')
    8787    for item in items:
    8888        if item.startswith('PO-Revision-Date:'):
    89             timestr = item.split(': ')[1]
    90             parsedtime = dateutil.parser.parse(timestr)
    91             return time.mktime(parsedtime.timetuple())
     89            time_str = item.split(': ')[1]
     90            parsed_time = dateutil.parser.parse(time_str)
     91            return time.mktime(parsed_time.timetuple())
    9292
    9393    raise ValueError('Could not find revision date')
    9494    return -1
    def get_locale_path(bundle_id): 
    124124
    125125    for candidate_dir in candidate_dirs.keys():
    126126        if os.path.exists(candidate_dir):
    127             fullpath = os.path.join(candidate_dir, \
     127            full_path = os.path.join(candidate_dir, \
    128128                locale.getdefaultlocale()[0], 'LC_MESSAGES', \
    129129                bundle_id + '.mo')
    130             if os.path.exists(fullpath):
     130            if os.path.exists(full_path):
    131131                try:
    132132                    candidate_dirs[candidate_dir] = \
    133                         _extract_modification_time(fullpath)
     133                        _extract_modification_time(full_path)
    134134                except (IOError, ValueError):
    135135                    # The mo file is damaged or has not been initialized
    136136                    # Set lowest priority