<commit_before>#!/usr/bin/python
"""
edX Block object used to parse, store, and setup specific data.
"""


from edx_block_icons import icon_dict


class Block(object):

    def __init__(self, block):
        self.id = block['id']
        self.type = block['type']
        self.name = block['name']
        self.children = []
        self.parent = ''

        self.tip = ''

        try:
            self.icon = icon_dict[self.type]
        except KeyError:
            self.icon = '\uf111'

        if self.type == 'problem':
            try:
                self.markdown = block['markdown']
            except KeyError:
                self.markdown = ''
        if self.type == 'video':
            try:
                self.youtube_id = block['youtube_id']
            except KeyError:
                self.youtube_id = ''
                
            try:
                self.video_start = block['start_time']
            except KeyError:
                self.video_start = ''

            try:
                self.video_end = block['end_time']
            except KeyError:
                self.video_end = ''

        self.generate_tooltip()

    def __str__(self):
        """Overload string function."""
        return '{"name": "%s", "parent": "%s", "type": "%s", "icon": "%s", "tip": "%s"},' % (
               self.name.encode('utf-8'), self.parent.encode('utf-8'), self.type.encode('utf-8'),
               self.icon, self.tip)

    def generate_tooltip(self):
        if self.type == 'video':
            self.tip = 'video tip: %s %s %s' % (self.youtube_id.encode('utf-8'),
                                                self.video_start,
                                                self.video_end)
        elif self.type == 'problem' and self.markdown:
            self.tip = 'I HAVE MARKDOWN TO VIEW!!!'<commit_msg>updating methods for maing tooltips<commit_after>#!/usr/bin/python
"""
edX Block object used to parse, store, and setup specific data.
"""


from edx_block_icons import icon_dict


class Block(object):

    def __init__(self, block):
        self.id = block['id']
        self.type = block['type']
        self.name = block['name']
        self.children = []
        self.parent = ''

        self.tip = ''

        try:
            self.icon = icon_dict[self.type]
        except KeyError:
            self.icon = '\uf111'

        if self.type == 'problem':
            self.generate_problem_tooltip()

        if self.type == 'video':
            self.generate_video_tooltip()

    def __str__(self):
        """Overload string function."""
        return '{"name": "%s", "parent": "%s", "type": "%s", "icon": "%s", "tip": "%s"},' % (
               self.name.encode('utf-8'), self.parent.encode('utf-8'), self.type.encode('utf-8'),
               self.icon, self.tip)

    def generate_problem_tooltip(self, block):
        try:
            if block['markdown']:
                self.tip = 'I HAVE MARKDOWN TO VIEW!!!'
        except KeyError:
            return 0

    def generate_video_tooltip(self, block):
        try:
            youtube_id = block['youtube_id']
        except KeyError:
            youtube_id = None

        try:
            video_start = block['start_time']
        except KeyError:
            video_start = None

        try:
            video_end = block['end_time']
        except KeyError:
            video_end = None

        if video_start and video_end:
            video_length = video_end - video_start
        else:
            video_length = query_youtube_api(youtube_id)
            
        self.tip = 'video tip: %s %s %s' % (youtube_id.encode('utf-8'), video_start, video_end)
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.004098360655737705, 'mean_word_length': 1.6376080691642652, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6767246', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1023, 'n_words': 242}