Ejemplo n.º 1
0
def load_prelude():

	for line in open(os.path.dirname(os.path.abspath(__file__)) + "/prelude.w", "r"):
		line = line.strip()
		# Comment stripper. Fragile!
		line = line[:line.find('#')] if '#' in line else line

		# Ignore blank lines
		if line:
			evaluate( parse( expand_arrows(line), ROOT), ROOT )
Ejemplo n.º 2
0
def load_file(filename):
	try:
		for line in open( os.path.dirname(os.path.abspath(__file__)) + "/%s.w" % filename, "r"):
			line = line.strip()
			# Comment stripper. Fragile!
			line = line[:line.find('#')] if '#' in line else line

			# Ignore blank lines
			if line:
				evaluate( parse( expand_arrows(line), ROOT), ROOT )
	except:
		print "Can't load that file for some damned reason or another."
Ejemplo n.º 3
0
	def test_transition_expansion(self):
		test_line = "foo -> bar"
		self.assertEqual("transition (pattern foo) (action bar)", expand_arrows(test_line))
Ejemplo n.º 4
0
	if command in ('reset',):
		ROOT = Category("*")
		ROOT.add(ROOT)
		load_prelude()
		print "* was reset"
		continue

	if command.split() and command.split()[0] == "load":
		args = command.split()
		if len(args) != 2:
			print "This didn't make sense for loading: ", args
		else:
			load_file(args[1])
		continue

	# Ignore blank lines
	if line:
		evaluate( parse( expand_arrows(line), ROOT), ROOT )