コード例 #1
0
def compile_help (text):
    cmd = 'help(%s)' % text
    out = {"help" : "", "src": "", "file": ""}

    try:
        out["help"] = CaptureStdout.capture (cmd, my_globals, "tm_python");
    except Exception as e:
        out ["help"] = 'No help for "%s": %s' % (text, e)

    try:
        out["src"] = eval ('getsource(%s)' % text,
                           my_globals, {'getsource' : getsource})
    except Exception as e:
        out["src"] = 'No code available for "%s": %s' % (text, e)

    try:
        # Todo: strip docstring from code
        out["file"] = eval ('getsourcefile(%s)' % text,
                            my_globals, {'getsourcefile' : getsourcefile})
    except Exception as e:
        out["file"] = 'Unable to access the code for "%s": %s' % (text, e)

    return dict (map (lambda k_v: (k_v[0], as_scm_string (k_v[1])), out.items()))
コード例 #2
0
ファイル: tm_eukleides.py プロジェクト: timy/texmacs
                continue
            else:
                lines = []
                for x in line.split('~'):
                    lines.append(x)
                while line != "<EOF>":
                    line = tm_input()
                    for x in line.split('~'):
                        lines.append(x)
                text = '\n'.join(lines[:-1])
                self.eval(text)


if (exists(tmpy_home_path)):
    flush_verbatim("WARNING: You are under develop mode using " +
                   tmpy_home_path)
    flush_newline(2)

my_globals = {}

text = 'import builtins as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_eukleides")

current = Eukleides()
if not current.available():
    flush_err("Failed to launch the Eukleides plugin, aborted!!!")
    exit(-1)

current.greet()
current.main_loop()
コード例 #3
0
ファイル: tm_xypic.py プロジェクト: happyChenXu/plugins
## COPYRIGHT   : (C) 2019  Darcy Shen
##
## This software falls under the GNU general public license version 3 or later.
## It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
## in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.

import os
import sys
from os.path import exists
tmpy_home_path = os.environ.get("TEXMACS_HOME_PATH") + "/plugins/tmpy"
if (exists (tmpy_home_path)):
    sys.path.append(os.environ.get("TEXMACS_HOME_PATH") + "/plugins/")
else:
    sys.path.append(os.environ.get("TEXMACS_PATH") + "/plugins/")

from tmpy.graph.xypic     import XYpic
from tmpy.capture         import CaptureStdout
from tmpy.compat          import py_ver

my_globals   = {}

if py_ver == 3:
    text = 'import builtins as __builtins__'
else:
    text = 'import __builtin__ as __builtins__'
CaptureStdout.capture (text, my_globals, "tm_xypic")

current = XYpic()
current.greet()
current.main_loop()
コード例 #4
0
###############################################################################
if (exists (tmpy_home_path)):
    flush_verbatim ("WARNING: You are under develop mode using " + tmpy_home_path)
    flush_newline (2)
flush_verbatim ("SymPy %s under Python %s\n" % (sympy.__version__, platform.python_version()))
flush_verbatim ("Please see the documentation in Help -> Plugins -> SymPy\n")
flush_prompt (">>> ")

while True:
    line= tm_input ()
    if not line:
        continue
    if line[0] == DATA_COMMAND:
        sf = parse_complete_command (line[1:])
        if sf[0] == 'complete':
            flush_scheme (complete (sf[1], sf[2], my_globals))
        continue

    lines = [line]
    while line != "<EOF>":
        line = tm_input()
        if line == '': 
            continue
        lines.append(line)
    text = '\n'.join(lines[:-1])
    try: # Is it an expression?
        result = eval(text, my_globals)
    except:
        result = CaptureStdout.capture(text, my_globals, "tm_sympy")
    flush_output (result)
コード例 #5
0
ファイル: tm_graph.py プロジェクト: happyChenXu/plugins
    return 'verbatim:%s' % str(data).strip()


def as_scm_string(text):
    return '"%s"' % text.replace('\\', '\\\\').replace('"', '\\"')


###############################################################################
## Session start
###############################################################################

if py_ver == 3:
    text = 'import builtins as __builtins__'
else:
    text = 'import __builtin__ as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_graph")

# Reopen stdout unbufferd (flush after each stdout.write() and print)
if py_ver == 3:
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w')
else:
    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

grapvizs = list(
    map(lambda x: Graphviz(x), [
        "dot", "neato", "twopi", "circo", "fdp", "sfdp", "patchwork", "osage"
    ]))
others = [
    Asymptote(),
    PlantUML(),
    Mermaid(),
コード例 #6
0
__version__ = '3.0'
__author__ = 'Ero Carrera, Adrian Soto, Miguel de Benito Delgado, Darcy Shen'
my_globals   = {}

# We insert into the session's namespace the 'ps_out' method.
my_globals['ps_out'] = ps_out

# As well as some documentation.
my_globals['__doc__'] = """A Python plugin for TeXmacs.
Provides autocompletion and embedding of PostScript data into the document,
e.g from files or from matplotlib.pyplot.
A rudimentary help window is also implemented: type the name of an object
with a question mark at the end to use it."""

text = 'import builtins as __builtins__'
CaptureStdout.capture (text, my_globals, "tm_python")

sys.stdout = os.fdopen (sys.stdout.fileno(), 'w')

###############################################################################
# Session start
###############################################################################
if (exists (tmpy_home_path)):
    flush_verbatim ("WARNING: You are under develop mode using " + tmpy_home_path)
    flush_newline (2)
flush_verbatim ("Python " + sys.version + "\n" +
               "Python plugin for TeXmacs.\n" +
               "Please see the documentation in Help -> Plugins -> Python")
flush_prompt (">>> ")
while True:
    line= input ()
コード例 #7
0
import os
import sys
from os.path import exists
tmpy_home_path = os.environ.get("TEXMACS_HOME_PATH") + "/plugins/tmpy"
if (exists(tmpy_home_path)):
    sys.path.append(os.environ.get("TEXMACS_HOME_PATH") + "/plugins/")
else:
    sys.path.append(os.environ.get("TEXMACS_PATH") + "/plugins/")

from tmpy.graph.tikz import TikZ
from tmpy.capture import CaptureStdout
from tmpy.protocol import *

if (exists(tmpy_home_path)):
    flush_verbatim("WARNING: You are under develop mode using " +
                   tmpy_home_path)
    flush_newline(2)

my_globals = {}

text = 'import builtins as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_tikz")

current = TikZ()
if not current.available():
    flush_err("Failed to launch the TikZ plugin, aborted!!!")
    exit(-1)
current.greet()
current.main_loop()
コード例 #8
0
ファイル: tm_gnuplot.py プロジェクト: dbv771/Xmacs
import os
import sys
from os.path import exists
tmpy_home_path = os.environ.get("TEXMACS_HOME_PATH") + "/plugins/tmpy"
if (exists(tmpy_home_path)):
    sys.path.append(os.environ.get("TEXMACS_HOME_PATH") + "/plugins/")
else:
    sys.path.append(os.environ.get("TEXMACS_PATH") + "/plugins/")

from tmpy.protocol import *
from tmpy.graph.gnuplot import Gnuplot
from tmpy.capture import CaptureStdout
from tmpy.compat import *

if (exists(tmpy_home_path)):
    flush_verbatim("WARNING: You are under develop mode using " +
                   tmpy_home_path)
    flush_newline(2)

my_globals = {}

if py_ver == 3:
    text = 'import builtins as __builtins__'
else:
    text = 'import __builtin__ as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_gnuplot")

current = Gnuplot()
current.greet()
current.main_loop()
コード例 #9
0
###############################################################################
##
## MODULE      : tm_gnuplot.py
## DESCRIPTION : Launcher for the Gnuplot plugin
## COPYRIGHT   : (C) 2019  Darcy Shen
##
## This software falls under the GNU general public license version 3 or later.
## It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
## in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.

import os
import sys
sys.path.append(os.environ.get("TEXMACS_PATH") + "/plugins/")

from tmpy.protocol import *
from tmpy.graph.asymptote import Asymptote
from tmpy.capture import CaptureStdout
from tmpy.compat import *

my_globals = {}

if py_ver == 3:
    text = 'import builtins as __builtins__'
else:
    text = 'import __builtin__ as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_asy")

current = Asymptote()
current.greet()
current.main_loop()
コード例 #10
0
import os
import sys
from os.path import exists
tmpy_home_path = os.environ.get("TEXMACS_HOME_PATH") + "/plugins/tmpy"
if (exists(tmpy_home_path)):
    sys.path.append(os.environ.get("TEXMACS_HOME_PATH") + "/plugins/")
else:
    sys.path.append(os.environ.get("TEXMACS_PATH") + "/plugins/")

from tmpy.graph.dratex import DraTeX
from tmpy.capture import CaptureStdout
from tmpy.compat import py_ver
from tmpy.protocol import *

if (exists(tmpy_home_path)):
    flush_verbatim("WARNING: You are under develop mode using " +
                   tmpy_home_path)
    flush_newline(2)

my_globals = {}

if py_ver == 3:
    text = 'import builtins as __builtins__'
else:
    text = 'import __builtin__ as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_dratex")

current = DraTeX()
current.greet()
current.main_loop()
コード例 #11
0
my_globals['__doc__'] = """A SageMath plugin for TeXmacs.

  TeXmacs SAGE interface v0.8.1.

  Based on the TeXmacs Python plugin by Ero Carrera (c) 2004
  
  The version distributed with TeXmacs is always the latest.

  Enjoy it!
  """

if py_ver > 3:
    text = 'import builtins as __builtins__'
else:
    text = 'import __builtin__ as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_sage")

sys.stdout = os.fdopen(sys.stdout.fileno(), 'w')

co = compile('from sage.all import *', 'tm_sage', 'exec')
eval(co, my_globals)
co = compile('from sage.calculus.predefined import x', 'tm_sage', 'exec')
eval(co, my_globals)

###############################################################################
# Session start
###############################################################################
if (os.path.exists(tmpy_home_path)):
    flush_verbatim("WARNING: You are under develop mode using " +
                   tmpy_home_path)
    flush_newline(2)
コード例 #12
0
ファイル: tm_quiver.py プロジェクト: XmacsLabs/quiver
        code = self.strip_comments(code)
        code = code.lstrip(' ').rstrip(' ')
        code = code.lstrip('\n').rstrip('\n')
        code = removeprefix(code, "\\[")
        code = removesuffix(code, "\\]")
        code = self.pre_code + "\n" + code + "\n" + self.post_code
        super(Quiver, self).evaluate(code)

    # For Debugging
    # def after_evaluate(self):
    #    self.remove_tmp_dir()


if (exists (tmpy_home_path)):
        flush_verbatim ("WARNING: You are under develop mode using " + tmpy_home_path)
        flush_newline (2)

my_globals   = {}

text = 'import builtins as __builtins__'
CaptureStdout.capture (text, my_globals, "tm_quiver")

current = Quiver()
if not current.available():
    flush_err ("Failed to launch the Quiver plugin, aborted!!!")
    exit(-1)

current.greet()
current.main_loop()

コード例 #13
0
import sys
from os.path import exists

tmpy_home_path = os.environ.get("TEXMACS_HOME_PATH") + "/plugins/tmpy"
if (exists(tmpy_home_path)):
    sys.path.append(os.environ.get("TEXMACS_HOME_PATH") + "/plugins/")
else:
    sys.path.append(os.environ.get("TEXMACS_PATH") + "/plugins/")

from tmpy.graph.plantuml import PlantUML
from tmpy.capture import CaptureStdout
from tmpy.protocol import *
from tmpy.compat import *

if (exists(tmpy_home_path)):
    flush_verbatim("WARNING: You are under develop mode using " +
                   tmpy_home_path)
    flush_newline(2)

my_globals = {}

if py_ver == 3:
    text = 'import builtins as __builtins__'
else:
    text = 'import __builtin__ as __builtins__'
CaptureStdout.capture(text, my_globals, "tm_plantuml")

current = PlantUML()
current.greet()
current.main_loop()