def addWrappedCmd(cmdname, cmd=None):
    if cmd is None:
        cmd = getattr(maya.cmds, cmdname)

    #if cmd.__name__ == 'dummyFunc': print cmdname

    def wrappedCmd(*args, **kwargs):
        # we must get the cmd each time, because maya delays loading of functions until they are needed.
        # if we don't reload we'll keep the dummyFunc around
        new_cmd = getattr(maya.cmds, cmdname)
        #print args, kwargs
        # convert args to mel-friendly representation
        new_args = getMelRepresentation(args)

        # flatten list. this is necessary for list of components.  see Issue 71.  however, be sure that it's not an empty list/tuple
        if len(new_args) == 1 and util.isIterable(new_args[0]) and len(new_args[0]): #isinstance( new_args[0], (tuple, list) ):
            new_args = new_args[0]

        new_kwargs = getMelRepresentation(kwargs)
        #print new_args, new_kwargs
        try:
            res = new_cmd(*new_args, **new_kwargs)
        except objectErrorType, e:
            m = objectErrorReg.match(str(e))
            if m:
                import pymel.core.general
                obj = m.group(1)
                raise pymel.core.general._objectError(obj)

            else:
                # re-raise error
                raise

        # when editing, some of maya.cmds functions return empty strings and some return idiotic statements like 'Values Edited'.
        # however, for UI's in particular, people use the edit command to get a pymel class for existing objects.
        # return None when we get an empty string
        try:
            if res=='' and kwargs.get('edit', kwargs.get('e', False) ):
                return None
        except __HOLE__:
            pass
        return res

    wrappedCmd.__doc__ = cmd.__doc__

    oldname = getattr(cmd, '__name__', None)
    if isinstance(oldname, str):
        # Don't use cmd.__name__, as this could be 'stubFunc'
        wrappedCmd.__name__ = getCmdName(cmd)
    else:
        wrappedCmd.__name__ = str(cmdname)

    # for debugging, to make sure commands got wrapped...
    #wrappedCmd = _testDecorator(wrappedCmd)

    # so that we can identify that this is a wrapped maya command
    setattr( _thisModule, cmdname, wrappedCmd )
    #globals()[cmdname] = wrappedCmd
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.5/pymel/internal/pmcmds.py/addWrappedCmd