Compare commits

..

1 Commits

Author SHA1 Message Date
Bryan Petty
50c4c97be9 This commit was manufactured by cvs2svn to create tag 'WITH_OGL'.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/WITH_OGL@6390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2000-03-01 23:37:09 +00:00
13 changed files with 21178 additions and 12176 deletions

14067
configure vendored Executable file

File diff suppressed because it is too large Load Diff

3602
configure.in Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,84 @@
#!#############################################################################
#! File: filelist.t
#! Purpose: tmake template file containig Perl code to parse the filelist.txt
#! file - this is used by all other templates.
#! Author: Vadim Zeitlin
#! Created: 14.07.99
#! Version: $Id$
#!#############################################################################
#${
open(FILELIST, "filelist.txt") or die "Can't open filelist file: $!\n";
line: while ( defined($_ = <FILELIST>) ) {
chomp;
#! comment or blank line, skip
next line if ( $_ eq "" or /^#/ );
#! if ( $verbose ) {
#! print STDERR "Processing line: '$_'\n";
#! }
my @fields = split "\t";
if ( $#fields > 2 ) {
warn "Ignoring malformed line $_ in the filelist file.\n";
next line;
} elsif ( $#fields == 1 ) {
#! add an empty flags string
$fields[2] = "";
}
if ( $verbose ) {
print STDERR "File $fields[0]: type '$fields[1]', flags '$fields[2]'\n";
}
#! first column is filename, second is type, third is flags
if ( $fields[1] eq "C" ) {
$wxCommon{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "G" ) {
$wxGeneric{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "M" ) {
$wxMSW{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "X" ) {
$wxMOTIF{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "R" ) {
$wxGTK{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "O" ) {
$wxOS2PM{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "H" ) {
$wxHTML{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "J" ) {
$wxOGL{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "U" ) {
$wxUNIX{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "B" ) {
$wxBase{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "W" ) {
$wxWXINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "P" ) {
$wxPROTOCOLINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "L" ) {
$wxHTMLINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "Z" ) {
$wxOGLINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "F" ) {
$wxMOTIFINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "9" ) {
$wxMSWINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "K" ) {
$wxGTKINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "2" ) {
$wxOS2PMINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "S" ) {
$wxUNIXINCLUDE{$fields[0]} = $fields[2];
} elsif ( $fields[1] eq "N" ) {
$wxGENERICINCLUDE{$fields[0]} = $fields[2];
} else {
warn "Unknown file type $fields[1] for $fields[0], ignoring.\n";
next line;
}
}
close(FILELIST);
#$}
#! vim:sw=4:ts=4:list:et

File diff suppressed because it is too large Load Diff

149
distrib/msw/tmake/gtk.t Normal file
View File

@@ -0,0 +1,149 @@
#!################################################################################
#! File: gtk.t
#! Purpose: tmake template file from which src/gtk/files.lst containing the
#! list of files for wxGTK library is generated by tmake
#! Author: Vadim Zeitlin
#! Created: 28.01.00
#! Version: $Id$
#!################################################################################
#${
#! include the code which parses filelist.txt file and initializes
#! %wxCommon, %wxGeneric, %wxHtml, %wxUNIX, %wxGTK, %wxMOTIF and
#! %wxOS2PM hashes.
IncludeTemplate("filelist.t");
#! find all our sources
$project{"COMMONOBJS"} .= "parser.o ";
$project{"COMMONDEPS"} .= "parser.d ";
foreach $file (sort keys %wxGeneric) {
next if $wxGeneric{$file} =~ /\bR\b/;
($fileobj = $file) =~ s/cp?p?$/\o/;
($filedep = $file) =~ s/cp?p?$/\d/;
$project{"GTK_SOURCES"} .= "generic/" . $file . " ";
$project{"GENERICOBJS"} .= $fileobj . " ";
$project{"GENERICDEPS"} .= $filedep . " "
}
foreach $file (sort keys %wxCommon) {
next if $wxCommon{$file} =~ /\bR\b/;
($fileobj = $file) =~ s/cp?p?$/\o/;
($filedep = $file) =~ s/cp?p?$/\d/;
$project{"GTK_SOURCES"} .= "common/" . $file . " ";
$project{"COMMONOBJS"} .= $fileobj . " ";
$project{"COMMONDEPS"} .= $filedep . " "
}
foreach $file (sort keys %wxGTK) {
($fileobj = $file) =~ s/cp?p?$/\o/;
($filedep = $file) =~ s/cp?p?$/\d/;
$project{"GTK_SOURCES"} .= "gtk/" . $file . " ";
$project{"GUIOBJS"} .= $fileobj . " ";
$project{"GUIDEPS"} .= $filedep . " "
}
foreach $file (sort keys %wxUNIX) {
($fileobj = $file) =~ s/cp?p?$/\o/;
($filedep = $file) =~ s/cp?p?$/\d/;
$project{"GTK_SOURCES"} .= "unix/" . $file . " ";
$project{"UNIXOBJS"} .= $fileobj . " ";
$project{"UNIXDEPS"} .= $filedep . " "
}
foreach $file (sort keys %wxHTML) {
($fileobj = $file) =~ s/cp?p?$/\o/;
($filedep = $file) =~ s/cp?p?$/\d/;
$project{"GTK_SOURCES"} .= "html/" . $file . " ";
$project{"HTMLOBJS"} .= $fileobj . " ";
$project{"HTMLDEPS"} .= $filedep . " "
}
foreach $file (sort keys %wxOGL) {
($fileobj = $file) =~ s/cp?p?$/\o/;
($filedep = $file) =~ s/cp?p?$/\d/;
$project{"GTK_SOURCES"} .= "ogl/" . $file . " ";
$project{"OGLOBJS"} .= $fileobj . " ";
$project{"OGLDEPS"} .= $filedep . " "
}
#! find all our headers
foreach $file (sort keys %wxWXINCLUDE) {
$project{"GTK_HEADERS"} .= $file . " "
}
foreach $file (sort keys %wxGTKINCLUDE) {
$project{"GTK_HEADERS"} .= "gtk/" . $file . " "
}
foreach $file (sort keys %wxGENERICINCLUDE) {
$project{"GTK_HEADERS"} .= "generic/" . $file . " "
}
foreach $file (sort keys %wxUNIXINCLUDE) {
$project{"GTK_HEADERS"} .= "unix/" . $file . " "
}
foreach $file (sort keys %wxHTMLINCLUDE) {
$project{"GTK_HEADERS"} .= "html/" . $file . " "
}
foreach $file (sort keys %wxOGLINCLUDE) {
$project{"GTK_HEADERS"} .= "ogl/" . $file . " "
}
foreach $file (sort keys %wxPROTOCOLINCLUDE) {
$project{"GTK_HEADERS"} .= "protocol/" . $file . " "
}
#$}
# This file was automatically generated by tmake at #$ Now()
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T!
ALL_SOURCES = \
#$ ExpandList("GTK_SOURCES");
ALL_HEADERS = \
#$ ExpandList("GTK_HEADERS");
COMMONOBJS = \
#$ ExpandList("COMMONOBJS");
COMMONDEPS = \
#$ ExpandList("COMMONDEPS");
GENERICOBJS = \
#$ ExpandList("GENERICOBJS");
GENERICDEPS = \
#$ ExpandList("GENERICDEPS");
GUIOBJS = \
#$ ExpandList("GUIOBJS");
GUIDEPS = \
#$ ExpandList("GUIDEPS");
UNIXOBJS = \
#$ ExpandList("UNIXOBJS");
UNIXDEPS = \
#$ ExpandList("UNIXDEPS");
HTMLOBJS = \
#$ ExpandList("HTMLOBJS");
HTMLDEPS = \
#$ ExpandList("HTMLDEPS");
OGLOBJS = \
#$ ExpandList("OGLOBJS");
OGLDEPS = \
#$ ExpandList("OGLDEPS");

1068
src/gtk/files.lst Normal file

File diff suppressed because it is too large Load Diff

1068
src/gtk1/files.lst Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,216 +0,0 @@
#!/usr/bin/env python
"""PyCrust is a python shell application.
"""
__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
__cvsid__ = "$Id$"
__date__ = "July 1, 2001"
__version__ = "$Revision$"[11:-2]
from wxPython.wx import *
from version import VERSION
from shell import Shell
ID_AUTOCOMP = NewId()
ID_AUTOCOMP_SHOW = NewId()
ID_AUTOCOMP_INCLUDE_MAGIC = NewId()
ID_AUTOCOMP_INCLUDE_SINGLE = NewId()
ID_AUTOCOMP_INCLUDE_DOUBLE = NewId()
ID_CALLTIPS = NewId()
ID_CALLTIPS_SHOW = NewId()
class Frame(wxFrame):
"""Main window for the PyCrust application."""
def __init__(self, parent, id, title):
"""Create the main frame object for the application."""
wxFrame.__init__(self, parent, id, title)
intro = 'Welcome To PyCrust %s - The Flakiest Python Shell' % VERSION
self.CreateStatusBar()
self.SetStatusText(intro)
self.icon = wxIcon('PyCrust.ico', wxBITMAP_TYPE_ICO)
self.SetIcon(self.icon)
self.createMenus()
# Create the shell, which will create a default interpreter.
locals = {'__app__': 'PyCrust Application'}
self.shell = Shell(parent=self, id=-1, introText=intro, locals=locals)
# Override the shell so that status messages go to the status bar.
self.shell.setStatusText = self.SetStatusText
def createMenus(self):
m = self.fileMenu = wxMenu()
m.AppendSeparator()
m.Append(wxID_EXIT, 'E&xit', 'Exit PyCrust')
m = self.editMenu = wxMenu()
m.Append(wxID_UNDO, '&Undo \tCtrl+Z', 'Undo the last action')
m.Append(wxID_REDO, '&Redo \tCtrl+Y', 'Redo the last undone action')
m.AppendSeparator()
m.Append(wxID_CUT, 'Cu&t \tCtrl+X', 'Cut the selection')
m.Append(wxID_COPY, '&Copy \tCtrl+C', 'Copy the selection')
m.Append(wxID_PASTE, '&Paste \tCtrl+V', 'Paste')
m.AppendSeparator()
m.Append(wxID_CLEAR, 'Cle&ar \tDel', 'Delete the selection')
m.Append(wxID_SELECTALL, 'Select A&ll \tCtrl+A', 'Select all text')
m = self.autocompMenu = wxMenu()
m.Append(ID_AUTOCOMP_SHOW, 'Show Auto Completion', \
'Show auto completion during dot syntax', checkable=1)
m.Append(ID_AUTOCOMP_INCLUDE_MAGIC, 'Include Magic Attributes', \
'Include attributes visible to __getattr__ and __setattr__', checkable=1)
m.Append(ID_AUTOCOMP_INCLUDE_SINGLE, 'Include Single Underscores', \
'Include attibutes prefixed by a single underscore', checkable=1)
m.Append(ID_AUTOCOMP_INCLUDE_DOUBLE, 'Include Double Underscores', \
'Include attibutes prefixed by a double underscore', checkable=1)
m = self.calltipsMenu = wxMenu()
m.Append(ID_CALLTIPS_SHOW, 'Show Call Tips', \
'Show call tips with argument specifications', checkable=1)
m = self.optionsMenu = wxMenu()
m.AppendMenu(ID_AUTOCOMP, '&Auto Completion', self.autocompMenu, \
'Auto Completion Options')
m.AppendMenu(ID_CALLTIPS, '&Call Tips', self.calltipsMenu, \
'Call Tip Options')
m = self.helpMenu = wxMenu()
m.AppendSeparator()
m.Append(wxID_ABOUT, '&About...', 'About PyCrust')
b = self.menuBar = wxMenuBar()
b.Append(self.fileMenu, '&File')
b.Append(self.editMenu, '&Edit')
b.Append(self.optionsMenu, '&Options')
b.Append(self.helpMenu, '&Help')
self.SetMenuBar(b)
EVT_MENU(self, wxID_EXIT, self.OnExit)
EVT_MENU(self, wxID_UNDO, self.OnUndo)
EVT_MENU(self, wxID_REDO, self.OnRedo)
EVT_MENU(self, wxID_CUT, self.OnCut)
EVT_MENU(self, wxID_COPY, self.OnCopy)
EVT_MENU(self, wxID_PASTE, self.OnPaste)
EVT_MENU(self, wxID_CLEAR, self.OnClear)
EVT_MENU(self, wxID_SELECTALL, self.OnSelectAll)
EVT_MENU(self, wxID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_AUTOCOMP_SHOW, self.OnAutoCompleteShow)
EVT_MENU(self, ID_AUTOCOMP_INCLUDE_MAGIC, self.OnAutoCompleteIncludeMagic)
EVT_MENU(self, ID_AUTOCOMP_INCLUDE_SINGLE, self.OnAutoCompleteIncludeSingle)
EVT_MENU(self, ID_AUTOCOMP_INCLUDE_DOUBLE, self.OnAutoCompleteIncludeDouble)
EVT_MENU(self, ID_CALLTIPS_SHOW, self.OnCallTipsShow)
EVT_UPDATE_UI(self, wxID_UNDO, self.OnUpdateMenu)
EVT_UPDATE_UI(self, wxID_REDO, self.OnUpdateMenu)
EVT_UPDATE_UI(self, wxID_CUT, self.OnUpdateMenu)
EVT_UPDATE_UI(self, wxID_COPY, self.OnUpdateMenu)
EVT_UPDATE_UI(self, wxID_PASTE, self.OnUpdateMenu)
EVT_UPDATE_UI(self, wxID_CLEAR, self.OnUpdateMenu)
EVT_UPDATE_UI(self, ID_AUTOCOMP_SHOW, self.OnUpdateMenu)
EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_MAGIC, self.OnUpdateMenu)
EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_SINGLE, self.OnUpdateMenu)
EVT_UPDATE_UI(self, ID_AUTOCOMP_INCLUDE_DOUBLE, self.OnUpdateMenu)
EVT_UPDATE_UI(self, ID_CALLTIPS_SHOW, self.OnUpdateMenu)
def OnExit(self, event):
self.Close(true)
def OnUndo(self, event):
self.shell.Undo()
def OnRedo(self, event):
self.shell.Redo()
def OnCut(self, event):
self.shell.Cut()
def OnCopy(self, event):
self.shell.Copy()
def OnPaste(self, event):
self.shell.Paste()
def OnClear(self, event):
self.shell.Clear()
def OnSelectAll(self, event):
self.shell.SelectAll()
def OnAbout(self, event):
"""Display an About PyCrust window."""
title = 'About PyCrust'
text = 'PyCrust %s\n\n' % VERSION + \
'Yet another Python shell, only flakier.\n\n' + \
'Half-baked by Patrick K. O\'Brien,\n' + \
'the other half is still in the oven.\n\n' + \
'Shell Revision: %s\n' % self.shell.revision + \
'Interpreter Revision: %s\n' % self.shell.interp.revision
dialog = wxMessageDialog(self, text, title, wxOK | wxICON_INFORMATION)
dialog.ShowModal()
dialog.Destroy()
def OnAutoCompleteShow(self, event):
self.shell.autoComplete = event.IsChecked()
def OnAutoCompleteIncludeMagic(self, event):
self.shell.autoCompleteIncludeMagic = event.IsChecked()
def OnAutoCompleteIncludeSingle(self, event):
self.shell.autoCompleteIncludeSingle = event.IsChecked()
def OnAutoCompleteIncludeDouble(self, event):
self.shell.autoCompleteIncludeDouble = event.IsChecked()
def OnCallTipsShow(self, event):
self.shell.autoCallTip = event.IsChecked()
def OnUpdateMenu(self, event):
"""Update menu items based on current status."""
id = event.GetId()
if id == wxID_UNDO:
event.Enable(self.shell.CanUndo())
elif id == wxID_REDO:
event.Enable(self.shell.CanRedo())
elif id == wxID_CUT:
event.Enable(self.shell.CanCut())
elif id == wxID_COPY:
event.Enable(self.shell.CanCopy())
elif id == wxID_PASTE:
event.Enable(self.shell.CanPaste())
elif id == wxID_CLEAR:
event.Enable(self.shell.CanCut())
elif id == ID_AUTOCOMP_SHOW:
event.Check(self.shell.autoComplete)
elif id == ID_AUTOCOMP_INCLUDE_MAGIC:
event.Check(self.shell.autoCompleteIncludeMagic)
elif id == ID_AUTOCOMP_INCLUDE_SINGLE:
event.Check(self.shell.autoCompleteIncludeSingle)
elif id == ID_AUTOCOMP_INCLUDE_DOUBLE:
event.Check(self.shell.autoCompleteIncludeDouble)
elif id == ID_CALLTIPS_SHOW:
event.Check(self.shell.autoCallTip)
class App(wxApp):
def OnInit(self):
parent = None
id = -1
title = 'PyCrust'
self.frame = Frame(parent, id, title)
self.frame.Show(true)
self.SetTopWindow(self.frame)
return true
def main():
import sys
application = App(0)
# Add the application object to the sys module's namespace.
# This allows a shell user to do:
# >>> import sys
# >>> sys.application.whatever
sys.application = application
application.MainLoop()
if __name__ == '__main__':
main()

View File

@@ -1,211 +0,0 @@
# (C)opyright by Dirk Holtwick, 1999
# ----------------------------------
# holtwick@spirito.de
# http://www.spirito.de/pyde
from editor import *
from string import *
from keyword import *
from tokenizer import *
"""
This module will be loaded by the main
window. It implements some methods that
are typical for Python sources.
"""
class wxPyEditor(wxEditor):
# ------------------------------------------------------------------
def __init__(self, parent, id,
pos=wxDefaultPosition, size=wxDefaultSize, style=0):
wxEditor.__init__(self, parent, id, pos, size, style)
self.SetFontTab([
wxNamedColour('black'),
wxNamedColour('blue'),
wxNamedColour('red'),
wxNamedColour('darkgreen'),
wxNamedColour('brown')
])
# ------------------------------------------------------------------
def OnUpdateHighlight(self, line = -1):
if line>=0:
t = self.text[line].text
syn = []
toks = Tokenizer(t).tokens()
for type, string, begin, end in toks:
if type == "KEY":
syn.append((begin, 1))
syn.append((end, 0))
elif type == "COMMENT":
syn.append((begin, 2))
elif type == "STRING":
syn.append((begin, 3))
syn.append((end, 0))
elif type == "NUMBER":
syn.append((begin, 4))
syn.append((end, 0))
elif type == "NAME":
if string=="self":
syn.append((begin, 4))
syn.append((end, 0))
else:
pass
self.text[line].syntax = syn
# ------------------------------------------------------------------
def OnUpdateSyntax(self, line = -1):
if line>=0:
"""
tx, syn, m = self.text[line]
pre = 0
for i in range(0,len(tx)):
if tx[i] != " ":
pre = i
break
t = tx[pre:]
t = Tokenizer(t).line()
t = tx[:pre] + t
self.text[line] = t, syn, m
"""
self.OnUpdateHighlight(line)
# ------------------------------------------------------------------
def OnTabulator(self, event):
add = +1
if event.ShiftDown():
add = -1
t = self.GetTextLine(self.cy)
if strip(t):
indent = self.GetIndent(t)
# print indent
t = t[indent:]
tabs = indent / self.tabsize
# for i in range(0,tabs+add):
t = (" " * 4 * (tabs+add)) + t
self.SetTextLine(self.cy, t)
elif add>0:
self.InsertText(" ")
# ------------------------------------------------------------------
def FindQuote(self, lineno, quote_type='"""', direction=1):
"""find line containing the matching quote"""
l =lineno +direction
while (l < len(self.text)-1) and (l >= 0):
if find(self.text[l].text, quote_type) >=0: return l
l =l +direction
return None
def FindNextLine(self, lineno, direction=1):
"""get the next line of code (skipping comment lines and empty lines)"""
l =lineno +direction
while (l < len(self.text)-1) and (l >= 0):
str =lstrip(self.text[l].text)
if (len(str) >0) and (str[0] !="#"): return l
l =l +direction
return None
def Fold(self):
l = self.GetLine(self.cy)
line = self.text[l]
t = line.text
# fold ...
if line.editable:
# 3*quotes
qpos =find(t, '"""')
if qpos >=0: qtype ='"""'
else:
qpos =find(t, "'''")
if qpos >=0: qtype ="'''"
if (qpos >=0) and (find(t[qpos+3:], qtype) <0):
closing_quote =self.FindQuote(l, qtype)
if closing_quote !=None:
line.editable = not line.editable
l =l +1
while l <= closing_quote:
self.text[l].visible =self.text[l].visible +1
l =l +1
else: # try normal fold on leading whitespace
lim = self.GetIndent(t)
lnext =self.FindNextLine(l)
if (lnext !=None) \
and (self.GetIndent(self.text[lnext].text) >lim):
line.editable =FALSE
lstart =l +1
l =self.FindNextLine(l)
while (l !=None) \
and (self.GetIndent(self.text[l].text) >lim):
l =self.FindNextLine(l)
if l ==None:
# fold till the end
l =len(self.text)
for line in self.text[lstart:l]:
line.visible =line.visible +1
# ... or unfold
else:
lim = line.visible + 1
line.editable = not line.editable
l = l + 1
line = self.text[l]
while (l < (len(self.text) -1)) and (line.visible>=lim):
line.visible = line.visible - 1
l = l + 1
line = self.text[l]
def FoldAll(self):
self.CalcLines()
self.cx = 0
self.cy = len(self.lines) - 1
prev_indent =0
# following loop is exited in two cases:
# when self.cy becomes 0 (topmost level is not folded by FoldAll)
# or when FindNextLine() returns None (all remaining lines till
# the beginning of the text are empty or comments)
while self.cy:
t = self.GetTextLine(self.cy)
# indent-based folding
indent =self.GetIndent(t)
if indent <prev_indent:
self.Fold()
prev_indent =indent
# triple-quote folding
qpos =find(t, '"""')
if qpos >=0: qtype ='"""'
else:
qpos =find(t, "'''")
if qpos >=0: qtype ="'''"
if (qpos >=0) and (find(t[qpos+3:], qtype) <0):
closing_quote =self.FindQuote(self.cy, qtype, -1)
if closing_quote !=None:
# XXX potential bug: unmatched triple quotes
self.cy =closing_quote
self.Fold()
self.cy =self.FindNextLine(self.cy, -1)
if self.cy ==None: self.cy =0
# ------------------------------------------------------------------
def OnFold(self):
self.Fold()
# ------------------------------------------------------------------
def OnInit(self):
#self.FoldAll()
pass

View File

@@ -1,60 +0,0 @@
from tokenize import *
from keyword import *
from string import *
class Tokenizer:
"""
Simple class to create a list of token-tuples like:
(type, string, first, last)
Example:
t = Tokenizer('def hallo(du): # juchee')
print t.tokens()
"""
def __init__(self, text):
self.text = text
self.toks = []
try:
tokenize(self.readline, self.get)
except TokenError:
pass
def tokens(self):
return self.toks
def get(self, type, string, begin, end, l):
#print begin,end
h1, b = begin
h2, e = end
tname = tok_name[type]
if iskeyword(string):
tname = "KEY"
self.toks.append( (tname, string, b, e) )
def readline(self):
t = self.text
self.text = ""
return t
def line(self):
pre = ""
out = ""
for type, string, begin, end in self.toks:
if (pre in ["NAME","KEY"]) and (not string in [".",",","("]):
out = out + " "
if type in ["NAME","KEY"]:
out = out + string
elif type=="OP":
if string in [",",":"]:
out = out + string + " "
else:
out = out + string
else:
out = out + string
pre = type
return out