<commit_before># Copyright (c) 2010-2011 OpenStack, LLC.
#
# 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.

import collections
from urllib import unquote
import copy

# conditionalize the return_ips method based on whether or not iptools
# is present in the system. Without iptools, you will lack CIDR support.
try:
    from iptools import IpRangeList
    CIDR_support = True

    def return_ips(conf, conf_tag):
        return IpRangeList(*[x.strip() for x in
            conf.get(conf_tag, '').split(',') if x.strip()])
    def sanitize_ips(line_data):
        for x in ['lb_ip', 'client_ip', 'log_source']:
            if line_data[x] == '-':
                line_data[x] = '0.0.0.0'
except ImportError:
    CIDR_support = False

    def return_ips(conf, conf_tag):
        return ([x.strip() for x in conf.get(conf_tag, '').split(',')
            if x.strip()])

from swift.common.utils import split_path, get_logger

month_map = '_ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split()
LISTING_PARAMS = set(
                'path limit format delimiter marker end_marker prefix'.split())


class AccessLogProcessor(object):<commit_msg>vastly improvee the speed of the access_processor's main process method by returning dict's instead of lists from IPTools. This turns a very nasty O(n)*3 into O(1)*3 .. much nicer. All tests pass.<commit_after># Copyright (c) 2010-2011 OpenStack, LLC.
#
# 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.

import collections
from urllib import unquote
import copy

# conditionalize the return_ips method based on whether or not iptools
# is present in the system. Without iptools, you will lack CIDR support.
try:
    from iptools import IpRangeList
    CIDR_support = True

    def return_ips(conf, conf_tag):
        return dict((k, 1) for k in
                    IpRangeList(*[x.strip() for x in
                    conf.get(conf_tag, '').split(',') if x.strip()]))
    def sanitize_ips(line_data):
        for x in ['lb_ip', 'client_ip', 'log_source']:
            if line_data[x] == '-':
                line_data[x] = '0.0.0.0'
except ImportError:
    CIDR_support = False

    def return_ips(conf, conf_tag):
        return ([x.strip() for x in conf.get(conf_tag, '').split(',')
            if x.strip()])

from swift.common.utils import split_path, get_logger

month_map = '_ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split()
LISTING_PARAMS = set(
                'path limit format delimiter marker end_marker prefix'.split())


class AccessLogProcessor(object):
{'fraction_non_alphanumeric': 0.0950754341019072, 'fraction_numerical': 0.010247651579846286, 'mean_word_length': 3.3275862068965516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '4012275', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1013, 'n_words': 414}