[ Avaa Bypassed ]




Upload:

Command:

www-data@3.18.105.157: ~ $
#!/usr/bin/python3
###############################################################################
# BRLTTY - A background process providing access to the console screen (when in
#          text mode) for a blind person using a refreshable braille display.
#
# Copyright (C) 1995-2019 by The BRLTTY Developers.
#
# BRLTTY comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU Lesser General Public License, as published by the Free Software
# Foundation; either version 2.1 of the License, or (at your option) any
# later version. Please see the file LICENSE-LGPL for details.
#
# Web Page: http://brltty.app/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################

# BRLTTY Contraction Table - latex-access (executable)

import sys, os

def putProgramMessage (message):
  stream = sys.stderr
  stream.write(os.path.basename(sys.argv[0]) + ": " + message + "\n")
  stream.flush()

def syntaxError (message):
  putProgramMessage(message)
  exit(2)

def semanticError (message):
  putProgramMessage(message)
  exit(3)

def systemError (message):
  putProgramMessage(message)
  exit(4)

def missingPackage (name):
  systemError("package not installed: " + name)

def putResponseProperty (keyword, value):
  value = unicode(value)
  if programArguments.verbose: putProgramMessage("rsp: " + keyword + "=" + value)

  stream = sys.stdout
  stream.write(keyword + "=" + value.encode("UTF-8") + "\n")
  stream.flush()

def getRequest ():
  request = {}

  while True:
    try:
      if programArguments.interactive:
        line = raw_input(packageName + "> ")
      else:
        line = raw_input()
    except EOFError:
      if len(request) == 0: return None
      semanticError("unexpected end-of-file on standard input")

    line = line.decode("UTF-8")
    components = line.split("=", 1)

    if len(components) > 1:
      (keyword, value) = components
      keyword = keyword.strip().lower()

      if programArguments.verbose: putProgramMessage("req: " + keyword + "=" + value)
      request[keyword] = value
      if keyword == "text": break

  return request

def processRequest ():
  request = getRequest()
  if not request: return False

  for attribute in ("displayLength", "cursorOffset", "expandCurrentWord", "consumedChars"):
    if hasattr(brailleTranslator, attribute):
      delattr(brailleTranslator, attribute)

  if request.has_key("maximum-length"):
    brailleTranslator.displayLength = int(request["maximum-length"])

  if request.has_key("cursor-position"):
    position = int(request["cursor-position"])

    if position > 0:
      brailleTranslator.cursorOffset = position - 1

      if request.has_key("expand-current-word"):
        brailleTranslator.expandCurrentWord = int(request["expand-current-word"]) != 0

  brailleTranslator.capitalisation = "6dot"
  if request.has_key("capitalization-mode"):
    if int(request["capitalization-mode"]) != 1:
      brailleTranslator.capitalisation = "8dot"

  text = request["text"]
  brf = brailleTranslator.translate(textPreprocessor.translate(text))

  if hasattr(brailleTranslator, "consumedChars"):
    consumedLength = brailleTranslator.consumedChars
    putResponseProperty("consumed-length", consumedLength)
  else:
    consumedLength = len(text)

  if hasattr(brailleTranslator, "src2trans"):
    offsets = brailleTranslator.src2trans
    if len(offsets) > consumedLength: offsets = offsets[:consumedLength]
    putResponseProperty("output-offsets", ",".join((str(offset) for offset in offsets)))

  putResponseProperty("brf", brf)
  return True

def parseProgramArguments ():
  import argparse
  parser = argparse.ArgumentParser(
    prog = os.path.basename(sys.argv[0]),
    usage = "%(prog)s [option ...]",
    description = """
      This is an executable contraction table for BRLTTY
      that uses the latex-access package
      to translate LaTeX mathematical notation into braille.
      BRLTTY can be found at [http://brltty.app/].
      latex-access can be found at [http://www.latex-access.sourceforge.net/].
    """
  )

  parser.add_argument(
    "-c", "--configuration",
    action = "store",
    nargs = 1,
    dest = "configuration",
    default = (
      os.path.join(os.path.expanduser("~"), "." + packageName),
      "/etc/" + packageName + ".conf"
    ),
    help = "the configuration file to use"
  )

  parser.add_argument(
    "-n", "--nemeth",
    action = "store_const",
    const = "nemeth",
    dest = "translator",
    help = "translate into Nemeth Code"
  )

  parser.add_argument(
    "-u", "--ueb",
    action = "store_const",
    const = "ueb",
    dest = "translator",
    help = "translate into Unified English Braille"
  )

  parser.add_argument(
    "-i", "--interactive",
    action = "store_true",
    dest = "interactive",
    help = "enable input editing and history"
  )

  parser.add_argument(
    "-v", "--verbose",
    action = "store_true",
    dest = "verbose",
    help = "show request and response properties on standard error"
  )

  return parser.parse_args()

if __name__ == "__main__":
  packageName = "latex-access"

  programArguments = parseProgramArguments()

  if programArguments.interactive:
    import readline, atexit
    historyFile=os.path.join(os.path.expanduser("~"), "." + packageName + ".history")
    atexit.register(readline.write_history_file, historyFile)
    readline.read_history_file(historyFile)

  try:
    from latex_access import nemeth, ueb, preprocessor, settings
  except ImportError:
    missingPackage(packageName)

  for configurationFile in programArguments.configuration:
    if os.path.exists(configurationFile):
      if programArguments.verbose:
        putProgramMessage("configuration file: " + configurationFile)

      settings.loadSettings(configurationFile)
      break

  if programArguments.translator:
    settings.settings["brailletable"] = programArguments.translator

  brailleTranslator = settings.brailleTableToUse()
  textPreprocessor = preprocessor.preprocessor()

  settings.activateSettings(
    {
      "braille": brailleTranslator,
      "preprocessor": textPreprocessor
    }
  )

  while processRequest(): pass


Filemanager

Name Type Size Permission Actions
af.ctb File 1.83 KB 0644
am.ctb File 12.41 KB 0644
countries.cti File 6.37 KB 0644
de-basis.ctb File 6.05 KB 0644
de-kurzschrift-1998.ctb File 55.98 KB 0644
de-kurzschrift-2015.ctb File 56.59 KB 0644
de-kurzschrift-wort.cti File 13.05 KB 0644
de-kurzschrift.ctb File 864 B 0644
de-vollschrift.ctb File 3.38 KB 0644
en-ueb-g2.ctb File 7.14 KB 0644
en-us-g2.ctb File 41.11 KB 0644
es.ctb File 7.49 KB 0644
fr-abrege.ctb File 48.18 KB 0644
fr-integral.ctb File 3.75 KB 0644
ha.ctb File 1.32 KB 0644
id.ctb File 1.41 KB 0644
ipa.ctb File 16.19 KB 0644
ja.ctb File 8.25 KB 0644
ko-g1.ctb File 1.14 KB 0644
ko-g2.ctb File 1.08 KB 0644
ko.ctb File 266.9 KB 0644
latex-access.ctb File 6.08 KB 0755
letters-latin.cti File 2.86 KB 0644
lt.ctb File 5.86 KB 0644
mg.ctb File 1.22 KB 0644
mun.ctb File 1.24 KB 0644
nabcc.cti File 2.13 KB 0644
nl.ctb File 1.26 KB 0644
ny.ctb File 1.23 KB 0644
pt.ctb File 10.07 KB 0644
si.ctb File 3.6 KB 0644
spaces.cti File 1.25 KB 0644
sw.ctb File 1.46 KB 0644
th.ctb File 4.45 KB 0644
zh-tw-ucb.ctb File 391.11 KB 0644
zh-tw.ctb File 699.34 KB 0644
zu.ctb File 1.25 KB 0644