<commit_before># Copyright 2014 <NAME>

#    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.

#    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 config
from datetime import datetime
from utils import datetime_iso_format


class Creator(object):

    """Creator enity.
        Fields:
        name: creator's name/identifier
    """

    def __init__(self, name):
        super(Creator, self).__init__()
        self.name = name

    def __eq__(self, other):
        return self.name == other.name


class Organization(Creator):

    """Organization entity.
        Fields:
        name: Org's name/identifier. Mandatory. Type: str.
        email: Org's email address. Optional. Type: str.
    """

    def __init__(self, name, email):
        super(Organization, self).__init__(name)
        self.email = email

    def __eq__(self, other):
        if type(other) is not Organization:
            return False
        else:
            return (self.name + self.email) == (other.name + other.email)


class Person(Creator):

    """Person entity.
        Fields:
        name: person's name/identifier. Mandatory. Type: str.
        email: person's email address. Optional. Type: str.
    """

    def __init__(self, name, email):
        super(Person, self).__init__(name)
        self.email = email

    def __eq__(self, other):
        if type(other) is not Person:
            return False
        else:
            return (self.name + self.email) == (other.name + other.email)


class Tool(Creator):

    """Tool entity.
        Fields: 
        name: tool identifier, with version. Type: str.
    """

    def __init__(self, name):
        super(Tool, self).__init__(name)


class CreationInfo(object):

    """Represents a document's creation info.
        Fields:
        creators: List of creators. At least one required. 
            Type: Creator.
        comment: Creation comment, optional. Type: str.
        license_list_version: version of SPDX license used in creation of SPDX
            document. One, optional. Type: spdx.version.Version
        created: Creation date. Mandatory one. Type: datetime.
    """

    def __init__(self, created=None, comment=None,
                 license_list_version=config.LICENSE_LIST_VERSION):
        super(CreationInfo, self).__init__()
        self.creators = []
        self.created = created
        self.comment = comment
        self.license_list_version = license_list_version

    def add_creator(self, creator):
        self.creators.append(creator)

    def remove_creator(self, creator):
        self.creators.remove(creator)

    def set_created_now(self):
        self.created = datetime.utcnow()

    @property
    def created_iso_format(self):
        return datetime_iso_format(self.created)

    def validate(self, messages):
        """Returns True if the fields are valid according to the SPDX standard.
        Appends user friendly messages to the messages parameter.
        """
        return (self.validate_creators(messages) &
                self.validate_created(messages))

    def validate_creators(self, messages):
        if len(self.creators) != 0:
            return True
        else:
            messages.append('No creators defined, must have at least one.')
            return False

    def validate_created(self, messages):
        if self.created is not None:
            return True
        else:
            messages.append('Creation info missing created date.')
            return False<commit_msg>Adds to_value functions to Creator classes<commit_after># Copyright 2014 <NAME>

#    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.

#    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 config
from datetime import datetime
from utils import datetime_iso_format


class Creator(object):

    """Creator enity.
        Fields:
        name: creator's name/identifier
    """

    def __init__(self, name):
        super(Creator, self).__init__()
        self.name = name

    def __eq__(self, other):
        return self.name == other.name



class Organization(Creator):

    """Organization entity.
        Fields:
        name: Org's name/identifier. Mandatory. Type: str.
        email: Org's email address. Optional. Type: str.
    """

    def __init__(self, name, email):
        super(Organization, self).__init__(name)
        self.email = email

    def __eq__(self, other):
        if type(other) is not Organization:
            return False
        else:
            return (self.name + self.email) == (other.name + other.email)

    def to_value(self):
        """Tag/value representation of Organization entity."""
        if self.email is not None:
            return 'Organization : {0} ({1})'.format(self.name, self.email)
        else:
            return 'Organization: {0}'.format(self.name)


class Person(Creator):

    """Person entity.
        Fields:
        name: person's name/identifier. Mandatory. Type: str.
        email: person's email address. Optional. Type: str.
    """

    def __init__(self, name, email):
        super(Person, self).__init__(name)
        self.email = email

    def __eq__(self, other):
        if type(other) is not Person:
            return False
        else:
            return (self.name + self.email) == (other.name + other.email)

    def to_value(self):
        """Tag/value representation of Person entity."""
        if self.email is not None:
            return 'Person : {0} ({1})'.format(self.name, self.email)
        else:
            return 'Person: {0}'.format(self.name)

class Tool(Creator):

    """Tool entity.
        Fields: 
        name: tool identifier, with version. Type: str.
    """

    def __init__(self, name):
        super(Tool, self).__init__(name)

    def to_value(self):
        """Tag/value representation of Tool entity."""
        return 'Tool: {0}'.format(self.name)


class CreationInfo(object):

    """Represents a document's creation info.
        Fields:
        creators: List of creators. At least one required. 
            Type: Creator.
        comment: Creation comment, optional. Type: str.
        license_list_version: version of SPDX license used in creation of SPDX
            document. One, optional. Type: spdx.version.Version
        created: Creation date. Mandatory one. Type: datetime.
    """

    def __init__(self, created=None, comment=None,
                 license_list_version=config.LICENSE_LIST_VERSION):
        super(CreationInfo, self).__init__()
        self.creators = []
        self.created = created
        self.comment = comment
        self.license_list_version = license_list_version

    def add_creator(self, creator):
        self.creators.append(creator)

    def remove_creator(self, creator):
        self.creators.remove(creator)

    def set_created_now(self):
        self.created = datetime.utcnow()

    @property
    def created_iso_format(self):
        return datetime_iso_format(self.created)

    def has_comment(self):
        return self.comment is not None

    def validate(self, messages):
        """Returns True if the fields are valid according to the SPDX standard.
        Appends user friendly messages to the messages parameter.
        """
        return (self.validate_creators(messages) &
                self.validate_created(messages))

    def validate_creators(self, messages):
        if len(self.creators) != 0:
            return True
        else:
            messages.append('No creators defined, must have at least one.')
            return False

    def validate_created(self, messages):
        if self.created is not None:
            return True
        else:
            messages.append('Creation info missing created date.')
            return False
{'fraction_non_alphanumeric': 0.09359151682803135, 'fraction_numerical': 0.0026509912402028586, 'mean_word_length': 2.3762645914396887, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5070341', 'n_tokens_mistral': 2392, 'n_tokens_neox': 2290, 'n_words': 771}