Coverage Report - orca.punctuation_settings

ModuleCoverage %
orca.punctuation_settings
99%
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
"""Punctuation Verbosity settings.
21
The Orca punctuation settings are broken up into 4 modes.
22
23
These modes are None, Some, Most and All.
24
25
They are defined by a group of radio buttons on the speech
26
page of the configuration user interface.
27
28
Each mode is defined below. The 4 bits of information listed here are:
29
30
  - The actual printed symbol.
31
32
  - How the symbol should be pronounced (in the chnames dictionary in
33
    chnames.py keyed by symbol).
34
35
  - The level at which the symbol should be spoken. Note that this
36
    denotes the level containing all lower levels.
37
38
  - Whether or not the spoken name for the symbol should replace the
39
    actual symbol or be inserted before the symbol.
40 1
"""
41
42 1
__id__        = "$Id: punctuation_settings.py 2309 2007-04-23 14:04:01Z joanied $"
43 1
__version__   = "$Revision: 2309 $"
44 1
__date__      = "$Date: 2007-04-23 10:04:01 -0400 (Mon, 23 Apr 2007) $"
45 1
__copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc."
46 1
__license__   = "LGPL"
47
48 1
import settings
49
50
#  Whether or not the spoken name for the symbol should replace the
51
#  actual symbol or be inserted before the symbol.
52
#
53 1
PUNCTUATION_REPLACE = 0
54 1
PUNCTUATION_INSERT  = 1
55
56
# The lowest level at which the spoken name should be spoken. Thus a symbol
57
# with a level of LEVEL_MOST will be spoken at LEVEL_MOST and LEVEL_ALL.
58
#
59 1
LEVEL_ALL  = settings.PUNCTUATION_STYLE_ALL
60 1
LEVEL_MOST = settings.PUNCTUATION_STYLE_MOST
61 1
LEVEL_SOME = settings.PUNCTUATION_STYLE_SOME
62 1
LEVEL_NONE = settings.PUNCTUATION_STYLE_NONE
63
64
# Bullets and bullet-like characters
65
#
66 1
middle_dot           =  u'\u00b7'
67 1
bullet               =  u'\u2022'
68 1
triangular_bullet    =  u'\u2023'
69 1
hyphen_bullet        =  u'\u2043'
70 1
black_square         =  u'\u25a0'
71 1
white_square         =  u'\u25a1'
72 1
white_bullet         =  u'\u25e6'
73 1
white_circle         =  u'\u25cb'
74 1
black_diamond        =  u'\u25c6'
75 1
black_circle         =  u'\u25cf'
76 1
check_mark           =  u'\u2713'
77 1
heavy_check_mark     =  u'\u2714'
78 1
x_shaped_bullet      =  u'\u2717'
79 1
right_arrow          =  u'\u2794'
80 1
right_arrowhead      =  u'\u27a2'
81
82
# StarOffice/OOo's special-purpose bullet chararacters
83
#
84 1
SO_black_square      =  u'\ue00a'
85 1
SO_black_diamond     =  u'\ue00c'
86
87
# Miscellaneous other symbols
88
#
89 1
cent                 =  u'\u00a2'
90 1
pound                =  u'\u00a3'
91 1
yen                  =  u'\u00a5'
92 1
section              =  u'\u00a7'
93 1
copyright            =  u'\u00a9'
94 1
not_sign             =  u'\u00ac'
95 1
registered           =  u'\u00ae'
96 1
degree               =  u'\u00b0'
97 1
plus_minus           =  u'\u00b1'
98 1
superscript2         =  u'\u00b2'
99 1
superscript3         =  u'\u00b3'
100 1
one_quarter          =  u'\u00bc'
101 1
one_half             =  u'\u00bd'
102 1
three_quarters       =  u'\u00be'
103 1
multiply             =  u'\u00d7'
104 1
divide               =  u'\u00f7'
105 1
en_dash              =  u'\u2013'
106 1
left_single_quote    =  u'\u2018'
107 1
right_single_quote   =  u'\u2019'
108 1
left_double_quote    =  u'\u201c'
109 1
right_double_quote   =  u'\u201d'
110 1
dagger               =  u'\u2020'
111 1
double_dagger        =  u'\u2021'
112 1
per_mille            =  u'\u2030'
113 1
prime                =  u'\u2032'
114 1
double_prime         =  u'\u2033'
115 1
euro                 =  u'\u20ac'
116 1
trademark            =  u'\u2122'
117 1
infinity             =  u'\u221e'
118 1
almost_equal         =  u'\u2248'
119 1
not_equal            =  u'\u2260'
120 1
lt_or_equal          =  u'\u2264'
121 1
gt_or_equal          =  u'\u2265'
122 1
square_root          =  u'\u221a'
123 1
cube_root            =  u'\u221b'
124
125
# punctuation is a dictionary where the keys represent a unicode
126
# character and the values are a list of two elements where the
127
# first represents the punctuation style and the second represents
128
# the action to take.
129
#
130 1
punctuation = {}
131
132 1
punctuation["!"] =  [ LEVEL_ALL,  PUNCTUATION_INSERT ]
133 1
punctuation["'"] =  [ LEVEL_ALL,  PUNCTUATION_REPLACE ]
134 1
punctuation[","] =  [ LEVEL_ALL,  PUNCTUATION_INSERT ]
135 1
punctuation["."] =  [ LEVEL_ALL,  PUNCTUATION_INSERT ]
136 1
punctuation["?"] =  [ LEVEL_ALL,  PUNCTUATION_INSERT ]
137 1
punctuation[right_single_quote] = [ LEVEL_ALL, PUNCTUATION_REPLACE ]
138
139 1
punctuation["\""] = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
140 1
punctuation["("]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
141 1
punctuation[")"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
142 1
punctuation["-"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
143 1
punctuation["_"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
144 1
punctuation[":"]  = [ LEVEL_MOST, PUNCTUATION_INSERT ]
145 1
punctuation[";"]  = [ LEVEL_MOST, PUNCTUATION_INSERT ]
146 1
punctuation["<"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
147 1
punctuation[">"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
148 1
punctuation["["]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
149 1
punctuation["]"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
150 1
punctuation["\\"] = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
151 1
punctuation["|"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
152 1
punctuation["`"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
153 1
punctuation["~"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
154 1
punctuation["{"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
155 1
punctuation["}"]  = [ LEVEL_MOST, PUNCTUATION_REPLACE ]
156 1
punctuation[left_single_quote]  =  [ LEVEL_MOST, PUNCTUATION_REPLACE ]
157 1
punctuation[left_double_quote]  =  [ LEVEL_MOST, PUNCTUATION_REPLACE ]
158 1
punctuation[right_double_quote] =  [ LEVEL_MOST, PUNCTUATION_REPLACE ]
159 1
punctuation[en_dash]            =  [ LEVEL_MOST, PUNCTUATION_REPLACE ]
160
161 1
punctuation["#"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
162 1
punctuation["$"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
163 1
punctuation["%"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
164 1
punctuation["&"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
165 1
punctuation["*"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
166 1
punctuation["+"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
167 1
punctuation["/"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
168 1
punctuation["="] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
169 1
punctuation["@"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
170 1
punctuation["^"] =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
171 1
punctuation[cent]               =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
172 1
punctuation[pound]              =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
173 1
punctuation[yen]                =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
174 1
punctuation[euro]               =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
175 1
punctuation[not_sign]           =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
176 1
punctuation[copyright]          =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
177 1
punctuation[registered]         =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
178 1
punctuation[trademark]          =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
179 1
punctuation[degree]             =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
180 1
punctuation[plus_minus]         =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
181 1
punctuation[multiply]           =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
182 1
punctuation[divide]             =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
183 1
punctuation[infinity]           =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
184 1
punctuation[almost_equal]       =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
185 1
punctuation[not_equal]          =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
186 1
punctuation[lt_or_equal]        =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
187 1
punctuation[gt_or_equal]        =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
188 1
punctuation[square_root]        =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
189 1
punctuation[cube_root]          =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
190 1
punctuation[dagger]             =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
191 1
punctuation[double_dagger]      =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
192 1
punctuation[section]            =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
193 1
punctuation[prime]              =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
194 1
punctuation[double_prime]       =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
195 1
punctuation[per_mille]          =  [ LEVEL_SOME, PUNCTUATION_REPLACE ]
196
197 1
punctuation[middle_dot]         =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
198 1
punctuation[bullet]             =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
199 1
punctuation[triangular_bullet]  =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
200 1
punctuation[hyphen_bullet]      =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
201 1
punctuation[black_square]       =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
202 1
punctuation[white_square]       =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
203 1
punctuation[white_bullet]       =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
204 1
punctuation[white_circle]       =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
205 1
punctuation[black_diamond]      =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
206 1
punctuation[black_circle]       =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
207 1
punctuation[check_mark]         =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
208 1
punctuation[heavy_check_mark]   =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
209 1
punctuation[x_shaped_bullet]    =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
210 1
punctuation[right_arrow]        =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
211 1
punctuation[right_arrowhead]    =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
212 1
punctuation[SO_black_square]    =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
213 1
punctuation[SO_black_diamond]   =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
214 1
punctuation[one_quarter]        =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
215 1
punctuation[one_half]           =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
216 1
punctuation[three_quarters]     =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
217 1
punctuation[superscript3]       =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
218 1
punctuation[superscript2]       =  [ LEVEL_NONE, PUNCTUATION_REPLACE ]
219
220 1
def getPunctuationInfo(character):
221
    """Given a punctuation character, return the value
222
    [punctuation_style, punctuation_action] or None
223
224
    Arguments:
225
    - character: the punctuation character to get the information for
226
227
    Returns return the value [punctuation_style, punctuation_action]
228
    or None
229
    """
230
231 607
    if not isinstance(character, unicode):
232 0
        character = character.decode("UTF-8")
233
234 607
    try:
235 607
        return punctuation[character]
236 593
    except:
237 593
        return None