multi_space = OneOrMore(Literal(" ")|"\t"|"\r"|"\f") // An expression for matching multi spaces
if path:
self.network = open(path, "r").read()
elif string:
self.network = string
After Change
multi_space = OneOrMore(Literal(" ")|"\t"|"\r"|"\f") // An pyparsing expression for checking mulitple spaces
if path:
with open(path, "r") as network:
self.network = network.read()
elif string:
self.network = string
else:
raise ValueError("Must specify either path or string")
if """ in self.network:
Replacing quotes by spaces to remove case sensitivity like:
"Dog-Problem" and Dog-problem
or "true""false" and "true" "false" and true false
self.network = self.network.replace(""", " ")
self.network = multi_space.setParseAction(lambda t:" ").transformString(self.network) // replacing mulitple spaces or tabs by one space
if "/*" in self.network or "//" in self.network:
self.network = cppStyleComment.suppress().transformString(self.network) // removing comments from the file
self.grammar = self.get_grammar(self.network)
self.network_name = self.get_network_name()
self.variable_names = self.get_variables()
self.variable_states = self.get_states()