<commit_before># -*- coding: utf-8 -*-
import logging
from abc import ABCMeta, abstractmethod

from django.conf import settings

from yyfeed.fetcher import Fetcher
from yyfeed.models import Feed
from yyutil.code import build

logger = logging.getLogger(__name__)
cache = build(settings.YYFEED_CACHE)


class FetcherJob(metaclass=ABCMeta):
    FETCHER = Fetcher

    def do(self):
        try:
            feed = Feed.objects.get(name=self.name())
            self.fetch(feed)

        except Exception as e:
            logger.exception('Fetch error')
            raise e

        return 'Success.'

    @abstractmethod
    def name(self):
        pass

    @staticmethod
    def fetch(feed: Feed):
        logger.debug('---- Start fetch feed [%s] ----', feed.name)

        fetcher = build(feed.fetcher)
        fetcher.cache = cache
        for item in fetcher.fetch():
            logger.trace("item = %s", item)

            defaults = {<commit_msg>add debug info for Job<commit_after># -*- coding: utf-8 -*-
import logging
from abc import ABCMeta, abstractmethod

from django.conf import settings

from yyfeed.fetcher import Fetcher
from yyfeed.models import Feed
from yyutil.code import build

logger = logging.getLogger(__name__)
cache = build(settings.YYFEED_CACHE)


class FetcherJob(metaclass=ABCMeta):
    FETCHER = Fetcher

    def do(self):
        name = self.name()

        try:
            feed = Feed.objects.get(name=name)
            self.fetch(feed)

        except Exception as e:
            logger.exception('Fetch error')
            logger.debug('---- Error fetch feed [%s] ----', name)
            raise e

        return 'Success.'

    @abstractmethod
    def name(self):
        pass

    @staticmethod
    def fetch(feed: Feed):
        logger.debug('---- Start fetch feed [%s] ----', feed.name)

        fetcher = build(feed.fetcher)
        fetcher.cache = cache
        for item in fetcher.fetch():
            logger.trace("item = %s", item)

            defaults = {
{'fraction_non_alphanumeric': 0.1108891108891109, 'fraction_numerical': 0.000999000999000999, 'mean_word_length': 2.2048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3582746', 'n_tokens_mistral': 599, 'n_tokens_neox': 578, 'n_words': 164}