Beispiel #1
0
 def thumbnail(self):
     """
     Get the thumbnail of the item
     """
     thumbnail = Item.asciify_string(os.path.join(self.get_dir(), "thumbnail_%s.png"%(os.path.basename(self.original_image_name))))
     if not (hasattr(self, 'do_not_generate') and self.do_not_generate) and not os.path.isfile(thumbnail):
         generate_thumbnail(self.original_image_name, thumbnail)
     return thumbnail
Beispiel #2
0
    def delete(self):
        for child in self.children:
            child.delete()

        shutil.rmtree(Item.asciify_string(self.get_dir()))

        try:
            super().delete()
        except:
            pass
Beispiel #3
0
 def thumbnail(self):
     """
     Get the thumbnail of the item
     """
     thumbnail = Item.asciify_string(
         os.path.join(
             self.get_dir(), "thumbnail_%s.png" %
             (os.path.basename(self.original_image_name))))
     if not (hasattr(self, 'do_not_generate')
             and self.do_not_generate) and not os.path.isfile(thumbnail):
         generate_thumbnail(self.original_image_name, thumbnail)
     return thumbnail
Beispiel #4
0
def create_category_dir(target, value, oldvalue, initiator):
    """
    Create of move the category directory
    """
    initiator = initiator
    base = target.get_base()
    new_dir = Item.asciify_string(os.path.join(base, value))
    if not oldvalue:
        old_dir = os.path.join(base, oldvalue)
        os.renames(old_dir, new_dir)
    else:
        try:
            os.makedirs(new_dir)
        except os.error:
            pass
Beispiel #5
0
    def image(self, val):
        """
        Set the image of the item
        """
        val.file.seek(0)
        ext = imghdr.what('unused', val.file.read())
        val.file.seek(0)
        path = Item.asciify_string(os.path.join(self.get_dir(), "Picture_original_%s.%s" % (self.name,ext)))
        self.original_image_name = path
        output_file = open(path, 'wb')

        while not val.file.closed:
            data = val.file.read(2 << 16)
            if not data:
                val.file.close()
            output_file.write(data)
        output_file.close()
Beispiel #6
0
    def image(self, val):
        """
        Set the image of the item
        """
        val.file.seek(0)
        ext = imghdr.what('unused', val.file.read())
        val.file.seek(0)
        path = Item.asciify_string(
            os.path.join(self.get_dir(),
                         "Picture_original_%s.%s" % (self.name, ext)))
        self.original_image_name = path
        output_file = open(path, 'wb')

        while not val.file.closed:
            data = val.file.read(2 << 16)
            if not data:
                val.file.close()
            output_file.write(data)
        output_file.close()
Beispiel #7
0
 def getOriginalImageName(self, ext):
     log.error("GetOriginalImageName - %s - %s - %s", ext, self.get_dir(),
               self.name)
     return Item.asciify_string(
         os.path.join(self.get_dir(),
                      "Category_original_%s.%s" % (self.name, ext)))