<commit_before># -*- coding: utf-8 -*-

###############################################################################
#   Copyright(c) 2008-2013 pyLoad Team
#   http://www.pyload.org
#
#   This file is part of pyLoad.
#   pyLoad is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as
#   published by the Free Software Foundation, either version 3 of the
#   License, or (at your option) any later version.
#
#   Subjected to the terms and conditions in LICENSE
#
#   @author: RaNaN
###############################################################################

import sys
from time import time, sleep
from random import randint

from pyload.utils import decode
from pyload.utils.fs import exists, makedirs, join, remove

# TODO
#       more attributes if needed
#       get rid of catpcha & container plugins ?! (move to crypter & internals)
#       adapt old plugins as needed

class Fail(Exception):
    """ raised when failed """

class Retry(Exception):
    """ raised when start again from beginning """

class Abort(Exception):
    """ raised when aborted """

class Base(object):
    """
    The Base plugin class with all shared methods and every possible attribute for plugin definition.
    """
    __version__ = "0.1"
    #: Regexp pattern which will be matched for download/crypter plugins
    __pattern__ = r""
    #: Internal addon plugin which is always loaded
    __internal__ = False
    #: When True this addon can be enabled by every user
    __user_context__ = False
    #: Config definition: list of  (name, type, label, default_value) or
    #: (name, label, desc, Input(...))
    __config__ = tuple()
    #: Short description, one liner
    __description__ = ""
    #: More detailed text
    __explanation__ = """"""
    #: List of needed modules
    __dependencies__ = tuple()
    #: Used to assign a category for addon plugins
    __category__ = ""
    #: Tags to categorize the plugin, see documentation for further info
    __tags__ = tuple()
    #: Base64 encoded .png icon, should be 32x32, please don't use sizes above ~2KB, for bigger icons use url.
    __icon__ = ""
    #: Alternative, link to png icon
    __icon_url__ = ""
    #: Domain name of the service
    __domain__ = ""
    #: Url with general information/support/discussion
    __url__ = ""
    #: Url to term of content, user is accepting these when using the plugin
    __toc_url__ = ""
    #: Url to service (to buy premium) for accounts
    __ref_url__ = ""

    __author__ = tuple()
    __author_mail__ = tuple()


    def __init__(self, core, owner=None):
        self.__name__ = self.__class__.__name__

        #: Core instance
        self.core = core
        #: logging instance
        self.log = core.log
        #: core config
        self.config = core.config
        #: :class:`EventManager`
        self.evm = core.eventManager
        #: :class:`InteractionManager`
        self.im = core.interactionManager
        if owner is not None:
            #: :class:`Api`, user api when user is set
            self.api = self.core.api.withUserContext(user)
            if not self.api:
                raise Exception("Plugin running with invalid user")

            #: :class:`User`, user related to this plugin
            self.owner = self.api.user
        else:
            self.api = self.core.api
            self.owner = None

        #: last interaction task
        self.task = None

        #: js engine, see `JsEngine`
        self.js = self.core.js

    def __getitem__(self, item):
        """ Retrieves meta data attribute """
        return getattr(self, "__%s__" % item)

    def logInfo(self, *args, **kwargs):
        """ Print args to log at specific level

        :param args: Arbitrary object which should be logged
        :param kwargs: sep=(how to separate arguments), default = " | "
        """<commit_msg>renamed new self.user to self.owner<commit_after># -*- coding: utf-8 -*-

###############################################################################
#   Copyright(c) 2008-2013 pyLoad Team
#   http://www.pyload.org
#
#   This file is part of pyLoad.
#   pyLoad is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as
#   published by the Free Software Foundation, either version 3 of the
#   License, or (at your option) any later version.
#
#   Subjected to the terms and conditions in LICENSE
#
#   @author: RaNaN
###############################################################################

import sys
from time import time, sleep
from random import randint

from pyload.utils import decode
from pyload.utils.fs import exists, makedirs, join, remove

# TODO
#       more attributes if needed
#       get rid of catpcha & container plugins ?! (move to crypter & internals)
#       adapt old plugins as needed

class Fail(Exception):
    """ raised when failed """

class Retry(Exception):
    """ raised when start again from beginning """

class Abort(Exception):
    """ raised when aborted """

class Base(object):
    """
    The Base plugin class with all shared methods and every possible attribute for plugin definition.
    """
    __version__ = "0.1"
    #: Regexp pattern which will be matched for download/crypter plugins
    __pattern__ = r""
    #: Internal addon plugin which is always loaded
    __internal__ = False
    #: When True this addon can be enabled by every user
    __user_context__ = False
    #: Config definition: list of  (name, type, label, default_value) or
    #: (name, label, desc, Input(...))
    __config__ = tuple()
    #: Short description, one liner
    __description__ = ""
    #: More detailed text
    __explanation__ = """"""
    #: List of needed modules
    __dependencies__ = tuple()
    #: Used to assign a category for addon plugins
    __category__ = ""
    #: Tags to categorize the plugin, see documentation for further info
    __tags__ = tuple()
    #: Base64 encoded .png icon, should be 32x32, please don't use sizes above ~2KB, for bigger icons use url.
    __icon__ = ""
    #: Alternative, link to png icon
    __icon_url__ = ""
    #: Domain name of the service
    __domain__ = ""
    #: Url with general information/support/discussion
    __url__ = ""
    #: Url to term of content, user is accepting these when using the plugin
    __toc_url__ = ""
    #: Url to service (to buy premium) for accounts
    __ref_url__ = ""

    __author__ = tuple()
    __author_mail__ = tuple()


    def __init__(self, core, owner=None):
        self.__name__ = self.__class__.__name__

        #: Core instance
        self.core = core
        #: logging instance
        self.log = core.log
        #: core config
        self.config = core.config
        #: :class:`EventManager`
        self.evm = core.eventManager
        #: :class:`InteractionManager`
        self.im = core.interactionManager
        if owner is not None:
            #: :class:`Api`, user api when user is set
            self.api = self.core.api.withUserContext(owner)
            if not self.api:
                raise Exception("Plugin running with invalid user")

            #: :class:`User`, user related to this plugin
            self.owner = self.api.user
        else:
            self.api = self.core.api
            self.owner = None

        #: last interaction task
        self.task = None

        #: js engine, see `JsEngine`
        self.js = self.core.js

    def __getitem__(self, item):
        """ Retrieves meta data attribute """
        return getattr(self, "__%s__" % item)

    def logInfo(self, *args, **kwargs):
        """ Print args to log at specific level

        :param args: Arbitrary object which should be logged
        :param kwargs: sep=(how to separate arguments), default = " | "
        """
{'fraction_non_alphanumeric': 0.13027405991077118, 'fraction_numerical': 0.004843849585723391, 'mean_word_length': 2.6680691912108463, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7622458', 'n_tokens_mistral': 2202, 'n_tokens_neox': 2081, 'n_words': 800}