<commit_before>import json
from .util import convert_dict

__author__ = '<NAME> <<EMAIL>>'


class BitcodinObject(dict):

    def __init__(self, dictionary, convert=False):
        """
        Converts all dictionaries to BitcodinObject objects.
        """
        super(BitcodinObject, self).__init__()
        if convert:
            self.__dict__.update(convert_dict(dictionary))
        else:
            self.__dict__.update(dictionary)

        self.to_object(convert)

    def to_object(self, convert=False):
        for k, v in self.__dict__.items():
            if isinstance(v, dict):
                self.__dict__[k] = BitcodinObject(v, convert)

            elif isinstance(v, list):
                index = 0
                for d in v:
                    if isinstance(d, dict):
                        v[index] = BitcodinObject(d, convert)
                    else:
                        v[index] = d
                    index += 1
                del index
                self.__dict__[k] = v

            else:
                self.__dict__[k] = v

    def to_dict(self):
        for k, v in self.__dict__.items():
            if isinstance(v, BitcodinObject):
                setattr(self, k, v.to_dict())

            elif isinstance(v, list):
                index = 0
                for d in v:
                    if isinstance(d, BitcodinObject):
                        v[index] = d.to_dict()
                    index += 1
                del index

        return self.__dict__

    def to_json(self):
        json_string = json.dumps(self.to_dict())
        self.to_object()
        return json_string

    def __getattr__(self, name):
        if name in self:
            return self[name]
        else:
            raise AttributeError('No such attribute: %s' % name)

    def __delattr__(self, name):
        if name in self:
            del self[name]
        else:
            raise AttributeError('No such attribute: ' + name)


class Input(BitcodinObject):

    def __init__(self, url=None, skip_analysis=False):
        """
        :param url: string: Url to the source
        :param skip_analysis: boolean: Skip analysis of video
        :return: Input
        """
        self.type = 'url'
        self.url = url
        self.skipAnalysis = skip_analysis

        super(Input, self).__init__(self.to_dict())


class S3Input(BitcodinObject):

    def __init__(self, access_key, secret_key, bucket, region, object_key, host=None, skip_analysis=False):
        """

        :param access_key: AWS Access Key ID
        :param secret_key: AWS Secret Key
        :param bucket: AWS Bucket Name
        :param region: AWS Region
        :param object_key: Path to object/file
        :param host: AWS Host (optional)
        :param skip_analysis: boolean: Skip analysis of video
        :return: S3Input
        """

        self.type = 's3'

        if host is not None:
            self.host = host
        self.accessKey = access_key
        self.secretKey = secret_key
        self.bucket = bucket
        self.region = region
        self.objectKey = object_key
        self.skipAnalysis = skip_analysis

        super(S3Input, self).__init__(self.to_dict())


class AzureInput(BitcodinObject):

    def __init__(self, account_name, account_key, container, url, skip_analysis=False):
        """

        :param account_name: Azure Account Name
        :param account_key: Azure Account Key
        :param container: Container Name
        :param url: URL to file/object
        :param skip_analysis: boolean: Skip analysis of video
        :return: AzureInput
        """

        self.type = 'abs'
        self.accountName = account_name
        self.accountKey = account_key
        self.container = container
        self.url = url
        self.skipAnalysis = skip_analysis

        super(AzureInput, self).__init__(self.to_dict())


class Job(BitcodinObject):

    def __init__(self, input_id, encoding_profile_id, manifest_types, speed=None, drm_config=None,
                 hls_encryption_config=None, extract_closed_captions=False, audio_meta_data=None, video_meta_data=None,
                 location=None, output_id=None, deinterlace=None, merge_audio_channel_configs=None, duration=None,
                 start_time=None):
        self.inputId = input_id
        self.encodingProfileId = encoding_profile_id
        self.manifestTypes = manifest_types
        self.extract_closed_captions = extract_closed_captions

        if speed is not None:
            self.speed = speed
        if drm_config is not None:
            self.drmConfig = drm_config
        if hls_encryption_config is not None:
            self.hlsEncryptionConfig = hls_encryption_config
        if audio_meta_data is not None:
            self.audioMetaData = audio_meta_data
        if video_meta_data is not None:
            self.videoMetaData = video_meta_data
        if location is not None:
            self.location = location
        if output_id is not None:
            self.outputId = output_id
        if deinterlace is not None:
            self.deinterlace = deinterlace<commit_msg>Fixed wrong job attribute extract_closed_captions, has to be camelCase<commit_after>import json
from .util import convert_dict

__author__ = '<NAME> <<EMAIL>>'


class BitcodinObject(dict):

    def __init__(self, dictionary, convert=False):
        """
        Converts all dictionaries to BitcodinObject objects.
        """
        super(BitcodinObject, self).__init__()
        if convert:
            self.__dict__.update(convert_dict(dictionary))
        else:
            self.__dict__.update(dictionary)

        self.to_object(convert)

    def to_object(self, convert=False):
        for k, v in self.__dict__.items():
            if isinstance(v, dict):
                self.__dict__[k] = BitcodinObject(v, convert)

            elif isinstance(v, list):
                index = 0
                for d in v:
                    if isinstance(d, dict):
                        v[index] = BitcodinObject(d, convert)
                    else:
                        v[index] = d
                    index += 1
                del index
                self.__dict__[k] = v

            else:
                self.__dict__[k] = v

    def to_dict(self):
        for k, v in self.__dict__.items():
            if isinstance(v, BitcodinObject):
                setattr(self, k, v.to_dict())

            elif isinstance(v, list):
                index = 0
                for d in v:
                    if isinstance(d, BitcodinObject):
                        v[index] = d.to_dict()
                    index += 1
                del index

        return self.__dict__

    def to_json(self):
        json_string = json.dumps(self.to_dict())
        self.to_object()
        return json_string

    def __getattr__(self, name):
        if name in self:
            return self[name]
        else:
            raise AttributeError('No such attribute: %s' % name)

    def __delattr__(self, name):
        if name in self:
            del self[name]
        else:
            raise AttributeError('No such attribute: ' + name)


class Input(BitcodinObject):

    def __init__(self, url=None, skip_analysis=False):
        """
        :param url: string: Url to the source
        :param skip_analysis: boolean: Skip analysis of video
        :return: Input
        """
        self.type = 'url'
        self.url = url
        self.skipAnalysis = skip_analysis

        super(Input, self).__init__(self.to_dict())


class S3Input(BitcodinObject):

    def __init__(self, access_key, secret_key, bucket, region, object_key, host=None, skip_analysis=False):
        """

        :param access_key: AWS Access Key ID
        :param secret_key: AWS Secret Key
        :param bucket: AWS Bucket Name
        :param region: AWS Region
        :param object_key: Path to object/file
        :param host: AWS Host (optional)
        :param skip_analysis: boolean: Skip analysis of video
        :return: S3Input
        """

        self.type = 's3'

        if host is not None:
            self.host = host
        self.accessKey = access_key
        self.secretKey = secret_key
        self.bucket = bucket
        self.region = region
        self.objectKey = object_key
        self.skipAnalysis = skip_analysis

        super(S3Input, self).__init__(self.to_dict())


class AzureInput(BitcodinObject):

    def __init__(self, account_name, account_key, container, url, skip_analysis=False):
        """

        :param account_name: Azure Account Name
        :param account_key: Azure Account Key
        :param container: Container Name
        :param url: URL to file/object
        :param skip_analysis: boolean: Skip analysis of video
        :return: AzureInput
        """

        self.type = 'abs'
        self.accountName = account_name
        self.accountKey = account_key
        self.container = container
        self.url = url
        self.skipAnalysis = skip_analysis

        super(AzureInput, self).__init__(self.to_dict())


class Job(BitcodinObject):

    def __init__(self, input_id, encoding_profile_id, manifest_types, speed=None, drm_config=None,
                 hls_encryption_config=None, extract_closed_captions=False, audio_meta_data=None, video_meta_data=None,
                 location=None, output_id=None, deinterlace=None, merge_audio_channel_configs=None, duration=None,
                 start_time=None):
        self.inputId = input_id
        self.encodingProfileId = encoding_profile_id
        self.manifestTypes = manifest_types
        self.extractClosedCaptions = extract_closed_captions

        if speed is not None:
            self.speed = speed
        if drm_config is not None:
            self.drmConfig = drm_config
        if hls_encryption_config is not None:
            self.hlsEncryptionConfig = hls_encryption_config
        if audio_meta_data is not None:
            self.audioMetaData = audio_meta_data
        if video_meta_data is not None:
            self.videoMetaData = video_meta_data
        if location is not None:
            self.location = location
        if output_id is not None:
            self.outputId = output_id
        if deinterlace is not None:
            self.deinterlace = deinterlace
{'fraction_non_alphanumeric': 0.08046200135882753, 'fraction_numerical': 0.0015529457439580705, 'mean_word_length': 1.91815349759275, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '72343', 'n_tokens_mistral': 2900, 'n_tokens_neox': 2783, 'n_words': 763}