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 2073 2007-03-01 17:20:32Z wwalker $" |
43 |
1 |
__version__ = "$Revision: 2073 $" |
44 |
1 |
__date__ = "$Date: 2007-03-01 09:20:32 -0800 (Thu, 01 Mar 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 |
|
# __punctuation is a dictionary where the keys represent a UTF-8 |
57 |
|
# character (possibly multibyte) and the values are a list of two |
58 |
|
# elements where the first represents the punctuation style and |
59 |
|
# the second represents the action to take. |
60 |
|
# |
61 |
1 |
__punctuation = {} |
62 |
|
|
63 |
1 |
__punctuation["!"] = [ settings.PUNCTUATION_STYLE_ALL, PUNCTUATION_INSERT ] |
64 |
1 |
__punctuation["'"] = [ settings.PUNCTUATION_STYLE_ALL, PUNCTUATION_REPLACE ] |
65 |
1 |
__punctuation[","] = [ settings.PUNCTUATION_STYLE_ALL, PUNCTUATION_INSERT ] |
66 |
1 |
__punctuation["."] = [ settings.PUNCTUATION_STYLE_ALL, PUNCTUATION_INSERT ] |
67 |
1 |
__punctuation["?"] = [ settings.PUNCTUATION_STYLE_ALL, PUNCTUATION_INSERT ] |
68 |
|
|
69 |
1 |
__punctuation["\""] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
70 |
1 |
__punctuation["("] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
71 |
1 |
__punctuation[")"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
72 |
1 |
__punctuation["-"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
73 |
1 |
__punctuation["_"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
74 |
1 |
__punctuation[":"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_INSERT ] |
75 |
1 |
__punctuation[";"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_INSERT ] |
76 |
1 |
__punctuation["<"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
77 |
1 |
__punctuation[">"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
78 |
1 |
__punctuation["["] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
79 |
1 |
__punctuation["]"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
80 |
1 |
__punctuation["\\"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
81 |
1 |
__punctuation["|"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
82 |
1 |
__punctuation["`"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
83 |
1 |
__punctuation["~"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
84 |
1 |
__punctuation["{"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
85 |
1 |
__punctuation["}"] = [ settings.PUNCTUATION_STYLE_MOST, PUNCTUATION_REPLACE ] |
86 |
|
|
87 |
1 |
__punctuation["#"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
88 |
1 |
__punctuation["$"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
89 |
1 |
__punctuation["%"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
90 |
1 |
__punctuation["&"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
91 |
1 |
__punctuation["*"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
92 |
1 |
__punctuation["+"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
93 |
1 |
__punctuation["/"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
94 |
1 |
__punctuation["="] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
95 |
1 |
__punctuation["@"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
96 |
1 |
__punctuation["^"] = [ settings.PUNCTUATION_STYLE_SOME, PUNCTUATION_REPLACE ] |
97 |
|
|
98 |
1 |
def getPunctuationInfo(character): |
99 |
|
"""Given a punctuation character, return the value |
100 |
|
[punctuation_style, punctuation_action] or None |
101 |
|
|
102 |
|
Arguments: |
103 |
|
- character: the punctuation character to get the information for |
104 |
|
|
105 |
|
Returns return the value [punctuation_style, punctuation_action] |
106 |
|
or None |
107 |
|
""" |
108 |
|
|
109 |
540 |
if isinstance(character, unicode): |
110 |
540 |
character = character.encode("UTF-8") |
111 |
|
|
112 |
540 |
try: |
113 |
540 |
return __punctuation[character] |
114 |
526 |
except: |
115 |
526 |
return None |