Ejemplo n.º 1
0
    def find_work(self, force=False, verbose=1):
        """Find work files within this work area.

        Args:
            force (bool): force reread work files from disk
            verbose (int): print process data

        Returns:
            (_CTTWorkFileBase): list of cachable work files
        """
        dprint('FINDING WORK', self.path, verbose=verbose)

        # Get work dir
        _tmpl = get_template(self.maya_work_type.hint)
        _data = copy.copy(self.data)
        _data['Task'] = 'blah'
        _data['extension'] = 'mb'
        _data['version'] = 1
        _tmp_path = _tmpl.apply_fields(_data)
        _tmp_work = self.maya_work_type(_tmp_path)

        # Find work files + make cachable
        _works = []
        for _file in find(_tmp_work.dir, depth=1, type_='f'):
            try:
                _tmp_work = self.maya_work_type(_file)
            except ValueError:
                continue
            lprint(' - ADDING', _file, verbose=verbose > 1)
            _work = obtain_work(_tmp_work.path)
            _works.append(_work)
        return _works
Ejemplo n.º 2
0
    def get_work_area(self, dcc='maya'):
        """Get work area in this step for the given dcc.

        Args:
            dcc (str): dcc to get work area for

        Returns:
            (TTWorkAreaBase): work area
        """
        if dcc == 'maya':
            _tmpl = get_template(self.work_area_maya_hint)
            return self.work_area_maya_type(_tmpl.apply_fields(self.data))
        raise ValueError(dcc)
Ejemplo n.º 3
0
    def find_next(self, vers=None):
        """Find next version.

        Args:
            vers (TTWorkFileBase list): override versions list

        Returns:
            (TTWorkFileBase): next version
        """
        _data = copy.copy(self.data)
        _latest = self.find_latest(vers=vers)
        _data['version'] = _latest.version + 1 if _latest else 1
        _path = get_template(self.hint).apply_fields(_data)
        return self.__class__(_path)
Ejemplo n.º 4
0
    def __init__(self, path, verbose=0):
        """Constructor.

        Args:
            path (str): file seq path
            verbose (int): print process data
        """
        _tmpl = get_template(self.hint)
        try:
            _data = _tmpl.get_fields(path)
        except tank.TankError as _exc:
            lprint('TANK ERROR', _exc.message, verbose=verbose)
            raise ValueError("Tank rejected path " + path)
        _data["SEQ"] = "%04d"
        _path = abs_path(_tmpl.apply_fields(_data))
        super(TTOutputFileSeqBase, self).__init__(path=_path,
                                                  data=_data,
                                                  tmpl=_tmpl)
        Seq.__init__(self, _path)
Ejemplo n.º 5
0
    def find_output_vers(self):
        """Find output versions in this shot.

        Returns:
            (TTShotOutputVersion list): list of output versions
        """
        _tmpl = get_template('shot_output_root')
        _out_root = TTShotOutputRoot(_tmpl.apply_fields(self.data))
        _vers = []
        for _dir in _out_root.find(depth=1, type_='d'):
            _type = TTShotOutputType(_dir)
            for _dir in _type.find(depth=1, type_='d'):
                try:
                    _name = TTShotOutputName(_dir)
                except ValueError:
                    continue
                for _dir in _name.find(depth=1, type_='d'):
                    _ver = TTShotOutputVersion(_dir)
                    _vers.append(_ver)
        return _vers
Ejemplo n.º 6
0
    def find_outputs(self, filter_=None, verbose=1):
        """Find outputs from this work file.

        Args:
            filter_ (str): path filter
            verbose (int): print process data

        Returns:
            (TTAssetOutputFile list): list of outputs
        """
        _ver_tmpl = get_template(self.output_version_type.hint)

        # Find vers that exist in each name
        lprint('SEARCHING FOR VERSIONS', verbose=verbose)
        _vers = []
        for _name in self.find_output_names(filter_=filter_):
            _data = copy.copy(_name.data)
            _data['version'] = self.version
            _ver = self.output_version_type(_ver_tmpl.apply_fields(_data))
            if _ver.exists():
                lprint(' - ADDED VER', _ver, verbose=verbose)
                _vers.append(_ver)
        lprint('FOUND {:d} VERS'.format(len(_vers)), verbose=verbose)

        # Find output in each ver
        _outputs = []
        for _ver in _vers:
            _ver_outputs = _ver.find_outputs()
            lprint(' -',
                   _ver,
                   len(_ver_outputs),
                   _ver_outputs,
                   verbose=verbose)
            _outputs += _ver_outputs

        return _outputs
Ejemplo n.º 7
0
    def find_output_names(self, filter_=None, verbose=0):
        """Find output names for this work file.

        Args:
            filter_ (str): path filter
            verbose (int): print process data

        Returns:
            (list): list of output names
        """
        _root_tmpl = get_template(self.output_root_type.hint)
        _root = self.output_root_type(_root_tmpl.apply_fields(self.data))
        lprint('ROOT', _root, verbose=verbose)
        _names = []
        for _dir in _root.find(filter_=filter_, depth=2, type_='d'):
            try:
                _name = self.output_name_type(_dir)
            except ValueError:
                continue
            if not _name.task == self.task:
                continue
            lprint(' - ADDED NAME', _name, verbose=verbose)
            _names.append(_name)
        return _names
Ejemplo n.º 8
0
    def map_to(self, class_=None, **kwargs):
        """Map this template's values to a different template.

        For example, this could be used to map a maya work file to
        a output file seq. If additional data is required, this can
        be passed in the kwargs.

        Args:
            class_ (TTBase): template type to map to

        Returns:
            (TTBase): new template instance
        """
        _class = class_ or type(self)
        _data = copy.copy(self.data)
        for _key, _val in kwargs.items():
            _data[_key] = _val
        _tmpl = get_template(_class.hint)
        try:
            _path = _tmpl.apply_fields(_data)
        except tank.TankError as _exc:
            _tags = '[' + _exc.message.split('[')[-1]
            raise ValueError('Missing tags: ' + _tags)
        return _class(_path)