<commit_before># -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from oslo_log import log
from six.moves.urllib.parse import quote

try:
    from swiftclient import client as swclient
    from swiftclient import utils as swift_utils
except ImportError:
    swclient = None
    swift_utils = None

from gnocchi import storage

LOG = log.getLogger(__name__)


def get_connection(conf):
    if swclient is None:
        raise RuntimeError("python-swiftclient unavailable")
    return swclient.Connection(
        auth_version=conf.swift_auth_version,
        authurl=conf.swift_authurl,
        preauthtoken=conf.swift_preauthtoken,
        user=conf.swift_user,
        key=conf.swift_key,
        tenant_name=conf.swift_project_name,
        timeout=conf.swift_timeout,
        os_options={'endpoint_type': conf.swift_endpoint_type,
                    'user_domain_name': conf.swift_user_domain_name},
        retries=0)


POST_HEADERS = {'Accept': 'application/json', 'Content-Type': 'text/plain'}


def bulk_delete(conn, container, objects):
    objects = [quote(('/%s/%s' % (container, obj['name'])).encode('utf-8'))<commit_msg>swift: make sure to retry if the client cannot find Swift<commit_after># -*- encoding: utf-8 -*-
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.


from oslo_log import log
from six.moves.urllib.parse import quote

try:
    from swiftclient import client as swclient
    from swiftclient import utils as swift_utils
except ImportError:
    swclient = None
    swift_utils = None

from gnocchi import storage
from gnocchi import utils

LOG = log.getLogger(__name__)


@utils.retry
def _get_connection(conf):
    return swclient.Connection(
        auth_version=conf.swift_auth_version,
        authurl=conf.swift_authurl,
        preauthtoken=conf.swift_preauthtoken,
        user=conf.swift_user,
        key=conf.swift_key,
        tenant_name=conf.swift_project_name,
        timeout=conf.swift_timeout,
        os_options={'endpoint_type': conf.swift_endpoint_type,
                    'user_domain_name': conf.swift_user_domain_name},
        retries=0)


def get_connection(conf):
    if swclient is None:
        raise RuntimeError("python-swiftclient unavailable")

    return _get_connection(conf)


POST_HEADERS = {'Accept': 'application/json', 'Content-Type': 'text/plain'}


def bulk_delete(conn, container, objects):
    objects = [quote(('/%s/%s' % (container, obj['name'])).encode('utf-8'))
{'fraction_non_alphanumeric': 0.0913823019086177, 'fraction_numerical': 0.004048582995951417, 'mean_word_length': 3.7254098360655736, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3494124', 'n_tokens_mistral': 1012, 'n_tokens_neox': 981, 'n_words': 319}