From cbacde9378cd33698ffa6a15aa9f33ed5f7b0016 Mon Sep 17 00:00:00 2001 From: Tim Vieira Date: Fri, 28 Jun 2013 10:39:24 -0400 Subject: [PATCH] yet another fix to ./debug --- src/Dyna/Backend/Python/config.py | 2 +- src/Dyna/Backend/Python/debug.py | 63 ++++++++++++------------------- 2 files changed, 26 insertions(+), 39 deletions(-) diff --git a/src/Dyna/Backend/Python/config.py b/src/Dyna/Backend/Python/config.py index a504281..7b67212 100644 --- a/src/Dyna/Backend/Python/config.py +++ b/src/Dyna/Backend/Python/config.py @@ -5,4 +5,4 @@ dotdynadir = path('~/.dyna').expand() if not dotdynadir.exists(): dotdynadir.mkdir() -dynahome = os.getenv('DYNAHOME', '.') +dynahome = path(os.getenv('DYNAHOME', '.')) diff --git a/src/Dyna/Backend/Python/debug.py b/src/Dyna/Backend/Python/debug.py index e42d132..f74f50a 100644 --- a/src/Dyna/Backend/Python/debug.py +++ b/src/Dyna/Backend/Python/debug.py @@ -6,7 +6,6 @@ normalization process. import re, os, shutil, webbrowser from collections import defaultdict, namedtuple -from cStringIO import StringIO from utils import magenta, red, green, yellow, white, read_anf from config import dynahome @@ -14,8 +13,8 @@ from pygments import highlight from pygments.lexers import get_lexer_by_name from pygments.formatters import HtmlFormatter -cssfile="%s/src/Dyna/Backend/Python/debug-pygments.css" % dynahome -jsfile="%s/external/prototype-1.6.0.3.js" % dynahome +cssfile = dynahome / 'src' / 'Dyna' / 'Backend' / 'Python' / 'debug-pygments.css' +jsfile = dynahome / 'external' / 'prototype-1.6.0.3.js' Edge = namedtuple('Edge', 'head label body') # "body" is sometimes called the "tail" @@ -101,13 +100,9 @@ class Hypergraph(object): print >> f, '}' -# print 'wrote', dot, 'compiling...' - # run graphviz to produce image assert 0 == os.system('(dot -Tsvg %s > %s)' % (dot, svg)), 'graphviz failed.' -# print 'created', svg - with file(svg) as f: return f.read() @@ -259,6 +254,9 @@ body { background: black; color: white; } ' @@ -328,39 +334,20 @@ function selectline(lineno) { # find "update plans" -- every term (edge) in a rule must have code to # handle an update to it's value. + # ------------- + # Dopamine code with file(d + '/dopupd') as f: code = f.read() - print >> html, '

Update plans

' - - for (f,bline,bcol,eline,ecol,kv,block) in \ - re.findall(';; (.*?):(\d+):(\d+)-.*?:(\d+):(\d+) (.*)\n((?: [^\n]*\n)*)' - , code) : - + for (f, bline, _bcol, _eline, _ecol, kv, block) in re.findall(';; (.*?):(\d+):(\d+)-.*?:(\d+):(\d+) (.*)\n((?: [^\n]*\n)*)', code): # [fa] = re.findall('fa=([^ ]*)', kv) - - print >> html, """\ -
-
-Update %s
-%s
-
-
-""" % (bline, kv, block) - - - # ------------- - # Dopamine code + print >> html, """
Update %s\n%s
""" % (bline, kv, block) with file(d + '/dopini') as f: code = f.read() - print >> html, '

Initialization plans

' - - for (f,bline,bcol,eline,ecol,kv,block) in \ - re.findall(';; (.*?):(\d+):(\d+)-.*?:(\d+):(\d+) (.*)\n((?: [^\n]*\n)*)', code): + for (f, bline, _bcol, _eline, _ecol, kv, block) in re.findall(';; (.*?):(\d+):(\d+)-.*?:(\d+):(\d+) (.*)\n((?: [^\n]*\n)*)', code): print >> html, """
Initializer:\n%s
""" % (bline, block) - # ---------------- # Python code with file(d + '/plan') as f: -- 2.50.1