<commit_before>import os
from netrc import netrc, NetrcParseError
import logging
from flexget.plugin import *
from flexget import validator

log = logging.getLogger('transmission')


class PluginTransmissionrpc:
    """
      Add url from entry url to transmission

      Example:

      transmissionrpc:
        host: localhost
        port: 9091
        netrc: /home/flexget/.tmnetrc
        username: myusername
        password: <PASSWORD>
        path: the download location
        removewhendone: yes

    Default values for the config elements:

    transmissionrpc:
        host: localhost
        port: 9091
        enabled: yes
        removewhendone: no
    """

    def validator(self):
        """Return config validator"""
        root = validator.factory()
        advanced = root.accept('dict')
        advanced.accept('text', key='host')
        advanced.accept('number', key='port')
        # note that password is optional in transmission
        advanced.accept('file', key='netrc', required=False)
        advanced.accept('text', key='username', required=False)
        advanced.accept('text', key='password', required=False)
        advanced.accept('path', key='path', required=False)
        advanced.accept('boolean', key='addpaused', required=False)
        advanced.accept('number', key='maxconnections', required=False)
        advanced.accept('number', key='maxupspeed', required=False)
        advanced.accept('number', key='maxdownspeed', required=False)
        advanced.accept('decimal', key='ratio', required=False)
        advanced.accept('boolean', key='enabled')
        advanced.accept('boolean', key='removewhendone')
        return root

    def get_config(self, feed):
        config = feed.config['transmissionrpc']
        if isinstance(config, bool):
            config = {'enabled': config}
        config.setdefault('enabled', True)<commit_msg>allow config format for transmissionrpc with all default options<commit_after>import os
from netrc import netrc, NetrcParseError
import logging
from flexget.plugin import *
from flexget import validator

log = logging.getLogger('transmission')


class PluginTransmissionrpc:
    """
      Add url from entry url to transmission

      Example:

      transmissionrpc:
        host: localhost
        port: 9091
        netrc: /home/flexget/.tmnetrc
        username: myusername
        password: <PASSWORD>
        path: the download location
        removewhendone: yes

    Default values for the config elements:

    transmissionrpc:
        host: localhost
        port: 9091
        enabled: yes
        removewhendone: no
    """

    def validator(self):
        """Return config validator"""
        root = validator.factory()
        root.accept('boolean')
        advanced = root.accept('dict')
        advanced.accept('text', key='host')
        advanced.accept('number', key='port')
        # note that password is optional in transmission
        advanced.accept('file', key='netrc', required=False)
        advanced.accept('text', key='username', required=False)
        advanced.accept('text', key='password', required=False)
        advanced.accept('path', key='path', required=False)
        advanced.accept('boolean', key='addpaused', required=False)
        advanced.accept('number', key='maxconnections', required=False)
        advanced.accept('number', key='maxupspeed', required=False)
        advanced.accept('number', key='maxdownspeed', required=False)
        advanced.accept('decimal', key='ratio', required=False)
        advanced.accept('boolean', key='enabled')
        advanced.accept('boolean', key='removewhendone')
        return root

    def get_config(self, feed):
        config = feed.config['transmissionrpc']
        if isinstance(config, bool):
            config = {'enabled': config}
        config.setdefault('enabled', True)
{'fraction_non_alphanumeric': 0.11574313827032626, 'fraction_numerical': 0.004142931123770067, 'mean_word_length': 2.9783728115345007, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5616625', 'n_tokens_mistral': 1016, 'n_tokens_neox': 978, 'n_words': 260}