Coverage Report - orca.phonnames

ModuleCoverage %
orca.phonnames
85%
1
# Orca
2
#
3
# Copyright 2006 Sun Microsystems Inc.
4
#
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Library General Public
7
# License as published by the Free Software Foundation; either
8
# version 2 of the License, or (at your option) any later version.
9
#
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# Library General Public License for more details.
14
#
15
# You should have received a copy of the GNU Library General Public
16
# License along with this library; if not, write to the
17
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
# Boston, MA 02111-1307, USA.
19
20
"""Provides getPhoneticName method that maps each letter of the
21 1
alphabet into its localized phonetic equivalent."""
22
23 1
__id__        = "$Id: phonnames.py 1529 2006-10-05 16:31:04Z wwalker $"
24 1
__version__   = "$Revision: 1529 $"
25 1
__date__      = "$Date: 2006-10-05 09:31:04 -0700 (Thu, 05 Oct 2006) $"
26 1
__copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc."
27 1
__license__   = "LGPL"
28
29 1
from orca_i18n import _ # for gettext support
30
31
# __phonnames is a dictionary where the keys represent a UTF-8
32
# character (possibly multibyte) and the values represent the common
33
# 'military' term used for the character.
34
#
35 1
__phonnames = {}
36 1
__phonnames["a"] = _("alpha")
37 1
__phonnames["b"] = _("bravo")
38 1
__phonnames["c"] = _("charlie")
39 1
__phonnames["d"] = _("delta")
40 1
__phonnames["e"] = _("echo")
41 1
__phonnames["f"] = _("foxtrot")
42 1
__phonnames["g"] = _("golf")
43 1
__phonnames["h"] = _("hotel")
44 1
__phonnames["i"] = _("india")
45 1
__phonnames["j"] = _("juliet")
46 1
__phonnames["k"] = _("kilo")
47 1
__phonnames["l"] = _("lima")
48 1
__phonnames["m"] = _("mike")
49 1
__phonnames["n"] = _("november")
50 1
__phonnames["o"] = _("oscar")
51 1
__phonnames["p"] = _("papa")
52 1
__phonnames["q"] = _("quebec")
53 1
__phonnames["r"] = _("romeo")
54 1
__phonnames["s"] = _("sierra")
55 1
__phonnames["t"] = _("tango")
56 1
__phonnames["u"] = _("uniform")
57 1
__phonnames["v"] = _("victor")
58 1
__phonnames["w"] = _("whiskey")
59 1
__phonnames["x"] = _("xray")
60 1
__phonnames["y"] = _("yankee")
61 1
__phonnames["z"] = _("zulu")
62
63 1
def getPhoneticName(character):
64
    """Given a character, return its phonetic name, which is typically
65
    the 'military' term used for the character.
66
67
    Arguments:
68
    - character: the character to get the military name for
69
70
    Returns a string representing the military name for the character
71
    """
72
73 0
    if isinstance(character, unicode):
74 0
        character = character.encode("UTF-8")
75
76 0
    try:
77 0
        return __phonnames[character]
78 0
    except:
79 0
        return character