Пример #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
    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)