Example #1
0
    def exportProtocol(self, protocol, root_path):

        protocol.update()

        expDir = entityRepository.exportEntity(protocol, root_path)

        # export notes
        notesDir = expDir.joinpath('notes')
        notes = protocol.getComments(count=1000)

        for note in notes:
            note.export(notesDir)

        # save materials
        materialsDir = expDir.joinpath('materials')
        materials = protocol.getMaterials()

        for material in materials:
            material.export(materialsDir)

        # save data
        dataDir = expDir.joinpath('data')
        data = protocol.getDataFields()

        for dat in data:
            dat.export(dataDir)

        # get html
        html = htmlExportService.getHTML(protocol)
        html_with_paths = htmlExportService.insertFilepaths(expDir, html)

        with open(expDir.joinpath('entity.html'), 'w') as out:
            out.write(html_with_paths)
Example #2
0
    def exportExperiment(self, experiment, root_path):

        experiment.update()

        expDir = entityRepository.exportEntity(experiment, root_path)

        # export entry
        experiment.root_experiment.export(expDir, folderName='entry')

        # export protocols
        protocolsDir = expDir.joinpath('protocols')
        protocols = experiment.getProtocols(count=100)

        for protocol in protocols:
            protocol.export(protocolsDir)

        # export notes
        notesDir = expDir.joinpath('notes')
        notes = experiment.getComments(count=1000)

        for note in notes:
            note.export(notesDir)

        # get html
        html = htmlExportService.getHTML(experiment)
        html_with_paths = htmlExportService.insertFilepaths(expDir, html)

        with open(expDir.joinpath('entity.html'), 'w',
                  encoding="utf-8") as out:
            out.write(html_with_paths)
Example #3
0
    def exportFile(self, file, root_path):

        fileDir = entityRepository.exportEntity(file,
                                                root_path,
                                                folderName=str(file.id))
        file.save(fileDir)
        if file.image_annotation is not None:
            annotatedFile = File(file.image_annotation, file.__user__)
            annotatedFile.export(root_path)
Example #4
0
    def exportComment(self, comment, rootPath):
        commentDir = entityRepository.exportEntity(comment, rootPath)

        # export comment
        nestedCommentsDir = commentDir.joinpath('comments')
        nestedComments = comment.getComments(count=1000)

        for nestedComment in nestedComments:
            nestedComment.export(nestedCommentsDir)
Example #5
0
    def export(self, rootPath, folderName=None):
        """
        Export the entity to the directory specified. 

        Parameters
        -------
        path (str)
            The path to the directory to save the experiment.

        Example
        -------
        ::

            experiment = user.getExperiment(17000)
            experiment.export('/my_folder')
        """
        from labstep.generic.entity.repository import entityRepository
        return entityRepository.exportEntity(self, rootPath, folderName=folderName)
Example #6
0
    def exportExperimentProtocol(self, experimentProtocol, rootPath,
                                 folderName):

        experimentProtocol.update()

        expDir = entityRepository.exportEntity(experimentProtocol,
                                               rootPath,
                                               folderName=folderName)

        # save materials
        materialsDir = expDir.joinpath('materials')
        materials = experimentProtocol.getMaterials()

        for material in materials:
            material.export(materialsDir)

        # save data
        dataDir = expDir.joinpath('data')
        data = experimentProtocol.getDataFields()

        for dat in data:
            dat.export(dataDir)