<commit_before>#
# Copyright (c) 2017 by QA Cafe.
# All Rights Reserved.
#

"""Module for accessing CDRouter Captures."""

import io

from requests_toolbelt.downloadutils import stream
from marshmallow import Schema, post_load
from marshmallow import fields as mfields

class Section(object):
    """Model for CDRouter Capture Sections.

    :param value: (optional) Section value as a string.
    """
    def __init__(self, **kwargs):
        self.value = kwargs.get('value', None)

class SectionSchema(Schema):
    value = mfields.Str()

    @post_load
    def post_load(self, data):
        return Section(**data)

class Structure(object):
    """Model for CDRouter Capture Structures.

    :param sections: (optional) :class:`captures.Section <captures.Section>` list
    """
    def __init__(self, **kwargs):
        self.sections = kwargs.get('sections', None)

class StructureSchema(Schema):
    sections = mfields.Nested(SectionSchema, many=True)

    @post_load
    def post_load(self, data):
        return Structure(**data)

class SummaryPacket(object):
    """Model for CDRouter Capture Summary Packets.

    :param sections: (optional) :class:`captures.Section <captures.Section>` list
    """
    def __init__(self, **kwargs):
        self.sections = kwargs.get('sections', None)

class SummaryPacketSchema(Schema):
    sections = mfields.Nested(SectionSchema, many=True)

    @post_load
    def post_load(self, data):
        return SummaryPacket(**data)

class Summary(object):
    """Model for CDRouter Capture Summaries.

    :param structure: (optional) :class:`captures.Structure <captures.Structure>` object
    :param summaries: (optional) :class:`captures.SummaryPacket <captures.SummaryPacket>` list
    """
    def __init__(self, **kwargs):
        self.structure = kwargs.get('structure', None)
        self.summaries = kwargs.get('summaries', None)

class SummarySchema(Schema):
    structure = mfields.Nested(StructureSchema)
    summaries = mfields.Nested(SummaryPacketSchema, many=True)

    @post_load
    def post_load(self, data):
        return Summary(**data)

class Field(object):
    """Model for CDRouter Capture Fields.

    :param name: (optional) Field name as string.
    :param show_name: (optional) Either `true` or `false` as string.
    :param hide: (optional) Either `true` or `false` as string.<commit_msg>Fix issue with CapturesService.summary<commit_after>#
# Copyright (c) 2017 by QA Cafe.
# All Rights Reserved.
#

"""Module for accessing CDRouter Captures."""

import io

from requests_toolbelt.downloadutils import stream
from marshmallow import Schema, post_load
from marshmallow import fields as mfields

class Section(object):
    """Model for CDRouter Capture Sections.

    :param value: (optional) Section value as a string.
    """
    def __init__(self, **kwargs):
        self.value = kwargs.get('value', None)

class SectionSchema(Schema):
    value = mfields.Str()

    @post_load
    def post_load(self, data):
        return Section(**data)

class Structure(object):
    """Model for CDRouter Capture Structures.

    :param sections: (optional) :class:`captures.Section <captures.Section>` list
    """
    def __init__(self, **kwargs):
        self.sections = kwargs.get('sections', None)

class StructureSchema(Schema):
    sections = mfields.Nested(SectionSchema, many=True)

    @post_load
    def post_load(self, data):
        return Structure(**data)

class SummaryPacket(object):
    """Model for CDRouter Capture Summary Packets.

    :param sections: (optional) :class:`captures.Section <captures.Section>` list
    """
    def __init__(self, **kwargs):
        self.sections = kwargs.get('sections', None)

class SummaryPacketSchema(Schema):
    sections = mfields.Nested(SectionSchema, many=True, missing=None)

    @post_load
    def post_load(self, data):
        return SummaryPacket(**data)

class Summary(object):
    """Model for CDRouter Capture Summaries.

    :param structure: (optional) :class:`captures.Structure <captures.Structure>` object
    :param summaries: (optional) :class:`captures.SummaryPacket <captures.SummaryPacket>` list
    """
    def __init__(self, **kwargs):
        self.structure = kwargs.get('structure', None)
        self.summaries = kwargs.get('summaries', None)

class SummarySchema(Schema):
    structure = mfields.Nested(StructureSchema)
    summaries = mfields.Nested(SummaryPacketSchema, many=True, missing=None)

    @post_load
    def post_load(self, data):
        return Summary(**data)

class Field(object):
    """Model for CDRouter Capture Fields.

    :param name: (optional) Field name as string.
    :param show_name: (optional) Either `true` or `false` as string.
    :param hide: (optional) Either `true` or `false` as string.
{'fraction_non_alphanumeric': 0.11909262759924386, 'fraction_numerical': 0.0016803192606595252, 'mean_word_length': 3.9449636552440293, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '768048', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1374, 'n_words': 398}