def doIt(self, args):
        # parse the arguments
        try:
            argData = OM.MArgDatabase(self.syntax(), args)  # if this fails, it will raise its own exception...
        except:
            pass  # ...so we can just pass here
        else:
            # read all of the arguments and store them to the appropriate data attributes
            # manually confirm the object list
            sel = OM.MSelectionList()
            argData.getObjects(sel)
            # ordinarily, the command is designed to only operate on a single object at a time
            if not sel.length() == 1:
                # edit and query mode require one object
                if argData.isEdit() or argData.isQuery():
                    raise Exception(
                        'This command requires exactly 1 argument to be specified or selected;  found %i.' % sel.length())
                # create mode supports a variety of patterns
                else:
                    isShoulderSpecified = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag)
                    isSpineSpecified = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineObjectFlag)
                    # selection list is either [spine, constraintObject] with shoulder flag, or [shoulder, constrainedObject] with spine flag
                    if sel.length() == 2:
                        if not (isShoulderSpecified or isSpineSpecified):
                            raise Exception(
                                'Selection list of length 2 requires either a spine or a shoulder be specified with a flag.')
                        else:
                            if isSpineSpecified:
                                sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                                sel.getDagPath(sel.length() - 1, self.__spineObjectArg)
                            else:
                                sel.getDagPath(0, self.__spineObjectArg)
                            if isShoulderSpecified:
                                sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kShoulderObjectFlag, 0))
                                sel.getDagPath(sel.length() - 1, self.__shoulderObjectArg)
                            else:
                                sel.getDagPath(0, self.__shoulderObjectArg)
                            sel.getDagPath(1, self.__constrainedObjectArg)
                    # selection list is either [spine, shoulder, constraintObject], or has spine or shoulder specified with flags
                    elif sel.length() == 3:
                        if isSpineSpecified:
                            sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                            sel.getDagPath(sel.length() - 1, self.__spineObjectArg)
                        else:
                            sel.getDagPath(0, self.__spineObjectArg)
                        if isShoulderSpecified:
                            sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                            sel.getDagPath(sel.length() - 1, self.__shoulderObjectArg)
                        else:
                            sel.getDagPath(1, self.__shoulderObjectArg)
                        sel.getDagPath(2, self.__constrainedObjectArg)
                    else:
                        raise Exception(
                            'This command requires 3 or fewer arguments to be specified or selected;  found %i.' % sel.length())
            else:
                iter = OM.MItSelectionList(sel, OM.MFn.kDependencyNode)
                while not iter.isDone():
                    # in edit or query mode, the object must be an am_shoulderConstraint node
                    if argData.isEdit() or argData.isQuery():
                        iter.getDependNode(self.__shoulderConstraintNodeArg)
                        self.__shoulderConstraintNodeFn.setObject(self.__shoulderConstraintNodeArg)
                        if not (self.__shoulderConstraintNodeFn.typeId() == AM_ShoulderConstraintNode.kPluginNodeId):
                            raise Exception('The provided dependency node %s is not of type %s.' % (
                                self.__shoulderConstraintNodeFn.name(), AM_ShoulderConstraintNode.kPluginNodeTypeName))
                    # in create mode, only a transform node is accepted
                    else:
                        selectedObject = OM.MObject()
                        iter.getDependNode(selectedObject)
                        if selectedObject.hasFn(OM.MFn.kTransform):
                            OM.MDagPath.getAPathTo(selectedObject, self.__constrainedObjectArg)
                        else:
                            selectedObjectFn = OM.MFnDependencyNode(selectedObject)
                            raise Exception('%s is not a valid transform node.' % selectedObjectFn.name())
                        # verify that a shoulder and spine have been specified
                        if not argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag) or not argData.isFlagSet(
                                AM_ShoulderConstraintCmd.kSpineObjectFlag):
                            raise Exception(
                                'When only one argument is specified in create mode, shoulder and spine flags must be present.')
                    iter.next()

            # perform the query
            if argData.isQuery():
                self.__shoulderObjectArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag)
                self.__spineObjectArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineObjectFlag)
                self.__raisedAngleArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kRaisedAngleFlag)
                self.__shoulderAimAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderAimFlag)
                self.__shoulderFrontAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderFrontFlag)
                self.__spineAimAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineAimFlag)
                self.__spineFrontAxisArg = argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineFrontFlag)
                self.doItQuery()
            # set up other arguments and call redoIt() for create or edit mode
            else:
                # validate the name flag
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kNameFlag):
                    self.__shoulderConstraintNodeName = argData.flagArgumentString(AM_ShoulderConstraintCmd.kNameFlag,
                                                                                   0)
                    if (len(self.__shoulderConstraintNodeName) < 1 or self.__shoulderConstraintNodeName[
                        0].isalpha() is False or len(re.split('\W+', self.__shoulderConstraintNodeName)) > 1):
                        raise Exception(
                            '%s is not a valid node name. Did you type it correctly?' % self.__shoulderConstraintNodeName)
                # validate dagpaths
                sel = OM.MSelectionList()
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderObjectFlag):
                    sel.clear()
                    try:
                        sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kShoulderObjectFlag, 0))
                        sel.getDagPath(0, self.__shoulderObjectArg)
                    except:
                        raise Exception(
                            '%s is not a valid node name. Did you type it correctly?' % argData.flagArgumentString(
                                AM_ShoulderConstraintCmd.kShoulderObjectFlag, 0))
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineObjectFlag):
                    sel.clear()
                    try:
                        sel.add(argData.flagArgumentString(AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                        sel.getDagPath(0, self.__spineObjectArg)
                    except:
                        raise Exception(
                            '%s is not a valid node name. Did you type it correctly?' % argData.flagArgumentString(
                                AM_ShoulderConstraintCmd.kSpineObjectFlag, 0))
                # get raised angle arg
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kRaisedAngleFlag):
                    self.__raisedAngleArg = argData.flagArgumentString(AM_ShoulderConstraintCmd.kRaisedAngleFlag, 0)
                else:
                    self.__raisedAngleArg = None
                # get vector args
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderAimFlag):
                    self.__shoulderAimAxisArg = OM.MVector(
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderAimFlag, 0),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderAimFlag, 1),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderAimFlag, 2))
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kShoulderFrontFlag):
                    self.__shoulderFrontAxisArg = OM.MVector(
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderFrontFlag, 0),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderFrontFlag, 1),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kShoulderFrontFlag, 2))
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineAimFlag):
                    self.__spineAimAxisArg = OM.MVector(
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineAimFlag, 0),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineAimFlag, 1),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineAimFlag, 2))
                if argData.isFlagSet(AM_ShoulderConstraintCmd.kSpineFrontFlag):
                    self.__spineFrontAxisArg = OM.MVector(
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineFrontFlag, 0),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineFrontFlag, 1),
                        argData.flagArgumentDouble(AM_ShoulderConstraintCmd.kSpineFrontFlag, 2))
                # set the isEditUsed flag only after all arguments have been stored to ensure command is not added to queue before it has done anything
                self.__isEditUsed = argData.isEdit()
                self.__isQueryUsed = False
                self.redoIt()
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/maya/plugins/2014/win64/AM_ShoulderConstraint.py/AM_ShoulderConstraintCmd.doIt/original