<commit_before>import pymel.core as pymel
import collections
from omtk import constants
from omtk.core.classModule import Module
from omtk.core.classCtrl import BaseCtrl
from omtk.core.utils import decorator_uiexpose
from omtk.modules import rigIK
from omtk.modules import rigFK
from omtk.modules import rigTwistbone
from omtk.libs import libRigging
from omtk.libs import libCtrlShapes
from omtk.libs import libAttr
from omtk.libs import libPython


class BaseAttHolder(BaseCtrl):
    def __createNode__(self, size=None, refs=None, **kwargs):
        # Resolve size automatically if refs are provided.
        ref = next(iter(refs), None) if isinstance(refs, collections.Iterable) else refs
        if size is None and ref is not None:
            size = libRigging.get_recommended_ctrl_size(ref)
        else:
            size = 1.0

        node = libCtrlShapes.create_shape_attrholder(size=size, **kwargs)

        # Hide default keyable attributes
        node.t.set(channelBox=False)
        node.r.set(channelBox=False)
        node.s.set(channelBox=False)

        return node


class CtrlElbow(BaseCtrl):
    def __createNode__(self, size=None, refs=None, *args, **kwargs):
        # Resolve size automatically if refs are provided
        ref = next(iter(refs), None) if isinstance(refs, collections.Iterable) else refs
        if size is None and ref is not None:
            size = libRigging.get_recommended_ctrl_size(ref) * 1.25
        else:
            size = 1.0

        return libCtrlShapes.create_shape_cross(size=size, **kwargs)


class Limb(Module):
    """
    Generic IK/FK setup. Twistbones are included.
    """
    kAttrName_State = 'fkIk'  # The name of the IK/FK attribute
    _CLASS_SYS_IK = rigIK.IK
    _CLASS_SYS_FK = rigFK.FK
    _CLASS_CTRL_ATTR = BaseAttHolder
    _CLASS_CTRL_ELBOW = CtrlElbow
    _CLASS_SYS_TWIST = rigTwistbone.Twistbone

    def __init__(self, *args, **kwargs):
        super(Limb, self).__init__(*args, **kwargs)
        self.sysIK = None
        self.sysFK = None
        self.sys_twist = []
        self.create_twist = True
        self.ctrl_elbow = None
        self.attState = None
        self.offset_ctrl_ik = None
        self.ctrl_attrs = None
        self.STATE_IK = 1.0
        self.STATE_FK = 0.0

    def build(self, *args, **kwargs):
        super(Limb, self).build(*args, **kwargs)

        nomenclature_anm = self.get_nomenclature_anm()
        nomenclature_rig = self.get_nomenclature_rig()

        # Resolve IK system name

        # Create IK system
        self.sysIK = self.init_module(
            self._CLASS_SYS_IK,
            self.sysIK,
            inputs=self.chain_jnt,
            suffix='ik',
        )
        self.sysIK.build(constraint=False, **kwargs)

        # Create FK system
        self.sysFK = self.init_module(
            self._CLASS_SYS_FK,
            self.sysFK,
            inputs=self.chain_jnt,
            suffix='fk',
        )
        self.sysFK.build(constraint=False, **kwargs)

        # Create twistbone system if needed
        if self.create_twist:
            num_twist_sys = self.sysIK.iCtrlIndex
            # Ensure the twistbone list have the proper size
            libPython.resize_list(self.sys_twist, num_twist_sys)

            # If the IK system is a quad, we need to have two twist system<commit_msg>Fix fk ctrl name in limbs to keep input name<commit_after>import pymel.core as pymel
import collections
from omtk import constants
from omtk.core.classModule import Module
from omtk.core.classCtrl import BaseCtrl
from omtk.core.utils import decorator_uiexpose
from omtk.modules import rigIK
from omtk.modules import rigFK
from omtk.modules import rigTwistbone
from omtk.libs import libRigging
from omtk.libs import libCtrlShapes
from omtk.libs import libAttr
from omtk.libs import libPython


class BaseAttHolder(BaseCtrl):
    def __createNode__(self, size=None, refs=None, **kwargs):
        # Resolve size automatically if refs are provided.
        ref = next(iter(refs), None) if isinstance(refs, collections.Iterable) else refs
        if size is None and ref is not None:
            size = libRigging.get_recommended_ctrl_size(ref)
        else:
            size = 1.0

        node = libCtrlShapes.create_shape_attrholder(size=size, **kwargs)

        # Hide default keyable attributes
        node.t.set(channelBox=False)
        node.r.set(channelBox=False)
        node.s.set(channelBox=False)

        return node


class CtrlElbow(BaseCtrl):
    def __createNode__(self, size=None, refs=None, *args, **kwargs):
        # Resolve size automatically if refs are provided
        ref = next(iter(refs), None) if isinstance(refs, collections.Iterable) else refs
        if size is None and ref is not None:
            size = libRigging.get_recommended_ctrl_size(ref) * 1.25
        else:
            size = 1.0

        return libCtrlShapes.create_shape_cross(size=size, **kwargs)


class Limb(Module):
    """
    Generic IK/FK setup. Twistbones are included.
    """
    kAttrName_State = 'fkIk'  # The name of the IK/FK attribute
    _CLASS_SYS_IK = rigIK.IK
    _CLASS_SYS_FK = rigFK.FK
    _CLASS_CTRL_ATTR = BaseAttHolder
    _CLASS_CTRL_ELBOW = CtrlElbow
    _CLASS_SYS_TWIST = rigTwistbone.Twistbone

    def __init__(self, *args, **kwargs):
        super(Limb, self).__init__(*args, **kwargs)
        self.sysIK = None
        self.sysFK = None
        self.sys_twist = []
        self.create_twist = True
        self.ctrl_elbow = None
        self.attState = None
        self.offset_ctrl_ik = None
        self.ctrl_attrs = None
        self.STATE_IK = 1.0
        self.STATE_FK = 0.0

    def build(self, *args, **kwargs):
        super(Limb, self).build(*args, **kwargs)

        nomenclature_anm = self.get_nomenclature_anm()
        nomenclature_rig = self.get_nomenclature_rig()

        # Resolve IK system name

        # Create IK system
        self.sysIK = self.init_module(
            self._CLASS_SYS_IK,
            self.sysIK,
            inputs=self.chain_jnt,
            suffix='ik',
        )
        self.sysIK.build(constraint=False, **kwargs)

        # Create FK system
        self.sysFK = self.init_module(
            self._CLASS_SYS_FK,
            self.sysFK,
            inputs=self.chain_jnt,
            suffix='fk',
        )
        # We want to keep the name of the input on the fk
        self.sysFK._FORCE_INPUT_NAME = True
        self.sysFK.build(constraint=False, **kwargs)

        # Create twistbone system if needed
        if self.create_twist:
            num_twist_sys = self.sysIK.iCtrlIndex
            # Ensure the twistbone list have the proper size
            libPython.resize_list(self.sys_twist, num_twist_sys)

            # If the IK system is a quad, we need to have two twist system
{'fraction_non_alphanumeric': 0.08160259242892914, 'fraction_numerical': 0.00324053616143762, 'mean_word_length': 2.4607543323139653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2465345', 'n_tokens_mistral': 2246, 'n_tokens_neox': 2103, 'n_words': 544}