Ejemplo n.º 1
0
    def task_parse_database(self, data):
        filename, on_done = data
        if self.add_busy(filename, self.task_parse_database, data):
            return
        try:
            self.set_status('Parsing compilation database: %s' % filename)
            with open(filename) as compilation_database_file:
                compilation_database_entries = json.load(compilation_database_file)

            total = len(compilation_database_entries)
            entry = 0
            for compilation_entry in compilation_database_entries:
                entry = entry + 1
                self.set_status('Parsing compilation database: %s (%d/%d)' % (filename, entry, total))
                entry_folder = os.path.dirname(compilation_entry["file"])
                if entry_folder not in self.compilation_database:
                    self.compilation_database[entry_folder] = []

                self.compilation_database[entry_folder].extend([ p.strip() for p in compilation_database_pattern.findall(compilation_entry["command"]) ])

            for k,v in self.compilation_database.items():
                self.compilation_database[k] = list(set(self.compilation_database[k]))

            self.set_status("Parsing %s done" % filename)
        finally:
            l = self.parsingList.lock()
            try:
                l.remove(filename)
            finally:
                self.parsingList.unlock()
                self.remove_busy(filename)
        if not on_done is None:
            run_in_main_thread(on_done)
Ejemplo n.º 2
0
 def do_message(self):
     try:
         self.lock.acquire()
         common.run_in_main_thread(lambda: common.status_message(self.status))
         self.status_count = 0
         self.timer = None
     finally:
         self.lock.release()