<commit_before>import logging
from datetime import datetime
from sqlalchemy import Column, Integer, String, Unicode, DateTime
from sqlalchemy.schema import Index, MetaData
from flexget import schema
from flexget.plugin import register_plugin, register_parser_option, priority
from flexget.manager import Session
from flexget.utils.tools import console
from flexget.utils.sqlalchemy_utils import table_add_column

SCHEMA_VER = 1

log = logging.getLogger('failed')
Base = schema.versioned_base('failed', SCHEMA_VER)


@schema.upgrade('failed')
def upgrade(ver, session):
    if ver is None:
        # add count column
        table_add_column('failed', 'count', Integer, session, default=1)
        ver = 0
    if ver == 0:
        # define an index
        log.info('Adding database index ...')
        meta = MetaData(bind=session.connection(), reflect=True)
        failed = meta.tables['failed']
        Index('failed_title_url', failed.c.title, failed.c.url).create()
        ver = 1
    return ver


class FailedEntry(Base):
    __tablename__ = 'failed'

    id = Column(Integer, primary_key=True)
    title = Column(Unicode)
    url = Column(String)
    tof = Column(DateTime)
    count = Column(Integer, default=1)

    def __init__(self, title, url):
        self.title = title
        self.url = url
        self.tof = datetime.now()

    def __str__(self):
        return '<Failed(title=%s)>' % self.title

# create indexes, used when creating tables
columns = Base.metadata.tables['failed'].c
Index('failed_title_url', columns.title, columns.url)


class PluginFailed(object):
    """Provides tracking for failures and related commandline utilities."""

    def validator(self):
        from flexget import validator
        return validator.factory('boolean')

    def on_process_start(self, feed, config):
        if feed.manager.options.failed:
            feed.manager.disable_feeds()
            self.print_failed()
            return
        if feed.manager.options.clear_failed:
            feed.manager.disable_feeds()
            self.clear_failed()
            return

    def print_failed(self):
        """Parameter --failed"""<commit_msg>Hot fix for previous commit<commit_after>import logging
from datetime import datetime
from sqlalchemy import Column, Integer, String, Unicode, DateTime
from sqlalchemy.schema import Index, MetaData
from flexget import schema
from flexget.plugin import register_plugin, register_parser_option, priority
from flexget.manager import Session
from flexget.utils.tools import console
from flexget.utils.sqlalchemy_utils import table_add_column

SCHEMA_VER = 1

log = logging.getLogger('failed')
Base = schema.versioned_base('failed', SCHEMA_VER)


@schema.upgrade('failed')
def upgrade(ver, session):
    if ver is None:
        # add count column
        table_add_column('failed', 'count', Integer, session, default=1)
        ver = 0
    if ver == 0:
        # define an index
        log.info('Adding database index ...')
        meta = MetaData(bind=session.connection(), reflect=True)
        failed = meta.tables['failed']
        Index('failed_title_url', failed.c.title, failed.c.url, failed.c.count).create()
        ver = 1
    return ver


class FailedEntry(Base):
    __tablename__ = 'failed'

    id = Column(Integer, primary_key=True)
    title = Column(Unicode)
    url = Column(String)
    tof = Column(DateTime)
    count = Column(Integer, default=1)

    def __init__(self, title, url):
        self.title = title
        self.url = url
        self.tof = datetime.now()

    def __str__(self):
        return '<Failed(title=%s)>' % self.title

# create indexes, used when creating tables
columns = Base.metadata.tables['failed'].c
Index('failed_title_url', columns.title, columns.url, columns.count)


class PluginFailed(object):
    """Provides tracking for failures and related commandline utilities."""

    def validator(self):
        from flexget import validator
        return validator.factory('boolean')

    def on_process_start(self, feed, config):
        if feed.manager.options.failed:
            feed.manager.disable_feeds()
            self.print_failed()
            return
        if feed.manager.options.clear_failed:
            feed.manager.disable_feeds()
            self.clear_failed()
            return

    def print_failed(self):
        """Parameter --failed"""
{'fraction_non_alphanumeric': 0.10281657888710785, 'fraction_numerical': 0.0027478818410808336, 'mean_word_length': 3.120754716981132, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5756874', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1208, 'n_words': 335}