Example #1
0
 def test_nested():
     nested_content = [
         text1, generate_xml_element(tag_inner, content=text2)
     ]
     print(
         generate_xml_element(tag_outer, content=nested_content,
                              block=True))
 def generate_xml(self, indent: int = 0):
     wallpaper_info_list = []
     for (key, val) in vars(self).items():
         wallpaper_info_list.append(
             generate_xml_element(tag=key, content=str(val)))
     generated_text = generate_xml_element(self.wallpaper_tag,
                                           content=wallpaper_info_list)
     return indent_text(generated_text, indent=indent)
 def generate_static(self, indent: int = 0):
     generated_text = generate_xml_element(
         'static',
         content=[
             generate_xml_element('duration',
                                  content='%.1f' % self.lasting_sec),
             generate_xml_element('file', content=self.current_image),
         ])
     return indent_text(generated_text, indent=indent)
 def generate_transition(self, indent: int = 0):
     generated_text = generate_xml_element(
         'transition',
         content=[
             generate_xml_element('duration',
                                  content='%.1f' % self.transition_sec),
             generate_xml_element('from', content=self.current_image),
             generate_xml_element('to', content=self.next_image),
         ])
     return indent_text(generated_text, indent=indent)
def get_unix_start_time():
    """
    Get the starting point of Unix time.
    Return the XML markup.
    """

    start_time_items = [('year', 1970), ('month', 1), ('day', 1), ('hour', 0),
                        ('minute', 0), ('second', 0)]

    start_time_xml_list = []
    for (tag, val) in start_time_items:
        start_time_xml_list.append(
            generate_xml_element(tag, content='%02d' % val))
    return generate_xml_element('starttime', start_time_xml_list)
Example #6
0
    def generate_slide_show_xml():
        """
        Generate a slide show XML.
        Put the XML into "~/.local/share/backgrounds" directory.
        """

        root_tag = 'background'
        start_comment_text = 'This animation starts at the beginning of the unix epoch.'

        # start time
        start_time = get_unix_start_time()
        start_time_comment = generate_xml_comment(start_comment_text)

        # list of slides
        num_total_images = len(linked_images)
        slides_xml_list = []
        for image_index in range(0, num_total_images):
            # get current and next images
            current_image = abspath(linked_images[image_index])
            next_index = (image_index + 1) % num_total_images
            next_image = abspath(linked_images[next_index])
            # generate XML transition
            new_slide = Slide(current_image, next_image, transition_interval)
            slides_xml_list.append(new_slide.generate_static())
            slides_xml_list.append(new_slide.generate_transition())

        # combine together into XML
        combined_xml = XML_header + '\n'
        combined_xml += generate_xml_element(
            tag=root_tag,
            content=[start_time, start_time_comment, *slides_xml_list])
        return combined_xml
Example #7
0
 def test_multiline():
     multiline_content = [text1, text2]
     print(
         generate_xml_element(tag_outer,
                              attrs=attrs_outer,
                              content=multiline_content,
                              block=True))
def test_wallpaper():
    print(get_xml_header())

    sample_slideshow = Wallpaper('/usr/share/backgrounds/contest/focal.xml',
                                 name='Ubuntu')
    sample_image = WallpaperImage(
        '/usr/share/backgrounds/warty-final-ubuntu.png')

    root_tag = 'wallpapers'
    inner_content = [
        sample_slideshow.generate_xml(),
        sample_image.generate_xml()
    ]
    print_indented(generate_xml_element(root_tag, content=inner_content))
Example #9
0
    def generate_bg_properties_xml():
        """
        Generate a background properties XML.
        Put the XML into "~/.local/share/gnome-background-properties" directory.
        """

        root_tag = 'wallpapers'
        bg_list = []

        # first add slide show XML
        slide_show = Wallpaper(slide_show_xml_filename, name=collection_name)
        slide_show_xml_element = slide_show.generate_xml()
        bg_list.append(slide_show_xml_element)

        # then add images
        for image_filename in linked_images:
            image = WallpaperImage(image_filename)
            image_xml_element = image.generate_xml()
            bg_list.append(image_xml_element)

        # combine together into XML
        combined_xml = XML_header + '\n'
        combined_xml += generate_xml_element(tag=root_tag, content=bg_list)
        return combined_xml
Example #10
0
 def test_single_tag_attrs_block():
     print(
         generate_xml_element(tag_outer,
                              attrs=attrs_outer,
                              content=text1,
                              block=True))
Example #11
0
 def test_single_tag_inline():
     print(generate_xml_element(tag_outer, content=text1))
Example #12
0
 def test_single_tag_with_attrs():
     print(generate_xml_element(tag_outer, attrs=attrs_outer))
Example #13
0
 def test_single_tag():
     print(generate_xml_element(tag_outer))