def load_tables(self, grammar_str, filename, make_grammar_file): if make_grammar_file: with open(filename, 'wb') as fh: fh.write(grammar_str) if self.sig_changed(filename): dparser_swigc.make_tables(grammar_str, filename) with open(filename + '.md5', 'wb') as fh: fh.write(self.sig.digest()) if self.tables: dparser_swigc.unload_parser_tables(self.tables) self.tables = dparser_swigc.load_parser_tables(filename + ".d_parser.dat")
def load_tables(self, grammar_str, filename, make_grammar_file): if make_grammar_file: with open(filename, 'wb') as fh: fh.write(grammar_str) if self.sig_changed(filename): dparser_swigc.make_tables(grammar_str, filename.encode()) with open(filename + '.md5', 'wb') as fh: fh.write(self.sig.digest()) if self.tables: dparser_swigc.unload_parser_tables(self.tables) self.tables = dparser_swigc.load_parser_tables( (filename + ".d_parser.dat").encode('utf-8'))
def load_tables(self,grammar_str, filename, make_grammar_file): if make_grammar_file: g_file = open(filename, "wb") # 'binary' mode has been set to force \n on end of the line g_file.write(grammar_str) g_file.close() if self.sig_changed(filename): dparser_swigc.make_tables(grammar_str, filename) sig_file = open(filename + ".md5", "wb") sig_file.write(self.sig.digest()) sig_file.close() if self.tables: dparser_swigc.unload_parser_tables(self.tables) self.tables = dparser_swigc.load_parser_tables(filename + ".d_parser.dat")
def load_tables(self, grammar_str, filename, make_grammar_file): if make_grammar_file: g_file = open( filename, "wb" ) # 'binary' mode has been set to force \n on end of the line g_file.write(grammar_str) g_file.close() if self.sig_changed(filename): dparser_swigc.make_tables(grammar_str, filename) sig_file = open(filename + ".md5", "wb") sig_file.write(self.sig.digest()) sig_file.close() if self.tables: dparser_swigc.unload_parser_tables(self.tables) self.tables = dparser_swigc.load_parser_tables(filename + ".d_parser.dat")
def __del__(self): if self.tables: dparser_swigc.unload_parser_tables(self.tables)
def __del__(self): del self.sig if self.tables and dparser_swigc: dparser_swigc.unload_parser_tables(self.tables)