*** empty log message ***

This commit is contained in:
Joe Shochet 2001-02-07 18:08:15 +00:00
parent f20c160c06
commit 623a770f4b

View File

@ -52,7 +52,7 @@ def findClass(namespace, className):
def rebindClass(builtins, filename): def rebindClass(builtins, filename):
file = open(filename) file = open(filename, 'r')
lines = file.readlines() lines = file.readlines()
curLine = 0 curLine = 0
found = 0 found = 0
@ -82,41 +82,33 @@ def rebindClass(builtins, filename):
if not found: if not found:
print 'error: className not found' print 'error: className not found'
return None return
# Store the original real class # Store the original real class
res = findClass(builtins, className) res = findClass(builtins, className)
if res: if res:
realClass, realNameSpace = res realClass, realNameSpace = res
else: else:
print ('Error redinifing class: could not find class: ' + className) print ('Warning: could not find class, defining new class in builtins: ' + className)
return None # Now execute that class def
execfile(filename, builtins)
# Make a temp file in the home directory to execfile from # Remove that temp file
tmpfilename = os.path.join(os.getenv('HOME'), 'tmp_py_file')
tmpfile = open(tmpfilename, 'w')
# now write the class back to the file with the new class name
for i in range(len(lines)):
# if (i == foundLine):
# tmpfile.write(newline)
# else:
tmpfile.write(lines[i])
file.close() file.close()
tmpfile.close() os.remove(filename)
return
# Now execute that class def # Now execute that class def
execfile(tmpfilename, realNameSpace) execfile(filename, realNameSpace)
# Remove that temp file # Remove that temp file
os.remove(tmpfilename) file.close()
os.remove(filename)
res = findClass(realNameSpace, className) res = findClass(realNameSpace, className)
if res: if res:
tmpClass, tmpNameSpace = res tmpClass, tmpNameSpace = res
else: else:
print ('Error redinifing class: could not find temp class') print ('Internal error redefining class: could not find temp class')
return None return
# Copy the functions that we just redefined into the real class # Copy the functions that we just redefined into the real class
copyFuncs(tmpClass, realClass) copyFuncs(tmpClass, realClass)