<commit_before># -*- coding: utf-8 -*-
# @Author: Michael
# @Date:   2016-12-27 19:21:52
# @Last Modified by:   Michael
# @Last Modified time: 2017-01-02 18:02:43
from .utils import fileLayoutJudge, lock, walker
from .parsers import JsonPaser


class ManageEngine(object):
    """
    @brief      Class for manage engine.
    """
    def __init__(self):
        super(ManageEngine, self).__init__()
        self.parsers = {}
        self.initParsers()
        self.payload = {}

    def initParsers(self):
        self.parsers['json'] = JsonPaser()

    def generatePayload(self, changedFiles):
        owner = changedFiles['owner']
        filesToDelete = changedFiles.get('D')
        filesToUpdate = changedFiles.get('A')
        if filesToDelete is not None:
            self.processDelete(filesToDelete)
        if filesToUpdate is not None:
            self.processUpdate(filesToUpdate, owner)

    def processDelete(self, files):
        pass

    def processUpdate(self, files, owner):
        walker.appendFiles(files, lock)
        packagePrev = None
        for path, package in walker:
            if packagePrev is None or package != packagePrev:
                packagePrev = package
                self.parsers[fileLayoutJudge(path)].parse(path, owner, packagePrev)
            else:
                self.parsers[fileLayoutJudge(path)].parse(path)
>>>>>>> dev<commit_msg>fixed some error<commit_after># -*- coding: utf-8 -*-
# @Author: Michael
# @Date:   2016-12-27 19:21:52
# @Last Modified by:   Michael
# @Last Modified time: 2017-01-02 18:05:22
from .utils import fileLayoutJudge, lock, walker
from .parsers import JsonPaser


class ManageEngine(object):
    """
    @brief      Class for manage engine.
    """
    def __init__(self):
        super(ManageEngine, self).__init__()
        self.parsers = {}
        self.initParsers()
        self.payload = {}

    def initParsers(self):
        self.parsers['json'] = JsonPaser()

    def generatePayload(self, changedFiles):
        owner = changedFiles['owner']
        filesToDelete = changedFiles.get('D')
        filesToUpdate = changedFiles.get('A')
        if filesToDelete is not None:
            self.processDelete(filesToDelete)
        if filesToUpdate is not None:
            self.processUpdate(filesToUpdate, owner)

    def processDelete(self, files):
        pass

    def processUpdate(self, files, owner):
        walker.appendFiles(files, lock)
        packagePrev = None
        for path, package in walker:
            if packagePrev is None or package != packagePrev:
                packagePrev = package
                self.parsers[fileLayoutJudge(path)].parse(path, owner, packagePrev)
            else:
                self.parsers[fileLayoutJudge(path)].parse(path)
{'fraction_non_alphanumeric': 0.10886075949367088, 'fraction_numerical': 0.020976491862567812, 'mean_word_length': 2.4618272841051314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '733849', 'n_tokens_mistral': 844, 'n_tokens_neox': 772, 'n_words': 198}