From 8caad15188ecbf61405f6b49a5be4a5710110db2 Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Tue, 8 Dec 2015 17:39:35 -0500 Subject: [PATCH] Remove This Awful Code --- common/lib/symmath/symmath/formula.py | 170 ++------------------------ 1 file changed, 8 insertions(+), 162 deletions(-) diff --git a/common/lib/symmath/symmath/formula.py b/common/lib/symmath/symmath/formula.py index 79c4797076..1dbabbb3b8 100644 --- a/common/lib/symmath/symmath/formula.py +++ b/common/lib/symmath/symmath/formula.py @@ -600,21 +600,16 @@ class formula(object): """ Handle requests to snuggletex API to convert the Ascii math to MathML """ - # url = 'http://192.168.1.2:8080/snuggletex-webapp-1.2.2/ASCIIMathMLUpConversionDemo' - # url = 'http://127.0.0.1:8080/snuggletex-webapp-1.2.2/ASCIIMathMLUpConversionDemo' url = 'https://math-xserver.mitx.mit.edu/snuggletex-webapp-1.2.2/ASCIIMathMLUpConversionDemo' - if 1: - payload = { - 'asciiMathInput': asciimath, - 'asciiMathML': mathml, - #'asciiMathML':unicode(mathml).encode('utf-8'), - } - headers = {'User-Agent': "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"} - request = requests.post(url, data=payload, headers=headers, verify=False) - request.encoding = 'utf-8' - ret = request.text - # print "encoding: ", request.encoding + payload = { + 'asciiMathInput': asciimath, + 'asciiMathML': mathml, + } + headers = {'User-Agent': "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"} + request = requests.post(url, data=payload, headers=headers, verify=False) + request.encoding = 'utf-8' + ret = request.text mode = 0 cmathml = [] @@ -629,153 +624,4 @@ class formula(object): cmathml.append(k) cmathml = '\n'.join(cmathml[2:]) cmathml = '\n' + unescape(cmathml) + '\n' - # print cmathml return cmathml - -#----------------------------------------------------------------------------- - - -def test1(): - """Test XML strings - addition""" - xmlstr = """ - - - - 1 - 2 - - - """ - return formula(xmlstr) - - -def test2(): - """Test XML strings - addition, Greek alpha""" - xmlstr = u""" - - - - 1 - - - 2 - α - - - - """ - return formula(xmlstr) - - -def test3(): - """Test XML strings - addition, Greek gamma""" - xmlstr = """ - - - - 1 - - - 2 - γ - - - - """ - return formula(xmlstr) - - -def test4(): - """Test XML strings - addition, Greek alpha, mfrac""" - xmlstr = u""" - - - 1 - + - - 2 - α - - - -""" - return formula(xmlstr) - - -def test5(): - """Test XML strings - sum of two matrices""" - xmlstr = u""" - - - - cos - - ( - θ - ) - - - - - [ - - - - 1 - - - 0 - - - - - 0 - - - 1 - - - - ] - - + - - [ - - - - 0 - - - 1 - - - - - 1 - - - 0 - - - - ] - - - -""" - return formula(xmlstr) - - -def test6(): - """Test XML strings - imaginary numbers""" - xmlstr = u""" - - - 1 - + - i - - -""" - return formula(xmlstr, options='imaginary')