<commit_before>"""
tictail.client
~~~~~~~~~~~~~~

"""

import copy

from .transport import RequestsHttpTransport
from .resource import (Followers,
                       Cards,
                       Customers,
                       Products,
                       Orders,
                       Stores,
                       Themes,
                       Me)


# API version supported by these bindings.
VERSION = 1

# Default HTTP protocol to use.
DEFAULT_PROTOCOL = 'https'

# Base API URL.
BASE = 'api.tictail.com'

# Whether `requests` should verify SSL certificates.
VERIFY_SSL_CERTS = True

# Default socket timeout.
DEFAULT_TIMEOUT = 20

# Defauly applied configuration.
DEFAULT_CONFIG = {
    'version': VERSION,
    'protocol': DEFAULT_PROTOCOL,
    'base': BASE,
    'verify_ssl_certs': VERIFY_SSL_CERTS,
    'timeout': DEFAULT_TIMEOUT
}


class Client(object):

    def __init__(self, access_token, config=None, transport=None):
        self.access_token = access_token
        self.config = self._make_config(config)

        if transport is None:
            transport = self._make_transport()

        self.transport = transport

    def _make_config(self, config_override):
        config = copy.deepcopy(DEFAULT_CONFIG)
        if config_override:
            config.update(config_override)
        return config

    def _make_transport(self):
        return RequestsHttpTransport(self.access_token, self.config)

    def _make_shortcut(self, resource_cls, store_id):
        if store_id is None:
            raise ValueError('`store_id` cannot be None')
        prefix = "{}/{}".format(Stores.endpoint, store_id)
        return resource_cls(self.transport, prefix=prefix)

    # ====== Root Endpoints ====== #

    def me(self):
        """Alias for getting the store for which the access token you are using
        is valid.

        >>> tt = Tictail('token')
        >>> tt.me()
        {...}

        """
        return Me(self.transport).get()

    @property
    def stores(self):
        return Stores(self.transport)

    # ====== Shortcuts ======= #

    def followers(self, store=None):
        return self._make_shortcut(Followers, store)

    def cards(self, store=None):
        return self._make_shortcut(Cards, store)

    def customers(self, store=None):
        return self._make_shortcut(Customers, store)

    def products(self, store=None):
        return self._make_shortcut(Products, store)

    def orders(self, store=None):
        return self._make_shortcut(Orders, store)

    def theme(self, store=None):
        return self._make_shortcut(Themes, store)<commit_msg>Shortcut docstrings<commit_after>"""
tictail.client
~~~~~~~~~~~~~~

"""

import copy

from .transport import RequestsHttpTransport
from .resource import (Followers,
                       Cards,
                       Customers,
                       Products,
                       Orders,
                       Stores,
                       Themes,
                       Me)


# API version supported by these bindings.
VERSION = 1

# Default HTTP protocol to use.
DEFAULT_PROTOCOL = 'https'

# Base API URL.
BASE = 'api.tictail.com'

# Whether `requests` should verify SSL certificates.
VERIFY_SSL_CERTS = True

# Default socket timeout.
DEFAULT_TIMEOUT = 20

# Defauly applied configuration.
DEFAULT_CONFIG = {
    'version': VERSION,
    'protocol': DEFAULT_PROTOCOL,
    'base': BASE,
    'verify_ssl_certs': VERIFY_SSL_CERTS,
    'timeout': DEFAULT_TIMEOUT
}


class Client(object):

    def __init__(self, access_token, config=None, transport=None):
        self.access_token = access_token
        self.config = self._make_config(config)

        if transport is None:
            transport = self._make_transport()

        self.transport = transport

    def _make_config(self, config_override):
        config = copy.deepcopy(DEFAULT_CONFIG)
        if config_override:
            config.update(config_override)
        return config

    def _make_transport(self):
        return RequestsHttpTransport(self.access_token, self.config)

    def _make_shortcut(self, resource_cls, store_id):
        if store_id is None:
            raise ValueError('`store_id` cannot be None')
        prefix = "{}/{}".format(Stores.endpoint, store_id)
        return resource_cls(self.transport, prefix=prefix)

    # ====== Root Endpoints ====== #

    def me(self):
        """Alias for getting the store for which the access token you are using
        is valid.

        >>> tt = Tictail('token')
        >>> tt.me()
        {...}

        """
        return Me(self.transport).get()

    @property
    def stores(self):
        return Stores(self.transport)

    # ====== Shortcuts ======= #

    def followers(self, store=None):
        """Returns a `Followers` resource.

        :param store: A store id.

        """
        return self._make_shortcut(Followers, store)

    def cards(self, store=None):
        """Returns a `Card` resource.

        :param store: A store id.

        """
        return self._make_shortcut(Cards, store)

    def customers(self, store=None):
        """Returns a `Customers` resource.

        :param store: A store id.

        """
        return self._make_shortcut(Customers, store)

    def products(self, store=None):
        """Returns a `Products` resource.

        :param store: A store id.

        """
        return self._make_shortcut(Products, store)

    def orders(self, store=None):
        """Returns an `Orders` resource.

        :param store: A store id.

        """
        return self._make_shortcut(Orders, store)

    def theme(self, store=None):
        """Returns a `Themes` resource.

        :param store: A store id.

        """
        return self._make_shortcut(Themes, store)
{'fraction_non_alphanumeric': 0.11020620343094785, 'fraction_numerical': 0.0010396811644429042, 'mean_word_length': 2.2832764505119454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6841690', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1610, 'n_words': 426}