mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-08-27 10:19:22 +00:00
Updated accessible_output2. Add mac and a better linux support
This commit is contained in:
@@ -5,27 +5,43 @@ class OutputError(Exception):
|
||||
pass
|
||||
|
||||
class Output(object):
|
||||
name = "Unnamed Output" #The name of this output
|
||||
lib32 = None #name of 32-bit lib
|
||||
lib64 = None #name of 64-bit lib
|
||||
priority = 100 #Where to sort in the list of available outputs for automaticly speaking
|
||||
name = "Unnamed Output"
|
||||
lib32 = None
|
||||
lib64 = None
|
||||
argtypes = {}
|
||||
cdll = False
|
||||
priority = 100
|
||||
system_output = False
|
||||
|
||||
def __init__(self):
|
||||
is_32bit = platform.architecture()[0] == "32bit"
|
||||
if self.lib32 and is_32bit:
|
||||
self.lib = load_library(self.lib32)
|
||||
self.is_32bit = platform.architecture()[0] == "32bit"
|
||||
if self.lib32 and self.is_32bit:
|
||||
self.lib = load_library(self.lib32, cdll=self.cdll)
|
||||
elif self.lib64:
|
||||
self.lib = load_library(self.lib64)
|
||||
self.lib = load_library(self.lib64, cdll=self.cdll)
|
||||
else:
|
||||
self.lib = None
|
||||
if self.lib is not None:
|
||||
for func in self.argtypes:
|
||||
try:
|
||||
getattr(self.lib, func).argtypes = self.argtypes[func]
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def output(self, text, **options):
|
||||
output = False
|
||||
if hasattr(self, 'speak') and callable(self.speak):
|
||||
self.speak(text, **options)
|
||||
if self.speak(text, **options):
|
||||
output = True
|
||||
if hasattr(self, 'braille') and callable(self.braille):
|
||||
self.braille(text, **options)
|
||||
if self.braille(text, **options):
|
||||
output = True
|
||||
if not output:
|
||||
raise RuntimeError("Output %r does not have any method defined to output" % self)
|
||||
|
||||
def is_system_output(self):
|
||||
return self.system_output
|
||||
|
||||
def speak(self, **optiont):
|
||||
return False
|
||||
|
||||
def braille(self, **options):
|
||||
return False
|
||||
|
Reference in New Issue
Block a user