# based on Andrew Kuchling's minigzip.py distributed with the zlib module
-import string, struct, sys, time
+import struct, sys, time
import zlib
import __builtin__
self.fileobj.write( self.compress.compress(data) )
def writelines(self,lines):
- self.write(string.join(lines))
+ self.write(" ".join(lines))
def read(self, size=-1):
if self.extrasize <= 0 and self.fileobj is None:
readsize = min(100, size) # Read from the file in small chunks
while 1:
if size == 0:
- return string.join(bufs, '') # Return resulting line
+ return "".join(bufs) # Return resulting line
c = self.read(readsize)
- i = string.find(c, '\n')
+ i = c.find('\n')
if size is not None:
# We set i=size to break out of the loop under two
# conditions: 1) there's no newline, and the chunk is
if i >= 0 or c == '':
bufs.append(c[:i+1]) # Add portion of last chunk
self._unread(c[i+1:]) # Push back rest of chunk
- return string.join(bufs, '') # Return resulting line
+ return ''.join(bufs) # Return resulting line
# Append chunk to list, decrease 'size',
bufs.append(c)
iskeyword = kwdict.has_key
def main():
- import sys, re, string
+ import sys, re
args = sys.argv[1:]
iptfile = args and args[0] or "Python/graminit.c"
while 1:
line = fp.readline()
if not line: break
- if string.find(line, '{1, "') > -1:
+ if line.find('{1, "') > -1:
match = strprog.search(line)
if match:
lines.append(" '" + match.group(1) + "',\n")
# write the output file
fp = open(optfile, 'w')
- fp.write(string.join(format, ''))
+ fp.write(''.join(format))
fp.close()
if __name__ == "__main__":