Example #1
0
 def test_import_2(self):
     picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
                                     path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"),
                                     overwrite=True)
     cats = set([t.category for t in picture.tags])
     assert 'epoch' in cats
     assert 'kind' in cats
    def test_import(self):
        picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"))

        motifs = set([tag.name for tag in picture.tags if tag.category == 'theme'])
        assert motifs == set([u'nieporządek']), 'theme tags are wrong. %s' % motifs

        picture.delete()
Example #3
0
    def test_import_with_explicit_image(self):
        picture = Picture.from_xml_file(
            path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"),
            path.join(path.dirname(__file__), "files/kandinsky-composition-viii.png"),
        )

        picture.delete()
Example #4
0
    def test_import_with_explicit_image(self):
        picture = Picture.from_xml_file(
            path.join(path.dirname(__file__),
                      "files/kandinsky-composition-viii.xml"),
            path.join(path.dirname(__file__),
                      "files/kandinsky-composition-viii.png"))

        picture.delete()
Example #5
0
 def import_picture(self, file_path, options, continue_on_error=True):
     try:
         image_store = ImageStore(os.path.dirname(file_path))
         picture = Picture.from_xml_file(file_path, image_store=image_store, overwrite=options.get('force'))
     except Exception, ex:
         if continue_on_error:
             print "%s: %s" % (file_path, ex)
             return
         else:
             raise ex
 def test_import_2(self):
     picture = Picture.from_xml_file(
         path.join(path.dirname(__file__),
                   "files/kandinsky-composition-viii.xml"),
         path.join(path.dirname(__file__),
                   "files/kandinsky-composition-viii.png"),
         overwrite=True)
     cats = set([t.category for t in picture.tags])
     assert 'epoch' in cats
     assert 'kind' in cats
Example #7
0
    def test_import(self):
        picture = Picture.from_xml_file(
            path.join(path.dirname(__file__),
                      "files/kandinsky-composition-viii.xml"))

        motifs = set(
            [tag.name for tag in picture.tags if tag.category == 'theme'])
        assert motifs == set([u'nieporządek'
                              ]), 'theme tags are wrong. %s' % motifs

        picture.delete()
Example #8
0
 def import_picture(self, file_path, options, continue_on_error=True):
     try:
         image_store = ImageStore(os.path.dirname(file_path))
         picture = Picture.from_xml_file(file_path,
                                         image_store=image_store,
                                         overwrite=options.get('force'))
     except Exception, ex:
         if continue_on_error:
             print "%s: %s" % (file_path, ex)
             return
         else:
             raise ex
Example #9
0
    def test_import(self):
        picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"))

        themes = set()
        for area in picture.areas.all():
            themes.update([(tag.category, tag.name) for tag in area.tags if tag.category in (u"theme", u"thing")])
        assert themes == {(u"theme", u"nieporządek"), (u"thing", u"Kosmos")}, "Bad themes on Picture areas: %s" % themes

        pic_themes = set([tag.name for tag in picture.tags if tag.category in ("theme", "thing")])
        assert not pic_themes, "Unwanted themes set on Pictures: %s" % pic_themes

        picture.delete()
Example #10
0
    def test_import(self):
        picture = Picture.from_xml_file(path.join(path.dirname(__file__), "files/kandinsky-composition-viii.xml"))

        themes = set()
        for area in picture.areas.all():
            themes.update([(tag.category, tag.name)
                for tag in area.tags if tag.category in (u'theme', u'thing')])
        assert themes == set([(u'theme', u'nieporządek'), (u'thing', u'kosmos')]), \
            'Bad themes on Picture areas: %s' % themes

        pic_themes = set([tag.name for tag in picture.tags if tag.category in ('theme', 'thing')])
        assert not pic_themes, 'Unwanted themes set on Pictures: %s' % pic_themes

        picture.delete()
    def test_import(self):
        picture = Picture.from_xml_file(
            path.join(path.dirname(__file__),
                      "files/kandinsky-composition-viii.xml"))

        themes = set()
        for area in picture.areas.all():
            themes.update([(tag.category, tag.name) for tag in area.tags
                           if tag.category in (u'theme', u'thing')])
        assert themes == {(u'theme', u'nieporządek'), (u'thing', u'Kosmos')}, \
            'Bad themes on Picture areas: %s' % themes

        pic_themes = set([
            tag.name for tag in picture.tags
            if tag.category in ('theme', 'thing')
        ])
        assert not pic_themes, 'Unwanted themes set on Pictures: %s' % pic_themes

        picture.delete()
 def import_picture(self, file_path, options):
     picture = Picture.from_xml_file(file_path, overwrite=options.get('force'))
     return picture
Example #13
0
 def save(self, commit=True, **kwargs):
     return Picture.from_xml_file(
         self.cleaned_data['picture_xml_file'], image_file=self.cleaned_data['picture_image_file'],
         overwrite=True, **kwargs)
Example #14
0
 def import_picture(self, file_path, options):
     picture = Picture.from_xml_file(file_path,
                                     overwrite=options.get('force'))
     return picture