def getMethod(service, doc, args):
    """ Locates the method to be executed 
    Capable of finding some methods implicitly
    Displays assistance if method isn't identified

    Args:
      service: The service object being used
      doc: Documentation describing the service
      args: List containing the method path to be followed

    Returns:
      A tuple of the meta-info describing the method, 
      the method itself, and the parameters for the method
    """
    obj = doc
    attr = service
    i = 0
    while 'resources' in obj or 'methods' in obj:
        if i < len(args) and 'resources' in obj and args[i] in obj['resources']:
            attr = getattr(attr, args[i])
            obj = obj['resources'][args[i]]
            i = i + 1
        elif i < len(args) and 'methods' in obj and args[i] in obj['methods']:
            attr = getattr(attr, args[i])
            obj = obj['methods'][args[i]]
            i = i + 1
        elif ('resources' in obj and not 'methods' in obj and
              len(obj['resources']) == 1):
            attr = getattr(attr, obj['resources'].keys()[0])
            obj = obj['resources'][obj['resources'].keys()[0]]
        elif 'methods' in obj and not 'resources' in obj and len(obj['methods']) == 1:
            attr = getattr(attr, obj['methods'].keys()[0])
            obj = obj['methods'][obj['methods'].keys()[0]]
        else:
            print 'Did not recognize task.'
            if 'methods' in obj:
                LOG.error('Possible methods: ' + ', '.join(obj['methods']))
            if 'resources' in obj:
                LOG.error('Possible resources: ' + ', '.join(obj['resources']))
            return
        if not 'id' in obj:
            attr = attr()
    return obj, attr, args[i:]
dataset/ETHPy150Open vinitkumar/googlecl/src/googlecl/discovery/__init__.py/getMethod/original