[pypy-svn] rev 1472 - pypy/trunk/doc/funding/tools
stephan at codespeak.net
stephan at codespeak.net
Tue Sep 30 17:32:22 CEST 2003
Author: stephan
Date: Tue Sep 30 17:32:21 2003
New Revision: 1472
Modified:
pypy/trunk/doc/funding/tools/format.py
pypy/trunk/doc/funding/tools/zipmod.py
Log:
fxed some errors in format
Modified: pypy/trunk/doc/funding/tools/format.py
==============================================================================
--- pypy/trunk/doc/funding/tools/format.py (original)
+++ pypy/trunk/doc/funding/tools/format.py Tue Sep 30 17:32:21 2003
@@ -13,6 +13,7 @@
class parse(object):
def __init__(self,text):
self.text = text
+ self.index = 0
def start(self,txt):pass
def stop(self,txt):pass
@@ -20,39 +21,40 @@
def other(self,txt):pass
def any(self,txt):pass
def parse(self):
- content = self.text[:]
- while content:
- m = OTHER.match(content)
+ content = self.text
+ txtlen = len(content)
+ while txtlen > self.index:
+ m = OTHER.match(content,self.index)
if m is not None:
- #print 'OTHER:',m.group()
- content = content[m.span()[1]:]
+ #print 'OTHER:',m.group(),m.span()
+ self.index = m.span()[1]
self.other(m.group())
continue
- m = EMPTY.match(content)
+ m = EMPTY.match(content,self.index)
if m is not None:
- #print 'EMPTY:',m.group()
- content = content[m.span()[1]:]
+ #print 'EMPTY:',m.group(),m.span()
+ self.index = m.span()[1]
self.empty(m.group())
continue
- m = START.match(content)
+ m = START.match(content,self.index)
if m is not None:
- #print 'START:',m.group()
- content = content[m.span()[1]:]
+ #print 'START:',m.group(),m.span()
+ self.index = m.span()[1]
self.start(m.group())
continue
- m = STOP.match(content)
+ m = STOP.match(content,self.index)
if m is not None:
- #print 'STOP:',m.group()
- content = content[m.span()[1]:]
+ #print 'STOP:',m.group(),m.span()
+ self.index = m.span()[1]
self.stop(m.group())
continue
- m = ANY.match(content)
+ m = ANY.match(content,self.index)
if m is not None:
- #print 'ANY:',m.group()
+ #print 'ANY:',m.group(),m.span()
+ self.index = m.span()[1]
txt = m.group()
txt.strip()
self.any(txt)
- content = content[m.span()[1]:]
continue
class format(parse):
@@ -60,6 +62,7 @@
super(format,self).__init__(*argl,**argd)
self.level = 0
self.outbuf = []
+ self.stack = []
def __str__(self):
self.parse()
@@ -124,6 +127,12 @@
return ''.join(self.outbuf)
def start(self,txt):
+ i = txt.find(' ')
+ if i:
+ elem = txt[1:i]
+ else:
+ elem = txt[1:-1]
+ self.stack.append(elem)
txt = txt.strip()
if txt.startswith('<style:style'):
for tab in self.tabnames:
@@ -136,7 +145,9 @@
txt = txt.strip()
if self.inStyle:
self.inStyle = False
- self.outbuf.append(txt)
+ #self.outbuf.append(txt)
+ #elem = ''.join(('</',self.stack.pop(),'>'))
+ self.outbuf.append('</%s>' % self.stack.pop())
def other(self,txt):
txt = txt.strip()
@@ -158,6 +169,7 @@
def changeStyle(txt):
f = format(str(replaceMargin(txt)))
return str(f)
+ #return str(replaceMargin(txt))
if __name__ == '__main__':
import sys
Modified: pypy/trunk/doc/funding/tools/zipmod.py
==============================================================================
--- pypy/trunk/doc/funding/tools/zipmod.py (original)
+++ pypy/trunk/doc/funding/tools/zipmod.py Tue Sep 30 17:32:21 2003
@@ -58,13 +58,18 @@
dirName = os.path.join(tmp, os.path.dirname(fn))
try: os.mkdir(dirName)
except OSError: pass
- destPath = os.path.join(tmp, fn)
- open(destPath, 'w').write(filemap[fn])
+ destPath = os.path.join(tmp, fn.replace('/',os.sep))
+ d,f = os.path.split(destPath)
+ try:
+ os.makedirs(d)
+ except:pass
+ fs = open(destPath, 'wb')
+ fs.write(filemap[fn])
# rebuild a copy of the original ZIP file from tmp. dir.
zip = zipfile.ZipFile(docPath, 'w', zipfile.ZIP_DEFLATED)
for fn in filenames:
- destPath = os.path.join(tmp, fn)
+ destPath = os.path.join(tmp, fn.replace('/',os.sep))
zip.write(destPath, fn)
More information about the Pypy-commit
mailing list