[Python-checkins] python/dist/src/Mac/Unsupported unshar.py,NONE,1.1.6.1 run.py,1.1,NONE mkfrozenresources.py,1.2,NONE fixgusidir.py,1.1,NONE findmodulefiles.py,1.2,NONE binhextree.py,1.1,NONE RunLibScript.rsrc,1.1,NONE RunLibScript.py,1.1,NONE PackLibDir.rsrc,1.1,NONE PackLibDir.py,1.1,NONE FixCreator.py,1.1,NONE

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Mon, 28 Apr 2003 10:22:26 -0700


Update of /cvsroot/python/python/dist/src/Mac/Unsupported
In directory sc8-pr-cvs1:/tmp/cvs-serv27228/Mac/Unsupported

Added Files:
      Tag: ast-branch
	unshar.py 
Removed Files:
      Tag: ast-branch
	run.py mkfrozenresources.py fixgusidir.py findmodulefiles.py 
	binhextree.py RunLibScript.rsrc RunLibScript.py 
	PackLibDir.rsrc PackLibDir.py FixCreator.py 
Log Message:
Merge head to this branch.

Merge all sorts of changes from just before 2.3b1 into the ast
branch.  This should make the eventual merge back to the trunk easier.

The merge is almost entirely porting changes into the ast-branch.
There was no attempt to get changes to compile.c into newcompile.c.
That work should be done when newcompile.c is closer to completion.

The only significant conflicts appeared to be in pythonrun.c.


--- NEW FILE: unshar.py ---
# Extract files from a SHAR archive.
# Run this on the Mac.
# Usage:
# >>> import unshar
# >>> f = open('SHAR')
# >>> unshar.unshar(f)

import string
import EasyDialogs

def unshar(fp, verbose=0, overwrite=0):
	ofp = None
	file = None
	while 1:
		line = fp.readline()
		if verbose > 3: print 'Got:', `line`
		if line[:1] == 'X':
			# Most common case first
			if ofp: ofp.write(line[1:])
			continue
		if not line:
			if verbose: print 'EOF'
			if ofp:
				print 'Unterminated file -- closing'
				ofp.close()
				ofp = None
			break
		if line[0] == '#':
			if verbose: print line,
			continue
		if line[:14] == 'sed "s/^X//" >':
			if verbose: print "!!!", `line`
			i = string.find(line, "'")
			j = string.find(line, "'", i+1)
			if i >= 0 and j > i:
				file = line[i+1:j]
				if '/' in file:
					words = string.splitfields(file, '/')
					for funny in '', '.':
						while funny in words: words.remove(funny)
					for i in range(len(words)):
						if words[i] == '..': words[i] = ''
					words.insert(0, '')
					file = string.joinfields(words, ':')
				try:
					ofp = open(file, 'r')
					ofp.close()
					ofp = None
					over = 1
				except IOError:
					over = 0
				if over and not overwrite:
					print 'Skipping', file, '(already exists) ...'
					continue
				ofp = open(file, 'w')
				if over:
					print 'Overwriting', file, '...'
				else:
					print 'Writing', file, '...'
			continue
		if line == 'END_OF_FILE\n':
			if not file:
				print 'Unexpected END_OF_FILE marker'
			if ofp:
				print 'done'
				ofp.close()
				ofp = None
			else:
				print 'done skipping'
			file = None
			continue
		if verbose: print "...", `line`
		
def main():
	import sys
	import os
	if len(sys.argv) > 1:
		for fname in sys.argv[1:]:
			fp = open(fname, 'r')
			dir, fn = os.path.split(fname)
			if dir:
				os.chdir(dir)
			unshar(fp)
	else:
		import macfs
		fname = EasyDialogs.AskFileForOpen()
		if not fname:
			sys.exit(0)
		fp = open(fname, 'r')
		dirname = EasyDialogs.AskFolder(message='Folder to save files in:')
		if not dirname:
			sys.exit(0)
		os.chdir(dirname)
		unshar(fp)
		
if __name__ == '__main__':
	main()

--- run.py DELETED ---

--- mkfrozenresources.py DELETED ---

--- fixgusidir.py DELETED ---

--- findmodulefiles.py DELETED ---

--- binhextree.py DELETED ---

--- RunLibScript.rsrc DELETED ---

--- RunLibScript.py DELETED ---

--- PackLibDir.rsrc DELETED ---

--- PackLibDir.py DELETED ---

--- FixCreator.py DELETED ---