Ejemplo n.º 1
0
    def process(self):
        if self.projects is None:
            self.projects = {}
            for name, module in self.project_args:
                with open(f'{name}.json', 'r') as f:
                    project: Project = jsonpickle.decode(f.read())
                    self.projects[project.name] = project

        for name, project in self.projects.items():
            test_files = TestIndex.iter_test_files(name)
            test_methods: Dict[PyDrillerMethod, Set[CustomCommit]] = {}
            for commit in project.commits:
                for method in commit.modified_methods:
                    if method.filename in test_files:
                        if method in test_methods:
                            test_methods[method].add(commit)
                        else:
                            test_methods[method] = set()
            for method, commits in test_methods.items():
                contributors = {commit.author.email for commit in commits}
                new_method = Method.from_pydriller_method(method.filename, method, len(commits), contributors, project)
                project.methods.append(new_method)