コード例 #1
0
    def create_shot(self, sid, tag=None, comment=''):
        """
        Create a shot
        :param sid: Sid fill with datas
        :return The path where is create
        """
        if sid.is_asset():
            raise pe.PipeException('Sid need to be a shot for create a shot')
        if not sid.has_a('ext'):
            raise pe.PipeException(
                'Sid need to be fill with a extension. Sid: ' + str(sid))

        engine_crate = conf.get_soft_by_ext(sid.get('ext'))

        # file path
        path = sid.get_as('state').path
        if not os.path.exists(conf.root):
            raise pe.PipeException(conf.root + " not find")
        if not os.path.exists(path):
            os.makedirs(path)
        else:
            raise pe.PipeException("File already exist")
        """
        Template
        """
        path_template = conf.scene_templates.format(project=sid.get('project'),
                                                    software=engine_crate)
        file_name_template = conf.shot_template_name.format(
            software=engine_crate, ext=sid.get('ext'))

        path_template = self.template_init(path_template, file_name_template,
                                           engine_crate)

        shutil.copy(path_template, sid.path)

        # COMMENT FILE TODO Maybe in the conf (txt file base)
        if comment == '':
            comment = "Created on {d} at {h} \n\n".format(d=time.strftime('%A %d/%m/%Y'), h=time.strftime(
                '%H:%M')) + 'Sequence : {sequence}\n' \
                            'Shot : {shot}\n' \
                            'Task : {task}\n' \
                            'Subtask : {subtask}\n'.format(
                sequence=sid.get('seq'), shot=sid.get('shot'), task=sid.get('task'), subtask=sid.get('subtask'))

        self.create_package_file(sid.get_as('state'), comment,
                                 tag)  # TODO PASS A FILE OBJECT

        # CREATE WORKSPACE
        if sid.get('task') == 'comp':
            self.create_shot_2d_workspace(sid)
        else:
            self.create_shot_3d_workspace(sid)
        return sid
コード例 #2
0
 def conform_entity(self, sid):
     """
     Conform a existing file into the pipe nomenclature
     :return: The path where the file is conform
     """
     if not engine or engine == 'engine':
         raise pe.PipeException('Engine not valid')
     else:
         sid = self.datas.conform_entity(sid)
         self.engine.save(sid.path)
         return sid