This file is indexed.

/usr/share/pyshared/Wammu/Locales.py is in wammu 0.36-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# -*- coding: UTF-8 -*-
# vim: expandtab sw=4 ts=4 sts=4:
'''
Wammu - Phone manager
Locales initialisation and gettext wrapper
'''
__author__ = 'Michal Čihař'
__email__ = 'michal@cihar.com'
__license__ = '''
Copyright © 2003 - 2010 Michal Čihař

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
'''

import os
import gettext
import locale
import codecs
import __builtin__
import wx
import sys


LOCAL_LOCALE_PATH = os.path.join('build', 'share', 'locale')
LOCALE_PATH = None

FALLBACK_LOCALE_CHARSET = 'iso-8859-1'

# Determine "correct" character set
try:
    # works only in python > 2.3
    LOCALE_CHARSET = locale.getpreferredencoding()
except:
    try:
        LOCALE_CHARSET = locale.getdefaultlocale()[1]
    except:
        try:
            LOCALE_CHARSET = sys.getdefaultencoding()
        except:
            LOCALE_CHARSET = FALLBACK_LOCALE_CHARSET
if LOCALE_CHARSET in [None, 'ANSI_X3.4-1968']:
    LOCALE_CHARSET = FALLBACK_LOCALE_CHARSET

try:
    CONSOLE_CHARSET = sys.stdout.encoding
except AttributeError:
    CONSOLE_CHARSET = None
if CONSOLE_CHARSET is None:
    CONSOLE_CHARSET = LOCALE_CHARSET
CONSOLE_ENCODER = codecs.getencoder(CONSOLE_CHARSET)

def ConsoleStrConv(txt):
    """
    This function coverts something (txt) to string form usable on console.
    """
    try:
        if type(txt) == type(''):
            return txt
        if type(txt) == type(u''):
            return str(CONSOLE_ENCODER(txt, 'replace')[0])
        return str(txt)
    except UnicodeEncodeError:
        return '???'

def StrConv(txt):
    """
    This function coverts something (txt) to string form usable by wxPython. There
    is problem that in default configuration in most distros (maybe all) default
    encoding for unicode objects is ascii. This leads to exception when converting
    something different than ascii. And this exception is not catched inside
    wxPython and leads to segfault.

    So if wxPython supports unicode, we give it unicode, otherwise locale
    dependant text.
    """
    try:
        if type(txt) == type(u''):
            return txt
        if type(txt) == type(''):
            return unicode(txt, LOCALE_CHARSET)
        return str(txt)
    except UnicodeEncodeError:
        return '???'

# detect html charset
HTML_CHARSET = LOCALE_CHARSET

# prepare html encoder
HTML_ENCODER = codecs.getencoder(HTML_CHARSET)

def HtmlStrConv(txt):
    """
    This function coverts something (txt) to string form usable by wxPython
    html widget. There is problem that in default configuration in most distros
    (maybe all) default encoding for unicode objects is ascii. This leads to
    exception when converting something different than ascii. And this
    exception is not catched inside wxPython and leads to segfault.

    So if wxPython supports unicode, we give it unicode, otherwise locale
    dependant text.
    """
    try:
        if type(txt) == type(u''):
            return txt
        if type(txt) == type(''):
            return unicode(txt, LOCALE_CHARSET)
        return str(txt)
    except UnicodeEncodeError:
        return '???'

def UnicodeConv(txt):
    """
    This function coverts something (txt) to string form usable by wxPython. There
    is problem that in default configuration in most distros (maybe all) default
    encoding for unicode objects is ascii. This leads to exception when converting
    something different than ascii. And this exception is not catched inside
    wxPython and leads to segfault.

    So if wxPython supports unicode, we give it unicode, otherwise locale
    dependant text.
    """
    try:
        if type(txt) == type(u''):
            return txt
        if type(txt) == type(''):
            return unicode(txt, LOCALE_CHARSET)
        return unicode(str(txt), LOCALE_CHARSET)
    except UnicodeEncodeError:
        return unicode('???')

class WammuTranslations(gettext.GNUTranslations):
    '''
    Wrapper for gettext returning always "correct" charset.
    '''
    def ngettext(self, msgid1, msgid2, n):
        result = gettext.GNUTranslations.ngettext(self, msgid1, msgid2, n)
        if type(result) == type(''):
            return unicode(result, 'utf-8')
        else:
            return result

    def ugettext(self, message):
        result = gettext.GNUTranslations.gettext(self, message)
        if type(result) == type(''):
            return unicode(result, 'utf-8')
        else:
            return result

    def gettext(self, message):
        return self.ugettext(message)

    def hgettext(self, message):
        return self.ugettext(message)

def Init():
    '''
    Initialises gettext for wammu domain and installs global function _,
    which handles translations.
    '''
    global LOCALE_PATH
    switch = False
    if (os.path.exists('setup.py') and
        os.path.exists(LOCAL_LOCALE_PATH) and
        os.path.exists(
            os.path.join('Wammu', '__init__.py')
            )):
        LOCALE_PATH = LOCAL_LOCALE_PATH
        switch = True
    Install()
    if switch:
        print ConsoleStrConv(_('Automatically switched to local locales.'))

def UseLocal():
    '''
    Use locales from current build dir.
    '''
    global LOCALE_PATH
    LOCALE_PATH = LOCAL_LOCALE_PATH
    Install()

def ngettext(msgid1, msgid2, n):
    if n == 1:
        return msgid1
    else:
        return msgid2

def ugettext(message):
    return message

def lgettext(message):
    return message

def hgettext(message):
    return message

def Install():
    global LOCALE_PATH, ngettext, ugettext, lgettext, hgettext
    try:
        trans = gettext.translation('wammu',
            class_ = WammuTranslations,
            localedir = LOCALE_PATH)
        __builtin__.__dict__['_'] = trans.gettext
        ngettext = trans.ngettext
        ugettext = trans.ugettext
        lgettext = trans.lgettext
        hgettext = trans.hgettext
    except IOError:
        # No translation found for current locale
        __builtin__.__dict__['_'] = ugettext
        pass