From 4c63cdcd6092cfd2e20fe5a26c4117eccaa550dc Mon Sep 17 00:00:00 2001 From: moculus Date: Fri, 10 Apr 2009 05:29:44 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- mode/awk.py | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/mode/awk.py b/mode/awk.py index de0debd..229fd87 100644 --- a/mode/awk.py +++ b/mode/awk.py @@ -53,18 +53,15 @@ class AwkGrammar(Grammar): class AwkTabber(StackTabber2): open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} - control_tokens = { - 'awk.keyword': set(['if', 'else', 'while', 'do', 'for']) - } - end_at_eof = True - end_at_tokens = {} + control_tokens = {'awk.keyword': set(['if', 'else', 'while', 'do', 'for'])} + end_at_eof = True + end_at_tokens = {} def _is_base(self, y): if y == 0: return True t = self._get_tokens(y)[0] if t.fqisa('awk.regex.start'): return True if t.isa('awk.field', 'awk.global'): return True if t.matchs('awk.keyword', ('BEGIN', 'END')): return True - return False def _is_indent(self, t): return t.isa('spaces') def _is_ignored(self, t): return t.isa('spaces', 'eol', 'comment') @@ -72,17 +69,17 @@ class AwkTabber(StackTabber2): class AwkFilterFile(Exec): '''Filter a file through the current buffer's AWK program''' show_success = True - args = [arg('path', dt="path", p="Filter File: ", dv=default.path_dirname, - ld=True, h="file to open")] + args = [arg('path', dt='path', p='Filter File: ', dv=default.path_dirname, + ld=True, h='file to open')] def _execute(self, w, **vargs): if not hasattr(w.buffer, 'path'): - w.set_error("Buffer %r has no program" % w.buffer.name()) + w.set_error('Buffer %r has no program' % w.buffer.name()) return elif w.buffer.changed(): - w.set_error("Buffer %r is not saved" % w.buffer.name()) + w.set_error('Buffer %r is not saved' % w.buffer.name()) return elif not os.path.exists(vargs['path']): - w.set_error("File %r not found" % vargs['path']) + w.set_error('File %r not found' % vargs['path']) return cmd = 'awk -f %r %r' % (w.buffer.path, vargs['path']) @@ -90,20 +87,21 @@ class AwkFilterFile(Exec): outdata = pipe.stdout.read() status = pipe.wait() >> 8 w.application.data_buffer('*Awk-Output*', outdata, switch_to=True) - w.set_error("awk exited with status %d" % status) + w.set_error('awk exited with status %d' % status) class AwkFilterBuffer(Pipe): '''Filter a buffer through the current buffer's AWK program''' - args = [arg('name', dt="buffer", p="Filter Buffer: ", h="name of the buffer to switch to")] + args = [arg('name', dt='buffer', p='Filter Buffer: ', + h='name of the buffer to switch to')] def _execute(self, w, **vargs): if not hasattr(w.buffer, 'path'): - w.set_error("Buffer %r has no program" % w.buffer.name()) + w.set_error('Buffer %r has no program' % w.buffer.name()) return elif w.buffer.changed(): - w.set_error("Buffer %r is not saved" % w.buffer.name()) + w.set_error('Buffer %r is not saved' % w.buffer.name()) return elif not w.application.has_buffer_name(vargs['name']): - w.set_error("Buffer %r not found" % vargs['name']) + w.set_error('Buffer %r not found' % vargs['name']) return b = w.application.bufferlist.get_buffer_by_name(vargs['name']) @@ -115,17 +113,17 @@ class AwkFilterBuffer(Pipe): output = pipe.stdout.read() status = pipe.wait() >> 8 w.application.data_buffer('*Awk-Output*', output, switch_to=True) - w.set_error("awk exited with status %d" % status) + w.set_error('awk exited with status %d' % status) class AwkFilterInput(Method): '''Filter input through the current buffer's AWK program''' - args = [arg('input', p="Data To Filter: ", h="data to filter")] + args = [arg('input', p='Data To Filter: ', h='data to filter')] def _execute(self, w, **vargs): if not hasattr(w.buffer, 'path'): - w.set_error("Buffer %r has no program" % w.buffer.name()) + w.set_error('Buffer %r has no program' % w.buffer.name()) return elif w.buffer.changed(): - w.set_error("Buffer %r is not saved" % w.buffer.name()) + w.set_error('Buffer %r is not saved' % w.buffer.name()) return opts = w.application.config['awk.cmd-opts'] @@ -136,7 +134,7 @@ class AwkFilterInput(Method): output = pipe.stdout.read() status = pipe.wait() >> 8 w.application.data_buffer('*Awk-Output*', output, switch_to=True) - w.set_error("awk exited with status %d" % status) + w.set_error('awk exited with status %d' % status) class Awk(Fundamental): name = 'awk' @@ -147,7 +145,7 @@ class Awk(Fundamental): opentags = {'(': ')', '[': ']', '{': '}'} closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} - config = {'awk.cmd-opts': ""} + config = {'awk.cmd-opts': ''} actions = [AwkFilterFile, AwkFilterBuffer, AwkFilterInput] colors = { 'awk.global': ('yellow', 'default', 'bold'),