def create_object(self, name, images, filename, options=None, object_identifier=None, read_only=False):
        """Create an image group object with the given list of images. The
        file name specifies the location on local disk where the tar-file
        containing the image group files is located. The file will be copied
        to the image groups data directory.

        Parameters
        ----------
        name : string
            User-provided name for the image group
        images : List(GroupImage)
            List of objects describing images in the group
        filename : string
            Location of local file containing all images in the group
        options : list(dict('name':...,'value:...')), optional
            List of image group options. If None, default values will be used.
        object_identifier : string
            Unique object identifier, optional
        read_only : boolean, optional
            Optional value for the read-only property

        Returns
        -------
        ImageGroupHandle
            Object handle for created image group
        """
        # Raise an exception if given image group is not valied.
        self.validate_group(images)
        # Create a new object identifier if none is given.
        if object_identifier is None:
            identifier = str(uuid.uuid4()).replace('-','')
        else:
            identifier = object_identifier
        # Create the initial set of properties.
        prop_filename = os.path.basename(os.path.normpath(filename))
        prop_mime = 'application/x-tar' if filename.endswith('.tar') else 'application/x-gzip'
        properties = {
            datastore.PROPERTY_NAME: name,
            datastore.PROPERTY_FILENAME : prop_filename,
            datastore.PROPERTY_FILESIZE : os.path.getsize(filename),
            datastore.PROPERTY_MIMETYPE : prop_mime
        }
        if read_only:
            properties[datastore.PROPERTY_READONLY] = True
        # Directories are simply named by object identifier
        directory = os.path.join(self.directory, identifier)
        # Create the directory if it doesn't exists
        if not os.access(directory, os.F_OK):
            os.makedirs(directory)
        # Move original file to object directory
        shutil.copyfile(filename, os.path.join(directory, prop_filename))
        # Get dictionary of given options. If none are given opts will be an
        # empty dictionary. If duplicate attribute names are present an
        # exception will be raised.
        opts = attribute.to_dict(options, self.attribute_defs)
        # Create the image group object and store it in the database before
        # returning it.
        obj = ImageGroupHandle(
            identifier,
            properties,
            directory,
            images,
            opts
        )
        self.insert_object(obj)
        return obj
def create_object ( self , name , images , filename , options = None , object_identifier = None , read_only = False ) : self . validate_group ( images ) if object_identifier is None : identifier = str ( uuid . uuid4 ( ) ) . replace ( '-' , '' ) else : identifier = object_identifier prop_filename = os . path . basename ( os . path . normpath ( filename ) ) prop_mime = 'application/x-tar' if filename . endswith ( '.tar' ) else 'application/x-gzip' properties = { datastore . PROPERTY_NAME : name , datastore . PROPERTY_FILENAME : prop_filename , datastore . PROPERTY_FILESIZE : os . path . getsize ( filename ) , datastore . PROPERTY_MIMETYPE : prop_mime } if read_only : properties [ datastore . PROPERTY_READONLY ] = True directory = os . path . join ( self . directory , identifier ) if not os . access ( directory , os . F_OK ) : os . makedirs ( directory ) shutil . copyfile ( filename , os . path . join ( directory , prop_filename ) ) opts = attribute . to_dict ( options , self . attribute_defs ) obj = ImageGroupHandle ( identifier , properties , directory , images , opts ) self . insert_object ( obj ) return obj
Create an image group object with the given list of images. The
        file name specifies the location on local disk where the tar-file
        containing the image group files is located. The file will be copied
        to the image groups data directory.

        Parameters
        ----------
        name : string
            User-provided name for the image group
        images : List(GroupImage)
            List of objects describing images in the group
        filename : string
            Location of local file containing all images in the group
        options : list(dict('name':...,'value:...')), optional
            List of image group options. If None, default values will be used.
        object_identifier : string
            Unique object identifier, optional
        read_only : boolean, optional
            Optional value for the read-only property

        Returns
        -------
        ImageGroupHandle
            Object handle for created image group