<commit_before>__author__ = '<NAME>'
__license__ = 'MIT'
__contact__ = 'https://github.com/kharkevich'

from __future__ import print_function
from __future__ import absolute_import
from .base import Provider as BaseProvider
import json

def ProviderParser(subparser):
    subparser.add_argument("--auth-token", help="specify PDD token (https://tech.yandex.com/domain/doc/concepts/access-docpage/)")

class Provider(BaseProvider):

    def __init__(self, options, provider_options={}):
        super(Provider, self).__init__(options)
        self.domain_id = None
        self.api_endpoint = provider_options.get('api_endpoint') or 'https://pddimp.yandex.ru/api2/admin/dns'

    def authenticate(self):
        payload = self._get('/list?domain={0}'.format(self.options['domain']))
        if payload['success'] != "ok":
            raise Exception('No domain found')
        self.domain_id = self.options['domain']

    def create_record(self, type, name, content):
        if (type == 'CNAME') or (type == 'MX') or (type == 'NS'):
            content = content.rstrip('.') + '.' # make sure a the data is always a FQDN for CNAMe.

        querystring = 'domain={0}&type={1}&subdomain={2}&content={3}'.format(self.domain_id, type, self._relative_name(name), content)
        if self.options.get('ttl'):
            querystring += "&ttl={0}".format(self.options.get('ttl'))

        payload = self._post('/add', {},querystring)

        return self._check_exitcode(payload, 'create_record')
<commit_msg>accidently removed import while adding python 3.x support.<commit_after>from __future__ import print_function
from __future__ import absolute_import
from .base import Provider as BaseProvider
import requests
import json
__author__ = '<NAME>'
__license__ = 'MIT'
__contact__ = 'https://github.com/kharkevich'

def ProviderParser(subparser):
    subparser.add_argument("--auth-token", help="specify PDD token (https://tech.yandex.com/domain/doc/concepts/access-docpage/)")

class Provider(BaseProvider):

    def __init__(self, options, provider_options={}):
        super(Provider, self).__init__(options)
        self.domain_id = None
        self.api_endpoint = provider_options.get('api_endpoint') or 'https://pddimp.yandex.ru/api2/admin/dns'

    def authenticate(self):
        payload = self._get('/list?domain={0}'.format(self.options['domain']))
        if payload['success'] != "ok":
            raise Exception('No domain found')
        self.domain_id = self.options['domain']

    def create_record(self, type, name, content):
        if (type == 'CNAME') or (type == 'MX') or (type == 'NS'):
            content = content.rstrip('.') + '.' # make sure a the data is always a FQDN for CNAMe.

        querystring = 'domain={0}&type={1}&subdomain={2}&content={3}'.format(self.domain_id, type, self._relative_name(name), content)
        if self.options.get('ttl'):
            querystring += "&ttl={0}".format(self.options.get('ttl'))

        payload = self._post('/add', {},querystring)

        return self._check_exitcode(payload, 'create_record')

{'fraction_non_alphanumeric': 0.15274151436031333, 'fraction_numerical': 0.00489556135770235, 'mean_word_length': 3.7667185069984446, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, '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': '3715132', 'n_tokens_mistral': 961, 'n_tokens_neox': 930, 'n_words': 205}