예제 #1
0
 def save(self, *args, **kwargs):
     """Save other colors of the issue icon. We assume it is validated in
     the clean function"""
     if self.icon:
         xml = svg.validate_svg(self.icon.file.read())
         square = svg.make_square(xml)
         colors = svg.color_icon(square)
         super(Issue, self).save(*args, **kwargs)
         for key, content in colors.items():
             filename = self.icon_color(key)
             if self.icon.storage.exists(filename):
                 self.icon.storage.delete(filename)
             self.icon.storage.save(filename, svg.as_file(content))
     else:
         super(Issue, self).save(*args, **kwargs)
예제 #2
0
 def save(self, *args, **kwargs):
     """Save other colors of the issue icon. We assume it is validated in
     the clean function"""
     if self.icon:
         xml = svg.validate_svg(self.icon.file.read())
         square = svg.make_square(xml)
         colors = svg.color_icon(square)
         super(Issue, self).save(*args, **kwargs)
         for key, content in colors.items():
             filename = self.icon_color(key)
             if self.icon.storage.exists(filename):
                 self.icon.storage.delete(filename)
             self.icon.storage.save(filename, svg.as_file(content))
     else:
         super(Issue, self).save(*args, **kwargs)
 def test_must_be_svg(self):
     svg_bytes = XML_HEADER + b'<SOMEOTHERTAG></SOMEOTHERTAG>'
     self.assertIsNone(svg_util.validate_svg(svg_bytes))
 def test_must_be_xml(self):
     svg_bytes = b'some text n stuff'
     self.assertIsNone(svg_util.validate_svg(svg_bytes))
예제 #5
0
 def test_must_be_svg(self):
     svg_bytes = XML_HEADER + b"<SOMEOTHERTAG></SOMEOTHERTAG>"
     self.assertIsNone(svg_util.validate_svg(svg_bytes))
예제 #6
0
 def test_must_be_xml(self):
     svg_bytes = b"some text n stuff"
     self.assertIsNone(svg_util.validate_svg(svg_bytes))