<commit_before>#
# Copyright (c) 2009 rPath, Inc.
#
# This program is distributed under the terms of the Common Public License,
# version 1.0. A copy of this license should have been distributed with this
# source file in a file called LICENSE. If it is not present, the license
# is always available at http://www.rpath.com/permanent/licenses/CPL-1.0.
#
# This program is distributed in the hope that it will be useful, but
# without any warranty; without even the implied warranty of merchantability
# or fitness for a particular purpose. See the Common Public License for
# full details.
#

"""
Conary callbacks that have been wrapped to be more friendly with the
logging module.
"""

import logging
log = logging.getLogger('updatebot.lib.conarycallbacks')

from conary.conaryclient.callbacks import CloneCallback

def callonce(func):
    def wrapper(self, *args, **kwargs):
        if self._last != func.__name__:
            self._last = func.__name__
            return func(self, *args, **kwargs)
    return wrapper

class UpdateBotCloneCallback(CloneCallback):
    def __init__(self, *args, **kwargs):
        self._log = kwargs.pop('log', log)
        CloneCallback.__init__(self, *args, **kwargs)

        self._last = None

    def _message(self, message):
        self._log.info(message)

    @callonce
    def determiningCloneTroves(self, current=0, total=0):
        CloneCallback.determiningCloneTroves(self, current=0, total=0)

    @callonce
    def determiningTargets(self):
        CloneCallback.determiningTargets(self)

    @callonce
    def targetSources(self, current=0, total=0):
        CloneCallback.targetSources(self, current=0, total=0)

    @callonce
    def targetBinaries(self, current=0, total=0):
        CloneCallback.targetBinaries(self, current=0, total=0)

    @callonce
    def checkNeedsFulfilled(self, current=0, total=0):
        CloneCallback.checkNeedsFulfilled(self, current=0, total=0)

    @callonce
    def rewriteTrove(self, current=0, total=0):
        CloneCallback.rewriteTrove(self, current=0, total=0)

    @callonce
    def buildingChangeset(self, current=0, total=0):
        CloneCallback.buildingChangeset(self, current=0, total=0)

    @callonce
    def requestingFiles(self, number):
        CloneCallback.requestingFiles(self, number)

    @callonce
    def requestingFileContentsWithCount(self, count):
        CloneCallback.requestingFileContentsWithCount(self, count)

    @callonce
    def gettingCloneData(self):
        CloneCallback.gettingCloneData(self)
<commit_msg>only call download callback once<commit_after>#
# Copyright (c) 2009 rPath, Inc.
#
# This program is distributed under the terms of the Common Public License,
# version 1.0. A copy of this license should have been distributed with this
# source file in a file called LICENSE. If it is not present, the license
# is always available at http://www.rpath.com/permanent/licenses/CPL-1.0.
#
# This program is distributed in the hope that it will be useful, but
# without any warranty; without even the implied warranty of merchantability
# or fitness for a particular purpose. See the Common Public License for
# full details.
#

"""
Conary callbacks that have been wrapped to be more friendly with the
logging module.
"""

import logging
log = logging.getLogger('updatebot.lib.conarycallbacks')

from conary.conaryclient.callbacks import CloneCallback

def callonce(func):
    def wrapper(self, *args, **kwargs):
        if self._last != func.__name__:
            self._last = func.__name__
            return func(self, *args, **kwargs)
    return wrapper

class UpdateBotCloneCallback(CloneCallback):
    def __init__(self, *args, **kwargs):
        self._log = kwargs.pop('log', log)
        CloneCallback.__init__(self, *args, **kwargs)

        self._last = None

    def _message(self, message):
        self._log.info(message)

    @callonce
    def determiningCloneTroves(self, current=0, total=0):
        CloneCallback.determiningCloneTroves(self, current=0, total=0)

    @callonce
    def determiningTargets(self):
        CloneCallback.determiningTargets(self)

    @callonce
    def targetSources(self, current=0, total=0):
        CloneCallback.targetSources(self, current=0, total=0)

    @callonce
    def targetBinaries(self, current=0, total=0):
        CloneCallback.targetBinaries(self, current=0, total=0)

    @callonce
    def checkNeedsFulfilled(self, current=0, total=0):
        CloneCallback.checkNeedsFulfilled(self, current=0, total=0)

    @callonce
    def rewriteTrove(self, current=0, total=0):
        CloneCallback.rewriteTrove(self, current=0, total=0)

    @callonce
    def buildingChangeset(self, current=0, total=0):
        CloneCallback.buildingChangeset(self, current=0, total=0)

    @callonce
    def requestingFiles(self, number):
        CloneCallback.requestingFiles(self, number)

    @callonce
    def requestingFileContentsWithCount(self, count):
        CloneCallback.requestingFileContentsWithCount(self, count)

    @callonce
    def gettingCloneData(self):
        CloneCallback.gettingCloneData(self)

    @callonce
    def sendingChangset(self, got, need):
        self._message('uploading changeset')
{'fraction_non_alphanumeric': 0.09533898305084745, 'fraction_numerical': 0.012326656394453005, 'mean_word_length': 3.768595041322314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3082416', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1527, 'n_words': 435}