jpython: make this a class file

tiddlerdeja at my-deja.com tiddlerdeja at my-deja.com
Tue Mar 21 07:57:44 EST 2000


Can anyone tell me how I can run the following code on a JVM. I'm
having some trouble. Will there be trouble that there is no main()
function in a class? I just want to run this on a JVM some how.

Any help appreciated.
------------------------------

# htm2stm
# replace <!--#include file="/news/xxx.htm"-->
# with    <!--#include file="/news/xxx.stm"-->
# and
# replace <!--#include file="/news/yyy.htm"-->
# with    <!--#include file="/news/yyy.stm"-->

import os

startDir = 'C:\\Inetpub\\wwwroot\\test'

import re
head_re        = re.compile('<!--#include file="/news/xxx.htm"-->')
new_head_str    = '<!--#include file="/news/xxx.stm"-->'
fs_head_re     = re.compile('<!--#include file="/news/yyy.htm"-->')
new_fs_head_str = '<!--#include file="/news/yyy.stm"-->'


def swapExtension(arg, dirname, filenames):

	for fn in filenames:

		# check to see we are dealing with a file
		if os.path.isfile(dirname + os.sep + fn):

			file = open(dirname + os.sep + fn).read()

			if fs_head_re.search(file):
				print dirname + os.sep + fn

				# perform the substitution
				new_file = head_re.sub(new_head_str,
file)
				new_file = fs_head_re.sub
(new_fs_head_str, new_file)




				# write the new file back to disk
				write_file = open(dirname + os.sep +
fn, 'w')
				write_file.write(new_file)



if __name__ == '__main__':

	os.path.walk(startDir, swapExtension, "")




Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list