parameters: (self, ns, key)
return_statement: return None
docstring: Search for matching parameter key for search param
          key. Search for key starts at ns and proceeds upwards to
          the root. As such, search_param should only be called with a
          relative parameter name.
  
          search_param's behavior is to search for the first partial match.
          For example, imagine that there are two 'robot_description' parameters:
  
           - /robot_description
           -   /robot_description/arm
           -   /robot_description/base
  
           - /pr2/robot_description
           -   /pr2/robot_description/base
  
          If I start in the namespace /pr2/foo and search for
          'robot_description', search_param will match
          /pr2/robot_description. If I search for 'robot_description/arm'
          it will return /pr2/robot_description/arm, even though that
          parameter does not exist (yet).
  
          @param ns: namespace to begin search from.
          @type  ns: str
          @param key: Parameter key. 
          @type  key: str
          @return: key of matching parameter or None if no matching
          parameter.
          @rtype: str
docstring_summary: Search for matching parameter key for search param
          key. Search for key starts at ns and proceeds upwards to
          the root. As such, search_param should only be called with a
          relative parameter name.
docstring_tokens: Search for matching parameter key for search param key . Search for key starts at ns and proceeds upwards to the root . As such search_param should only be called with a relative parameter name .
function: def search_param(self, ns, key):
          """
          Search for matching parameter key for search param
          key. Search for key starts at ns and proceeds upwards to
          the root. As such, search_param should only be called with a
          relative parameter name.
  
          search_param's behavior is to search for the first partial match.
          For example, imagine that there are two 'robot_description' parameters:
  
           - /robot_description
           -   /robot_description/arm
           -   /robot_description/base
  
           - /pr2/robot_description
           -   /pr2/robot_description/base
  
          If I start in the namespace /pr2/foo and search for
          'robot_description', search_param will match
          /pr2/robot_description. If I search for 'robot_description/arm'
          it will return /pr2/robot_description/arm, even though that
          parameter does not exist (yet).
  
          @param ns: namespace to begin search from.
          @type  ns: str
          @param key: Parameter key. 
          @type  key: str
          @return: key of matching parameter or None if no matching
          parameter.
          @rtype: str
          """
          if not key or is_private(key):
              raise ValueError("invalid key")
          if not is_global(ns):
              raise ValueError("namespace must be global")            
          if is_global(key):
              if self.has_param(key):
                  return key
              else:
                  return None
  
          # there are more efficient implementations, but our hiearchy
          # is not very deep and this is fairly clean code to read.
  
          # - we only search for the first namespace in the key to check for a match
          key_namespaces = [x for x in key.split(SEP) if x]
          key_ns = key_namespaces[0]
  
          #  - corner case: have to test initial namespace first as
          #    negative indices won't work with 0
          search_key = ns_join(ns, key_ns)
          if self.has_param(search_key):
              # resolve to full key
              return ns_join(ns, key) 
          
          namespaces = [x for x in ns.split(SEP) if x]
          for i in range(1, len(namespaces)+1):
              search_key = SEP + SEP.join(namespaces[0:-i] + [key_ns])
              if self.has_param(search_key):
                  # we have a match on the namespace of the key, so
                  # compose the full key and return it
                  full_key = SEP + SEP.join(namespaces[0:-i] + [key]) 
                  return full_key
          return None
function_tokens: def search_param ( self , ns , key ) : if not key or is_private ( key ) : raise ValueError ( "invalid key" ) if not is_global ( ns ) : raise ValueError ( "namespace must be global" ) if is_global ( key ) : if self . has_param ( key ) : return key else : return None # there are more efficient implementations, but our hiearchy # is not very deep and this is fairly clean code to read. # - we only search for the first namespace in the key to check for a match key_namespaces = [ x for x in key . split ( SEP ) if x ] key_ns = key_namespaces [ 0 ] #  - corner case: have to test initial namespace first as #    negative indices won't work with 0 search_key = ns_join ( ns , key_ns ) if self . has_param ( search_key ) : # resolve to full key return ns_join ( ns , key ) namespaces = [ x for x in ns . split ( SEP ) if x ] for i in range ( 1 , len ( namespaces ) + 1 ) : search_key = SEP + SEP . join ( namespaces [ 0 : - i ] + [ key_ns ] ) if self . has_param ( search_key ) : # we have a match on the namespace of the key, so # compose the full key and return it full_key = SEP + SEP . join ( namespaces [ 0 : - i ] + [ key ] ) return full_key return None