<commit_before># -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2016 Red Hat, Inc
#
# 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 __future__ import unicode_literals
from six.moves.urllib.parse import urlparse

import collections
import dci.common.exceptions as exceptions
import dci.common.utils as utils
import dci.db.models as models
import six
import voluptuous as v


# Url validator is not powerfull enough let unleash its power
@v.message('expected a URL', cls=v.UrlInvalid)
def Url(value):
    try:
        parsed = urlparse(value)
        if not parsed.scheme or not parsed.netloc:
            raise v.UrlInvalid("must have a URL scheme and host")
        return value
    except Exception:
        raise ValueError

VALID_STATUS_UPDATE = ['success', 'failure']

INVALID_LIST = 'not a valid list'
INVALID_UUID = 'not a valid uuid'
INVALID_JSON = 'not a valid json'
INVALID_STRING = 'not a valid string'
INVALID_URL = 'not a valid URL'
INVALID_PRIORITY = 'not a valid priority integer (must be beetween 0 and 1000)'

INVALID_TEAM = 'not a valid team id'
INVALID_TEST = 'not a valid test id'
INVALID_TOPIC = 'not a valid topic id'
INVALID_JOB_DEFINITION = 'not a valid jobdefinition id'
INVALID_REMOTE_CI = 'not a valid remoteci id'
INVALID_JOB = 'not a valid job id'
INVALID_JOB_STATE = 'not a valid jobstate id'
INVALID_ROLE = ('not a valid role (must be %s)' %
                ' or '.join(models.USER_ROLES))
INVALID_OFFSET = 'not a valid offset integer (must be greater than 0)'
INVALID_LIMIT = 'not a valid limit integer (must be greater than 0)'

INVALID_REQUIRED = 'required key not provided'
INVALID_OBJECT = 'not a valid object'<commit_msg>job status update: Accept all status<commit_after># -*- coding: utf-8 -*-
#
# Copyright (C) 2015-2016 Red Hat, Inc
#
# 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 __future__ import unicode_literals
from six.moves.urllib.parse import urlparse

import collections
import dci.common.exceptions as exceptions
import dci.common.utils as utils
import dci.db.models as models
import six
import voluptuous as v


# Url validator is not powerfull enough let unleash its power
@v.message('expected a URL', cls=v.UrlInvalid)
def Url(value):
    try:
        parsed = urlparse(value)
        if not parsed.scheme or not parsed.netloc:
            raise v.UrlInvalid("must have a URL scheme and host")
        return value
    except Exception:
        raise ValueError

VALID_STATUS_UPDATE = ['failure', 'success', 'killed']

INVALID_LIST = 'not a valid list'
INVALID_UUID = 'not a valid uuid'
INVALID_JSON = 'not a valid json'
INVALID_STRING = 'not a valid string'
INVALID_URL = 'not a valid URL'
INVALID_PRIORITY = 'not a valid priority integer (must be beetween 0 and 1000)'

INVALID_TEAM = 'not a valid team id'
INVALID_TEST = 'not a valid test id'
INVALID_TOPIC = 'not a valid topic id'
INVALID_JOB_DEFINITION = 'not a valid jobdefinition id'
INVALID_REMOTE_CI = 'not a valid remoteci id'
INVALID_JOB = 'not a valid job id'
INVALID_JOB_STATE = 'not a valid jobstate id'
INVALID_ROLE = ('not a valid role (must be %s)' %
                ' or '.join(models.USER_ROLES))
INVALID_OFFSET = 'not a valid offset integer (must be greater than 0)'
INVALID_LIMIT = 'not a valid limit integer (must be greater than 0)'

INVALID_REQUIRED = 'required key not provided'
INVALID_OBJECT = 'not a valid object'
{'fraction_non_alphanumeric': 0.07885635231727, 'fraction_numerical': 0.009222965183306432, 'mean_word_length': 4.061843640606768, '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': '1738850', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1256, 'n_words': 561}