コード例 #1
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_version_attribute_is_set_to_none(self):
     """testing if setting the version attribute to None is possible
     """
     rep = Representation(self.version1)
     self.assertFalse(rep.version is None)
     rep.version = None
     self.assertTrue(rep.version is None)
コード例 #2
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_find_method_finds_the_given_representation(self):
     """testing if Representation.find() finds the latest version with the
     given representation.
     """
     rep = Representation(self.version1)
     result = rep.find('BBox')
     self.assertEqual(self.version5, result)
コード例 #3
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_find_method_finds_the_given_repr_from_different_repr(self):
     """testing if Representation.find() finds the latest version with the
     given representation from a different representation than the base one.
     """
     rep = Representation(self.version4)
     result = rep.find('ASS')
     self.assertEqual(self.version7, result)
コード例 #4
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_find_method_finds_the_given_repr_from_different_repr(self):
     """testing if Representation.find() finds the latest version with the
     given representation from a different representation than the base one.
     """
     rep = Representation(self.version4)
     result = rep.find('ASS')
     self.assertEqual(self.version7, result)
コード例 #5
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_version_attribute_is_set_to_none(self):
     """testing if setting the version attribute to None is possible
     """
     rep = Representation(self.version1)
     self.assertFalse(rep.version is None)
     rep.version = None
     self.assertTrue(rep.version is None)
コード例 #6
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_find_method_finds_the_given_representation(self):
     """testing if Representation.find() finds the latest version with the
     given representation.
     """
     rep = Representation(self.version1)
     result = rep.find('BBox')
     self.assertEqual(self.version5, result)
コード例 #7
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_version_attribute_is_working_properly(self):
     """testing if the version attribute is working properly
     """
     rep = Representation(self.version1)
     self.assertNotEqual(rep.version, self.version2)
     rep.version = self.version2
     self.assertEqual(rep.version, self.version2)
コード例 #8
0
    def _validate_version(self, version):
        """validates the given version value

        :param version: A stalker.model.version.Version instance
        :return:
        """
        if not version:
            raise RuntimeError(
                'Please supply a valid Stalker Version object!'
            )

        from stalker import Version
        if not isinstance(version, Version):
            raise TypeError(
                'version should be a stalker.models.version.Version instance'
            )

        r = Representation(version=version)

        self.base_take_name = r.get_base_take_name(version)
        if not r.is_base():
            raise RuntimeError(
                'This is not a Base take for this representation series, '
                'please open the base (%s) take!!!' % self.base_take_name
            )

        return version
コード例 #9
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_version_attribute_is_working_properly(self):
     """testing if the version attribute is working properly
     """
     rep = Representation(self.version1)
     self.assertNotEqual(rep.version, self.version2)
     rep.version = self.version2
     self.assertEqual(rep.version, self.version2)
コード例 #10
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_list_all_lists_all_representations(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names.
     """
     expected_result = ['Base', 'BBox', 'ASS', 'GPU']
     rep = Representation(self.version1)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
コード例 #11
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_list_all_lists_all_representations_from_non_base_version(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names by using non base version.
     """
     expected_result = ['Base', 'Hires', 'Midres', 'Lores']
     rep = Representation(self.version10)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
コード例 #12
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_list_all_lists_all_representations_from_non_base_version(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names by using non base version.
     """
     expected_result = ['Base', 'Hires', 'Midres', 'Lores']
     rep = Representation(self.version10)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
コード例 #13
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_list_all_lists_all_representations(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names.
     """
     expected_result = ['Base', 'BBox', 'ASS', 'GPU']
     rep = Representation(self.version1)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
コード例 #14
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
    def test_is_base_method_is_working_properly(self):
        """testing if Representation.is_base() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.is_base())

        rep = Representation(self.version4)
        self.assertFalse(rep.is_base())
コード例 #15
0
ファイル: test_repr.py プロジェクト: theomission/anima
    def test_repr_property_is_working_properly(self):
        """testing if Representation.repr property is working properly
        """
        rep = Representation(self.version1)
        self.assertEqual(rep.repr, 'Base')

        rep = Representation(self.version4)
        self.assertTrue(rep.repr, 'BBox')
コード例 #16
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_get_base_take_name_is_working_properly(self):
     """testing if the Representation.get_base_take_name() method is working
     properly
     """
     rep = Representation()
     self.assertEqual('Main', rep.get_base_take_name(self.version1))
     self.assertEqual('alt1', rep.get_base_take_name(self.version10))
     self.assertEqual('alt1', rep.get_base_take_name(self.version12))
     self.assertEqual('NoRepr', rep.get_base_take_name(self.version18))
コード例 #17
0
ファイル: publish.py プロジェクト: theomission/anima
def check_representations():
    """checks if the referenced versions are all matching the representation
    type of the current version
    """
    ref_reprs = []
    wrong_reprs = []

    v = staging.get('version')

    if v:
        r = Representation(version=v)
        current_repr = r.repr

        # For **Base** representation
        # allow any type of representation to be present in the scene
        if r.is_base():
            return

        for ref in pm.listReferences():
            ref_repr = ref.repr
            if ref_repr is None:
                # skip this one this is not related to a Stalker Version
                continue

            ref_reprs.append([ref, ref_repr])
            if ref_repr != current_repr:
                wrong_reprs.append(ref)
    else:
        return

    if len(wrong_reprs):
        ref_repr_labels = []
        for ref_repr in ref_reprs:
            ref = ref_repr[0]
            repr_name = ref_repr[1]

            color = 'red' if current_repr != repr_name else 'green'

            ref_repr_labels.append(
                '<span style="color: %(color)s">%(repr_name)s</span> -> '
                '%(ref)s' %
                {
                    'color': color,
                    'repr_name': repr_name,
                    'ref': ref.refNode.name()
                }
            )

        raise PublishError(
            'You are saving as the <b>%s</b> representation<br>'
            'for the current scene, but the following references<br>'
            'are not <b>%s</b> representations of their versions:<br><br>'
            '%s' % (
                current_repr, current_repr,
                '<br>'.join(ref_repr_labels[:MAX_NODE_DISPLAY])
            )
        )
コード例 #18
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_get_base_take_name_is_working_properly(self):
     """testing if the Representation.get_base_take_name() method is working
     properly
     """
     rep = Representation()
     self.assertEqual('Main', rep.get_base_take_name(self.version1))
     self.assertEqual('alt1', rep.get_base_take_name(self.version10))
     self.assertEqual('alt1', rep.get_base_take_name(self.version12))
     self.assertEqual('NoRepr', rep.get_base_take_name(self.version18))
コード例 #19
0
ファイル: extension.py プロジェクト: theomission/anima
    def get_base(self):
        """returns the base version instance
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.find(rep.base_repr_name)
コード例 #20
0
ファイル: extension.py プロジェクト: dushyantk/anima
    def get_base(self):
        """returns the base version instance
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.find(rep.base_repr_name)
コード例 #21
0
ファイル: test_repr.py プロジェクト: theomission/anima
    def test_version_attribute_is_not_a_version_instance(self):
        """testing if a TypeError will be raised when the version attribute is
        set to a value other then None and a Version instance
        """
        rep = Representation()
        with self.assertRaises(TypeError) as cm:
            rep.version = 'not a version'

        self.assertEqual(
            'Representation.version should be a '
            'stalker.models.version.Version instance, not str',
            str(cm.exception))
コード例 #22
0
ファイル: publish.py プロジェクト: theomission/anima
def check_representations():
    """checks if the referenced versions are all matching the representation
    type of the current version
    """
    ref_reprs = []
    wrong_reprs = []

    v = staging.get('version')

    if v:
        r = Representation(version=v)
        current_repr = r.repr

        # For **Base** representation
        # allow any type of representation to be present in the scene
        if r.is_base():
            return

        for ref in pm.listReferences():
            ref_repr = ref.repr
            if ref_repr is None:
                # skip this one this is not related to a Stalker Version
                continue

            ref_reprs.append([ref, ref_repr])
            if ref_repr != current_repr:
                wrong_reprs.append(ref)
    else:
        return

    if len(wrong_reprs):
        ref_repr_labels = []
        for ref_repr in ref_reprs:
            ref = ref_repr[0]
            repr_name = ref_repr[1]

            color = 'red' if current_repr != repr_name else 'green'

            ref_repr_labels.append(
                '<span style="color: %(color)s">%(repr_name)s</span> -> '
                '%(ref)s' % {
                    'color': color,
                    'repr_name': repr_name,
                    'ref': ref.refNode.name()
                })

        raise PublishError(
            'You are saving as the <b>%s</b> representation<br>'
            'for the current scene, but the following references<br>'
            'are not <b>%s</b> representations of their versions:<br><br>'
            '%s' % (current_repr, current_repr, '<br>'.join(
                ref_repr_labels[:MAX_NODE_DISPLAY])))
コード例 #23
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
    def test_version_attribute_is_not_a_version_instance(self):
        """testing if a TypeError will be raised when the version attribute is
        set to a value other then None and a Version instance
        """
        rep = Representation()
        with self.assertRaises(TypeError) as cm:
            rep.version = 'not a version'

        self.assertEqual(
            'Representation.version should be a '
            'stalker.models.version.Version instance, not str',
            str(cm.exception)
        )
コード例 #24
0
ファイル: extension.py プロジェクト: dushyantk/anima
    def is_base(self):
        """returns True or False depending to if this is the base
        representation for this reference
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.is_base()
コード例 #25
0
ファイル: extension.py プロジェクト: theomission/anima
    def is_base(self):
        """returns True or False depending to if this is the base
        representation for this reference
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.is_base()
コード例 #26
0
ファイル: test_repr.py プロジェクト: theomission/anima
    def test_is_repr_method_is_working_properly(self):
        """testing if Representation.is_repr() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.is_repr('Base'))

        rep = Representation(self.version4)
        self.assertFalse(rep.is_repr('Base'))

        rep = Representation(self.version4)
        self.assertTrue(rep.is_repr('BBox'))
コード例 #27
0
ファイル: extension.py プロジェクト: theomission/anima
    def is_repr(self, repr_name):
        """returns True or False depending to if this is the requested repr

        :param str repr_name: The representation name
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.is_repr(repr_name=repr_name)
コード例 #28
0
ファイル: extension.py プロジェクト: dushyantk/anima
    def list_all_repr(self):
        """Returns a list of strings representing all the representation names
        of this FileReference

        :return: list of str
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return []

        rep = Representation(version=v)
        return rep.list_all()
コード例 #29
0
ファイル: extension.py プロジェクト: theomission/anima
    def list_all_repr(self):
        """Returns a list of strings representing all the representation names
        of this FileReference

        :return: list of str
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return []

        rep = Representation(version=v)
        return rep.list_all()
コード例 #30
0
ファイル: extension.py プロジェクト: dushyantk/anima
    def has_repr(self, repr_name):
        """checks if the reference has the given representation

        :param str repr_name: The name of the desired representation
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.has_repr(repr_name)
コード例 #31
0
ファイル: extension.py プロジェクト: dushyantk/anima
    def is_repr(self, repr_name):
        """returns True or False depending to if this is the requested repr

        :param str repr_name: The representation name
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.is_repr(repr_name=repr_name)
コード例 #32
0
ファイル: extension.py プロジェクト: theomission/anima
    def has_repr(self, repr_name):
        """checks if the reference has the given representation

        :param str repr_name: The name of the desired representation
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.has_repr(repr_name)
コード例 #33
0
ファイル: extension.py プロジェクト: theomission/anima
    def find_repr(self, repr_name):
        """Finds the representation with the given repr_name.

        :param str repr_name: The desired repr name
        :return: :class:`.Version`
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return

        rep = Representation(version=v)
        rep_v = rep.find(repr_name)

        return rep_v
コード例 #34
0
ファイル: extension.py プロジェクト: dushyantk/anima
    def find_repr(self, repr_name):
        """Finds the representation with the given repr_name.

        :param str repr_name: The desired repr name
        :return: :class:`.Version`
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return

        rep = Representation(version=v)
        rep_v = rep.find(repr_name)

        return rep_v
コード例 #35
0
ファイル: test_repr.py プロジェクト: theomission/anima
    def test_version_argument_is_not_a_version_instance(self):
        """testing if a TypeError will be raised when the version argument is
        not a Version instance
        """
        with self.assertRaises(TypeError) as cm:
            Representation('not a version')

        self.assertEqual(
            'Representation.version should be a '
            'stalker.models.version.Version instance, not str',
            str(cm.exception))
コード例 #36
0
ファイル: extension.py プロジェクト: dushyantk/anima
    def repr(self):
        """the representation name of the related version
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return None

        rep = Representation(version=v)
        return rep.repr
コード例 #37
0
ファイル: test_repr.py プロジェクト: theomission/anima
    def test_has_repr_method_is_working_properly(self):
        """testing if Representation.has_repr() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.has_repr('BBox'))

        rep.version = self.version17
        self.assertTrue(rep.has_repr('Lores'))

        rep.version = self.version19
        self.assertFalse(rep.has_repr('BBox'))
コード例 #38
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
    def test_has_repr_method_is_working_properly(self):
        """testing if Representation.has_repr() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.has_repr('BBox'))

        rep.version = self.version17
        self.assertTrue(rep.has_repr('Lores'))

        rep.version = self.version19
        self.assertFalse(rep.has_repr('BBox'))
コード例 #39
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_version_argument_is_skipped(self):
     """testing if it is possible to skip the version argument
     """
     rep = Representation()
     self.assertTrue(rep.version is None)
コード例 #40
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_find_method_returns_none_for_invalid_repr_name(self):
     """testing if Representation.find() returns None for invalid or
     nonexistent repr name
     """
     rep = Representation(self.version4)
     self.assertTrue(rep.find('NonExists') is None)
コード例 #41
0
ファイル: test_repr.py プロジェクト: sergeneren/anima
 def test_find_method_returns_none_for_invalid_repr_name(self):
     """testing if Representation.find() returns None for invalid or
     nonexistent repr name
     """
     rep = Representation(self.version4)
     self.assertTrue(rep.find('NonExists') is None)
コード例 #42
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_version_argument_is_none(self):
     """testing if the version argument can be None
     """
     rep = Representation(None)
     self.assertTrue(rep.version is None)
コード例 #43
0
ファイル: test_repr.py プロジェクト: theomission/anima
 def test_version_argument_is_working_properly(self):
     """testing if the version argument value is correctly passed to the
     version attribute
     """
     rep = Representation(self.version1)
     self.assertEqual(rep.version, self.version1)