Skip to content

Commit 1b5488a

Browse files
authored
Merge pull request #13 from Mathics3/mathics-scanner-import
Mathics scanner import
2 parents d51e95e + 80dd73f commit 1b5488a

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

mathicsscript/__main__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from mathicsscript.format import format_output
1414

15-
from mathics import replace_wl_with_unicode
1615
from mathics.core.parser import FileLineFeeder
1716
from mathics.core.definitions import Definitions
1817
from mathics.core.expression import Symbol, SymbolTrue, SymbolFalse
@@ -21,6 +20,8 @@
2120
from mathics import version_string, license_string
2221
from mathics import settings
2322

23+
from mathics_scanner.characters import replace_wl_with_plain_text
24+
2425
from pygments import highlight
2526
from pygments.lexers import MathematicaLexer
2627

@@ -327,7 +328,7 @@ def main(
327328
current_pos = GNU_readline.get_current_history_length()
328329
for pos in range(last_pos, current_pos - 1):
329330
GNU_readline.remove_history_item(pos)
330-
wl_input = replace_wl_with_unicode(source_code.rstrip())
331+
wl_input = replace_wl_with_plain_text(source_code.rstrip(), use_unicode=unicode)
331332
GNU_readline.add_history(wl_input)
332333

333334
if query is None:
@@ -344,7 +345,7 @@ def main(
344345
query, timeout=settings.TIMEOUT, format="unformatted"
345346
)
346347
if result is not None:
347-
shell.print_result(result, output_style)
348+
shell.print_result(result, output_style, use_unicode=unicode)
348349

349350
except ShellEscapeException as e:
350351
source_code = e.line

mathicsscript/format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def format_output(obj, expr, format=None):
1212
format = obj.format
1313

1414
if isinstance(format, dict):
15-
return dict((k, obj.format_output(expr, f)) for k, f in format.items())
15+
return {k: obj.format_output(expr, f) for k, f in format.items()}
1616

1717
from mathics.core.expression import Expression, BoxError
1818

mathicsscript/termshell.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
import sys
1010
import re
1111
from columnize import columnize
12-
from mathics import replace_unicode_with_wl
1312
from mathics.core.expression import Expression, String, Symbol
1413
from mathics.core.expression import strip_context, from_python
1514
from mathics.core.rules import Rule
16-
from mathics.core.characters import named_characters
15+
from mathics_scanner.characters import (
16+
named_characters,
17+
replace_unicode_with_wl,
18+
replace_wl_with_plain_text,
19+
)
1720

1821
from pygments import highlight, lex
1922
from mathicsscript.mmalexer import MathematicaLexer
@@ -253,7 +256,7 @@ def read_line(self, prompt):
253256
raise ShellEscapeException(line)
254257
return replace_unicode_with_wl(line)
255258

256-
def print_result(self, result, output_style=""):
259+
def print_result(self, result, output_style="", use_unicode=True):
257260
if result is None:
258261
# FIXME decide what to do here
259262
return
@@ -267,7 +270,9 @@ def print_result(self, result, output_style=""):
267270
print(sys.exc_info()[1])
268271
return
269272

270-
out_str = str(result.result)
273+
out_str = replace_wl_with_plain_text(str(result.result),
274+
use_unicode=use_unicode)
275+
271276
if eval_type == "System`Graph":
272277
out_str = "-Graph-"
273278
elif self.terminal_formatter: # pygmentize

setup.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717
import os.path as osp
1818
from setuptools import find_packages
1919

20+
INSTALL_REQUIRES = [
21+
"Mathics-Scanner>=1.0.0dev",
22+
"Mathics3 >= 2.0.0dev",
23+
"click",
24+
"colorama",
25+
"columnize",
26+
"networkx",
27+
"pygments",
28+
"term-background >= 1.0.1",
29+
]
30+
31+
DEPENDENCY_LINKS = [
32+
'http://github.com/Mathics3/mathics-scanner/tarball/master#egg=Mathics-Scanner-1.0.0dev'
33+
]
2034

2135
def get_srcdir():
2236
filename = osp.normcase(osp.dirname(osp.abspath(__file__)))
@@ -66,15 +80,8 @@ def read(*rnames):
6680
package_data={
6781
"": ["inputrc", "inputrc-no-unicode", "inputrc-unicode", "settings/settings.m"]
6882
},
69-
install_requires=[
70-
"Mathics3 >= 2.0.0dev",
71-
"click",
72-
"colorama",
73-
"columnize",
74-
"networkx",
75-
"pygments",
76-
"term-background >= 1.0.1",
77-
],
83+
install_requires=INSTALL_REQUIRES,
84+
dependency_links=DEPENDENCY_LINKS,
7885
entry_points={"console_scripts": ["mathicsscript = mathicsscript.__main__:main"]},
7986
long_description=long_description,
8087
long_description_content_type="text/x-rst",

0 commit comments

Comments
 (0)