<commit_before>"""
Created on 10 Nov 2016

@author: <NAME> (<EMAIL>)

example:
    {
      "description": "electrochemical we (V), ae (V), wc (V), cnc (ppb), Pt100 temp, internal SHT",
      "unit": null,
      "name": "hourly statistics of Gas concentrations",
      "public": true,
      "topic": "/osio/orgs/south-coast-science-dev/production-test/loc/1/gases/hourly",
      "derived-data": {
        "interval": 3600
      },
      "topic-info": {
        "format": "application/json"
      }
    }
"""

from collections import OrderedDict

from scs_core.osio.data.abstract_topic import AbstractTopic
from scs_core.osio.data.topic_info import TopicInfo


# --------------------------------------------------------------------------------------------------------------------

class DerivedTopic(AbstractTopic):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    @classmethod
    def construct_from_jdict(cls, jdict):
        if not jdict:
            return None

        # AbstractTopic...
        path = jdict.get('topic')
        name = jdict.get('name')
        description = jdict.get('description')

        is_public = jdict.get('public')

        topic_info = TopicInfo.construct_from_jdict(jdict.get('topic-info'))

        # DerivedTopic...
        unit = jdict.get('unit')
        derived_data = jdict.get('derived-data')

        return DerivedTopic(path, name, description, is_public, topic_info, unit, derived_data)

<commit_msg>Added DerivedData class to DerivedTopic.<commit_after>"""
Created on 10 Nov 2016

@author: <NAME> (<EMAIL>)

example:
    {
      "description": "electrochemical we (V), ae (V), wc (V), cnc (ppb), Pt100 temp, internal SHT",
      "unit": null,
      "name": "hourly statistics of Gas concentrations",
      "public": true,
      "topic": "/osio/orgs/south-coast-science-dev/production-test/loc/1/gases/hourly",
      "derived-data": {
        "interval": 3600
      },
      "topic-info": {
        "format": "application/json"
      }
    }
"""

from collections import OrderedDict

from scs_core.osio.data.abstract_topic import AbstractTopic
from scs_core.osio.data.derived_data import DerivedData
from scs_core.osio.data.topic_info import TopicInfo


# --------------------------------------------------------------------------------------------------------------------

class DerivedTopic(AbstractTopic):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    @classmethod
    def construct_from_jdict(cls, jdict):
        if not jdict:
            return None

        # AbstractTopic...
        path = jdict.get('topic')
        name = jdict.get('name')
        description = jdict.get('description')

        is_public = jdict.get('public')

        topic_info = TopicInfo.construct_from_jdict(jdict.get('topic-info'))

        # DerivedTopic...
        unit = jdict.get('unit')
        derived_data = DerivedData.construct_from_jdict(jdict.get('derived-data'))

        return DerivedTopic(path, name, description, is_public, topic_info, unit, derived_data)


{'fraction_non_alphanumeric': 0.2552067143301212, 'fraction_numerical': 0.008703761268262356, 'mean_word_length': 1.6772046589018303, 'pattern_counts': {'":': 18, '<': 7, '<?xml version=': 0, '>': 7, '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': '4900581', 'n_tokens_mistral': 936, 'n_tokens_neox': 879, 'n_words': 188}