Im tring to write a piece of code to work out the indentation level of a code snippet from a text file. I know i need to use regular expressions but i dont know that much about regualr expressions in Python. What i really need is some ideas on how to work out indentation levels. Anyone got any ideas?

Tytan

heres what i have so far: (not sure how this is gonna turn out)

Code:
class parser:
	
	def __init__(self):
		self.load('test.pk')
		self.clean()
	
	def load(self, file):
		self.data = open(file, 'r').read()
		
		print self.data + '\n\n\n'
		time.sleep(5)
	
	def clean(self):
		parts = token.split(self.data)
		
		for part in parts:
			if part[:3] == '<py':
				part = re.split('\n', part[4:-3])
				for bit in part:
					bit = re.sub('\t|\s\s', '', bit)
					if bit == '': pass
					else: self.indent(bit)
		
		time.sleep(5)
		
	def indent(self, indent):
		if indent[-1] == ':': print indent
		elif indent[-1] == ',': print indent
		elif indent[-1] == '/': print indent
		else: print indent