def p_prelist(self, p): '''prelist : integer prelist_seen '(' itemlist ')' | integer prelist_seen '(' binaryblob ')' | integer prelist_seen '(' unparsed ')' ''' if type(p[4]) == Unparsed: p[0] = UnparsedList(int(p[1]), p[4].data) elif type(p[4]) == BinaryBlob: p[0] = BinaryList(int(p[1]), p[4].data) else: p[0] = self.condenseAllPreFixLists(p[4])
def p_prelist(self, p): '''prelist : integer prelist_seen '(' itemlist ')' | integer prelist_seen '(' binaryblob ')' | integer prelist_seen '(' unparsed ')' | integer prelist_seen '{' item '}' ''' if type(p[4]) == Unparsed: p[0] = UnparsedList(int(p[1]), p[4].data) elif type(p[4]) == BinaryBlob: p[0] = BinaryList(int(p[1]), p[4].data) elif p[5] == '}': p[0] = [p[4]] * int(p[1]) else: if len(p[4]) != p[1] and self.checkPrelistLength: p[0] = NotAPrelist(p[1], p[4]) else: p[0] = self.condenseAllPreFixLists(p[4])
def testUnparsedListDict(self): content="1\n2\n3\n4\n5\n6" g=FoamFileGenerator({"a":UnparsedList(6,content),"b":"nix"}) self.assertEqual(str(g),"a\n 6 ("+content+"\n );\nb nix;\n")
def testUnparsedListList(self): content="1\n2\n3\n4\n5\n6" g=FoamFileGenerator([UnparsedList(6,content),"nix"]) self.assertEqual(str(g),"(\n\n 6 ("+content+"\n )\n nix\n)\n")
def testUnparsedList(self): content="1\n2\n3\n4\n5\n6" g=FoamFileGenerator(UnparsedList(6,content)) self.assertEqual(str(g),"6 ("+content+"\n)\n")