def get_method_id(self, method_ref):
    'method_ref can be one of:\n           - a encoded_method object\n           - integer method index'
    method_ids = self.get_method_ids()
    if method_ids:
        if isinstance(method_ref, encoded_method):
            if (method_ref.method_idx < len(method_ids)):
                return method_ids[method_ref.method_idx]
        elif isinstance(method_ref, numbers.Integral):
            if (method_ref < len(method_ids)):
                return method_ids[method_ref]
        else:
            raise ValueError(('invalid method_ref type %s' % type(method_ref)))
    return None
method_ref can be one of:
- a encoded_method object
- integer method index
def get_method_id(self, method_ref):
    'method_ref can be one of:\n           - a encoded_method object\n           - integer method index'
    method_ids = self.get_method_ids()
    if method_ids:
        if isinstance(method_ref, encoded_method):
            if (method_ref.method_idx < len(method_ids)):
                return method_ids[method_ref.method_idx]
        elif isinstance(method_ref, numbers.Integral):
            if (method_ref < len(method_ids)):
                return method_ids[method_ref]
        else:
            raise ValueError(('invalid method_ref type %s' % type(method_ref)))
    return None