示例#1
0
    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")
示例#2
0
    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'))
示例#3
0
文件: dparser.py 项目: 01org/fMBT
    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")
示例#4
0
    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")
示例#5
0
 def __del__(self):
     if self.tables:
         dparser_swigc.unload_parser_tables(self.tables)
示例#6
0
 def __del__(self):
     if self.tables:
         dparser_swigc.unload_parser_tables(self.tables)
示例#7
0
 def __del__(self):
     del self.sig
     if self.tables and dparser_swigc:
         dparser_swigc.unload_parser_tables(self.tables)
示例#8
0
 def __del__(self):
     del self.sig
     if self.tables and dparser_swigc:
         dparser_swigc.unload_parser_tables(self.tables)