<commit_before>#
# Copyright (c) 2014 NSONE, Inc.
#
# License under The MIT License (MIT). See LICENSE in project root.

import sys
import collections

from . import resource


py_str = str if sys.version_info[0] == 3 else basestring


class Records(resource.BaseResource):

    ROOT = 'zones'

    INT_FIELDS = ['ttl']
    BOOL_FIELDS = ['use_csubnet']
    PASSTHRU_FIELDS = ['networks', 'meta', 'regions', 'link']

    # answers must be:
    #  1) a single string
    #     we coerce to a single answer with no other fields e.g. meta
    #  2) an iterable of single strings
    #     we coerce to several answers with no other fields e.g. meta
    #  3) an iterable of iterables
    #     we have as many answers as are in the outer iterable, and the
    #     answers themselves are used verbatim from the inner iterable (e.g. may
    #     have MX style [10, '1.1.1.1']), but no other fields e.g. meta
    #     you must use this form for MX records, and if there is only one
    #     answer it still must be wrapped in an outer iterable
    #  4) an iterable of dicts
    #     we assume the full rest model and pass it in unchanged. must use this
    #     form for any advanced record config like meta data or data feeds
    def _getAnswersForBody(self, answers):
        realAnswers = []
        # simplest: they specify a single string ip
        if isinstance(answers, py_str):
            answers = [answers]<commit_msg>Add optional override_ttl field for ALIAS records<commit_after>#
# Copyright (c) 2014 NSONE, Inc.
#
# License under The MIT License (MIT). See LICENSE in project root.

import sys
import collections

from . import resource


py_str = str if sys.version_info[0] == 3 else basestring


class Records(resource.BaseResource):

    ROOT = 'zones'

    INT_FIELDS = ['ttl']
    BOOL_FIELDS = ['use_csubnet', 'override_ttl']
    PASSTHRU_FIELDS = ['networks', 'meta', 'regions', 'link']

    # answers must be:
    #  1) a single string
    #     we coerce to a single answer with no other fields e.g. meta
    #  2) an iterable of single strings
    #     we coerce to several answers with no other fields e.g. meta
    #  3) an iterable of iterables
    #     we have as many answers as are in the outer iterable, and the
    #     answers themselves are used verbatim from the inner iterable (e.g. may
    #     have MX style [10, '1.1.1.1']), but no other fields e.g. meta
    #     you must use this form for MX records, and if there is only one
    #     answer it still must be wrapped in an outer iterable
    #  4) an iterable of dicts
    #     we assume the full rest model and pass it in unchanged. must use this
    #     form for any advanced record config like meta data or data feeds
    def _getAnswersForBody(self, answers):
        realAnswers = []
        # simplest: they specify a single string ip
        if isinstance(answers, py_str):
            answers = [answers]
{'fraction_non_alphanumeric': 0.07647462277091907, 'fraction_numerical': 0.010973936899862825, 'mean_word_length': 2.63715710723192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3355157', 'n_tokens_mistral': 921, 'n_tokens_neox': 870, 'n_words': 388}