2326
2326
import punctuation_settings
2330
line = line.decode("UTF-8")
2331
except UnicodeEncodeError:
2335
segment = segment.decode("UTF-8")
2336
except UnicodeEncodeError:
2329
2339
style = settings.verbalizePunctuationStyle
2330
2340
isPunctChar = True
2343
2353
# space characters". The %d is the number and the %s
2344
2354
# is the spoken word for the character.
2347
+ ngettext("%(count)d %(repeatChar)s character",
2356
repeatSegment = ngettext("%(count)d %(repeatChar)s character",
2348
2357
"%(count)d %(repeatChar)s characters",
2350
% {"count" : count, "repeatChar": repeatChar}
2359
% {"count" : count, "repeatChar": repeatChar}
2362
repeatSegment = repeatSegment.decode("UTF-8")
2363
except UnicodeEncodeError:
2366
line = "%s %s" % (line, repeatSegment)
2352
2368
line += segment
2465
2481
words = self.WORDS_RE.split(line)
2466
newLine = ' '.join(map(self._pronunciationForSegment, words))
2482
newLine = ''.join(map(self._pronunciationForSegment, words))
2469
2485
newLine = newLine.encode("UTF-8")
2593
2609
and returns the new string. Edge cases, such as no initial text or
2594
2610
no newText, are handled gracefully."""
2596
if not newText or len(newText) == 0:
2598
elif text and len(text):
2599
return text + delimiter + newText
2618
text = text.decode("UTF-8")
2619
except UnicodeEncodeError:
2623
newText = newText.decode("UTF-8")
2624
except UnicodeEncodeError:
2627
return text + delimiter + newText
2603
2629
def isAutoTextEvent(self, event):
2604
2630
"""Returns True if event is associated with text being autocompleted
2605
2631
or autoinserted or autocorrected or autosomethingelsed.
2832
2858
value = obj.queryValue()
2833
2859
except NotImplementedError:
2836
# OK, this craziness is all about trying to figure out the most
2837
# meaningful formatting string for the floating point values.
2838
# The number of places to the right of the decimal point should
2839
# be set by the minimumIncrement, but the minimumIncrement isn't
2840
# always set. So...we'll default the minimumIncrement to 1/100
2841
# of the range. But, if max == min, then we'll just go for showing
2842
# them off to two meaningful digits.
2845
minimumIncrement = value.minimumIncrement
2847
minimumIncrement = 0.0
2849
if minimumIncrement == 0.0:
2850
minimumIncrement = (value.maximumValue - value.minimumValue) \
2854
decimalPlaces = max(0, -math.log10(minimumIncrement))
2857
decimalPlaces = max(0, -math.log10(value.minimumValue))
2860
decimalPlaces = max(0, -math.log10(value.maximumValue))
2862
currentValue = value.currentValue
2864
# "The reports of my implementation are greatly exaggerated."
2866
maxValue = value.maximumValue
2869
debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
2870
"LookupError accessing maximumValue for %s" % obj)
2872
minValue = value.minimumValue
2875
debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
2876
"LookupError accessing minimumValue for %s" % obj)
2878
minIncrement = value.minimumIncrement
2880
minIncrement = (maxValue - minValue) / 100.0
2881
debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
2882
"LookupError accessing minimumIncrement for %s" % obj)
2885
decimalPlaces = math.ceil(max(0, -math.log10(minIncrement)))
2864
2889
formatter = "%%.%df" % decimalPlaces
2865
valueString = formatter % value.currentValue
2866
#minString = formatter % value.minimumValue
2867
#maxString = formatter % value.maximumValue
2869
# [[[TODO: WDW - probably want to do this as a percentage at some
2870
# point? Logged as bugzilla bug 319743.]]]
2890
return formatter % currentValue
2875
2893
def unicodeValueString(character):