Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist/'
docs/_build
__pycache__/
*.py[cod]
*.egg-info
77 changes: 29 additions & 48 deletions accessible_output2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,29 @@
from __future__ import absolute_import
import ctypes
import os
import types
from platform_utils import paths


def load_library(libname, cdll=False):
if paths.is_frozen():
libfile = os.path.join(
paths.embedded_data_path(), "accessible_output2", "lib", libname
)
else:
libfile = os.path.join(paths.module_path(), "lib", libname)
if not os.path.exists(libfile):
_cxfreeze_libfile = os.path.join(
paths.embedded_data_path(), "lib", "accessible_output2", "lib", libname
)
if os.path.exists(_cxfreeze_libfile):
libfile = _cxfreeze_libfile
if cdll:
return ctypes.cdll[libfile]
return ctypes.windll[libfile]


def get_output_classes():
from . import outputs

module_type = types.ModuleType
classes = [
m.output_class
for m in outputs.__dict__.values()
if isinstance(m, module_type) and hasattr(m, "output_class")
]
return sorted(classes, key=lambda c: c.priority)


def find_datafiles():
import platform
from glob import glob
import accessible_output2

if platform.system() != "Windows":
return []
path = os.path.join(accessible_output2.__path__[0], "lib", "*.dll")
results = glob(path)
dest_dir = os.path.join("accessible_output2", "lib")
return [(dest_dir, results)]
from __future__ import absolute_import
import ctypes
import types
from pathlib import Path

lib = Path(__file__).parent / "lib"


def load_library(libname, cdll=False):

lib_path = lib / libname
libfile = str(lib_path)
dll_loader = ctypes.cdll if cdll else ctypes.windll
try:
return dll_loader[libfile]
except AttributeError:
return None


def get_output_classes():
from . import outputs

module_type = types.ModuleType
classes = [
m.output_class
for m in outputs.__dict__.values()
if isinstance(m, module_type) and hasattr(m, "output_class")
]
return sorted(classes, key=lambda c: c.priority)
Binary file removed accessible_output2/lib/ZDSRAPI.dll
Binary file not shown.
Binary file removed accessible_output2/lib/ZDSRAPI_x64.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion accessible_output2/outputs/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def braille(self, *args, **kwargs):
def output(self, *args, **kwargs):
output = self.get_first_available_output()
if output:
output.speak(*args, **kwargs)
output.output(*args, **kwargs)

def is_system_output(self):
"""Returns True if this output is a system output."""
Expand Down
4 changes: 2 additions & 2 deletions accessible_output2/outputs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def output(self, text, **options):
RuntimeError: If the requested output doesn't define either speak or braille.
"""
output = False
if self.speak(text, **options):
if self.speak(text, **options) is not False:
output = True
if self.braille(text, **options):
if self.braille(text, **options) is not False:
output = True
if not output:
raise RuntimeError(
Expand Down
4 changes: 0 additions & 4 deletions accessible_output2/outputs/nvda.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from __future__ import absolute_import
import os
import platform
import ctypes

from platform_utils import paths
from libloader import load_library
from .base import Output


Expand Down
28 changes: 15 additions & 13 deletions accessible_output2/outputs/zdsr.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
from __future__ import absolute_import
import os
import platform
import ctypes
import os
from pathlib import Path

from platform_utils import paths
from libloader import load_library
from .base import Output


class ZDSR(Output):
"""Supports The ZDSR screen reader"""

_dll_loc = Path(os.path.expandvars(R"%ProgramFiles(x86)%\zdsr\zdsr"))
name = "ZDSR"
lib32 = "ZDSRAPI.dll"
lib64 = "ZDSRAPI_x64.dll"
is_loaded=False
lib32 = _dll_loc / "ZDSRAPI.dll"
lib64 = _dll_loc / "ZDSRAPI_x64.dll"
is_loaded = False
argtypes = {
"speak": (ctypes.c_wchar_p,),
}

def load(self):
self.lib.InitTTS(0,"")
self.is_loaded=True
self.lib.InitTTS(0, "")
self.is_loaded = True

def is_active(self):
try:
if not self.is_loaded: self.load()
if not self.is_loaded:
self.load()
return self.lib.GetSpeakState() != 2
except:
return False

def speak(self, text, interrupt=False):
if not self.is_loaded: self.load()
self.lib.Speak(text,interrupt)
if not self.is_loaded:
self.load()
self.lib.Speak(text, interrupt)

def silence(self):
if not self.is_loaded: self.load()
if not self.is_loaded:
self.load()
self.lib.StopSpeak()


Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
libloader
platform_utils
libloader
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from setuptools import setup, find_packages
import io

__doc__ = (
"""Library to provide speech and braille output to a variety of different screen readers and other accessibility solutions."""
)
__doc__ = """Library to provide speech and braille output to a variety of different screen readers and other accessibility solutions."""

with io.open("readme.rst", encoding="UTF8") as readme:
long_description = readme.read()
Expand All @@ -19,7 +17,9 @@
packages=find_packages(),
package_data={"accessible_output2": ["lib/*"]},
zip_safe=False,
install_requires=["libloader", "platform_utils"],
install_requires=[
"libloader",
],
extras_require={
':sys_platform == "win32"': ["pywin32", "libloader"],
':sys_platform == "darwin"': ["appscript"],
Expand Down