- More Python help.

This commit is contained in:
ccremers 2005-12-05 15:51:25 +00:00
parent b5f627054e
commit 87de97d578
2 changed files with 13 additions and 18 deletions

View File

@ -5,6 +5,7 @@
# Objects and stuff for the intermediate format # Objects and stuff for the intermediate format
# #
import copy # To copy objects import copy # To copy objects
import os # For path functions
class Message(object): class Message(object):
@ -370,10 +371,8 @@ class AuthenticateRule(GoalRule):
class Protocol(list): class Protocol(list):
def setFilename(self, filename): def setFilename(self, filename):
# TODO untested self.path = os.path.dirname(filename)
parts = filename.split("/") self.filename = os.path.basename(filename)
self.path = "".join(parts[:-1])
self.filename = parts[-1]
# Get head of filename (until first dot) # Get head of filename (until first dot)
def getBaseName(self): def getBaseName(self):

View File

@ -266,21 +266,17 @@ def ifParser():
# Determine (un)typedness from this line # Determine (un)typedness from this line
def typeSwitch(line): def typeSwitch(line):
try: global typedversion
global typedversion
typeflag = Literal("#") + "option" + Literal("=") + oneOf ("untyped","typed") typeflag = Literal("#") + "option" + Literal("=") + oneOf ("untyped","typed")
res = typeflag.parseString(line) res = typeflag.parseString(line)
if res[3] == "untyped": if res[3] == "untyped":
typedversion = False typedversion = False
elif res[3] == "typed": elif res[3] == "typed":
typeversion = True typeversion = True
else: else:
print "Cannot determine whether typed or untyped." print "Cannot determine whether typed or untyped."
raise ParseException raise ParseException
except:
print "Unexpected error while determining (un)typedness of the line", line
str = "Detected " str = "Detected "
if not typedversion: if not typedversion: