<commit_before>import textwrap
import urllib
from lxml import etree, html
from xml.etree import ElementTree as ET

from xblock.core import XBlock
from xblock.fields import Scope, Integer, String
from xblock.fragment import Fragment

from .utils import load_resource, render_template

from StringIO import StringIO


class CarouselBlock(XBlock):
    """
    An XBlock providing a responsive images carousel
    """

    display_name = String(help="This name appears in horizontal navigation at the top of the page.",
        default="Lynx Slider Block",
        scope=Scope.content
    )

    data = String(help="",
       scope=Scope.content,
       default=textwrap.dedent("""
             <carousel>
              <img>
                <link>http://met-content.bu.edu/etr2/content/images/Slide1.JPG</link>
                <description>Slide 1 description comes here</description>
              </img>
              <img>
                <link>http://met-content.bu.edu/etr2/content/images/Slide2.JPG</link>
                <description>Slide 2 description comes here</description>
              </img>
              <img>
                <link>http://met-content.bu.edu/etr2/content/images/Slide3.JPG</link>
                <description>Slide 3 description comes here</description>
              </img>
              <video>
                <link>http://www.youtube.com/watch?v=7uHeNryKUWk</link>
                <description>Video Description goes here</description>
              </video>
              <doc>
                <link>http://www.bu.edu/met-eti/files/2013/03/Final_VirtualLaboratoriesForLearning.pdf</link>
                <description>Document Description goes here</description>
              </doc>
            </carousel>
          """
    ))

    def student_view(self, context):
        """
        Lab view, displayed to the student
        """
        #root = ET.fromstring(self.data)
        #root = etree.parse(StringIO(self.data.replace('&', '&amp;'))).getroot()
        root = etree.fromstring(self.data.replace('&', '&amp;'))
        items = []
        for child in root:
            text_data = child.find('link').text
            if child.tag == 'doc': text_data = urllib.quote(text_data, '')
            description = child.find('description')
            description = ET.tostring(description)
            width = child.attrib.get('width', '100%')
            height = child.attrib.get('height', '625')
            items.append((child.tag, text_data, width, height, description))

        fragment = Fragment()<commit_msg>xblock default name updated | default dummy data added<commit_after>import textwrap
import urllib
from lxml import etree, html
from xml.etree import ElementTree as ET

from xblock.core import XBlock
from xblock.fields import Scope, Integer, String
from xblock.fragment import Fragment

from .utils import load_resource, render_template

from StringIO import StringIO


class CarouselBlock(XBlock):
    """
    An XBlock providing a responsive images carousel
    """

    display_name = String(help="This name appears in horizontal navigation at the top of the page.",
        default="LYNX Slideshow",
        scope=Scope.content
    )

    data = String(help="",
       scope=Scope.content,
       default=textwrap.dedent("""
             <carousel>
              <img>
                <link>http://met-content.bu.edu/etr2/content/images/Slide1.JPG</link>
                <description>Slide 1 description comes here</description>
              </img>
              <img>
                <link>http://met-content.bu.edu/etr2/content/images/Slide2.JPG</link>
                <description>Slide 2 description comes here</description>
              </img>
              <img>
                <link>http://met-content.bu.edu/etr2/content/images/Slide3.JPG</link>
                <description>Slide 3 description comes here</description>
              </img>
              <video>
                <link>http://www.youtube.com/watch?v=7uHeNryKUWk</link>
                <description>Video Description goes here</description>
              </video>
              <doc>
                <link>http://www.bu.edu/met-eti/files/2013/03/Final_VirtualLaboratoriesForLearning.pdf</link>
                <description>Document Description goes here</description>
              </doc>
            </carousel>
          """
    ))

    def student_view(self, context):
        """
        Lab view, displayed to the student
        """
        dummy_data=textwrap.dedent("""
                     <carousel>
                      <img>
                        <link>http://met-content.bu.edu/etr2/content/images/Slide1.JPG</link>
                        <description>Slide 1 description comes here</description>
                      </img>
                      <img>
                        <link>http://met-content.bu.edu/etr2/content/images/Slide2.JPG</link>
                        <description>Slide 2 description comes here</description>
                      </img>
                      <img>
                        <link>http://met-content.bu.edu/etr2/content/images/Slide3.JPG</link>
                        <description>Slide 3 description comes here</description>
                      </img>
                      <video>
                        <link>http://www.youtube.com/watch?v=7uHeNryKUWk</link>
                        <description>Video Description goes here</description>
                      </video>
                      <doc>
                        <link>http://www.bu.edu/met-eti/files/2013/03/Final_VirtualLaboratoriesForLearning.pdf</link>
                        <description>Document Description goes here</description>
                      </doc>
                    </carousel>
                  """
            )

        #root = ET.fromstring(self.data)
        #root = etree.parse(StringIO(self.data.replace('&', '&amp;'))).getroot()
        root = etree.fromstring(self.data.replace('&', '&amp;'))
        items = []
        for child in root:
            text_data = child.find('link').text
            if child.tag == 'doc': text_data = urllib.quote(text_data, '')
            description = child.find('description')
            description = ET.tostring(description)
            width = child.attrib.get('width', '100%')
            height = child.attrib.get('height', '625')
            items.append((child.tag, text_data, width, height, description))

        fragment = Fragment()
{'fraction_non_alphanumeric': 0.11850247524752475, 'fraction_numerical': 0.009282178217821782, 'mean_word_length': 1.7938634399308557, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 99, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 4}, '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': '5175617', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1713, 'n_words': 354}