def getobj(txt, last=False):
 txt_end = ''
 for (startchar, endchar) in ['[]', '()']:
  if txt.endswith(endchar):
   pos = txt.rfind(startchar)
   if pos:
    txt_end = txt[pos:]
    txt = txt[:pos]
 tokens = re.split(SYMBOLS, txt)
 token = None
 try:
  while ((token is None) or re.match(SYMBOLS, token)):
   token = tokens.pop()
  if token.endswith('.'):
   token = token[:(-1)]
  if token.startswith('.'):
   return None
  if last:
   token += txt[(txt.rfind(token) + len(token))]
  token += txt_end
  if token:
   return token
 except IndexError:
  return None

def getobj ( txt , last = False ) : txt_end = '' for ( startchar , endchar ) in [ '[]' , '()' ] : if txt . endswith ( endchar ) : pos = txt . rfind ( startchar ) if pos : txt_end = txt [ pos : ] txt = txt [ : pos ] tokens = re . split ( SYMBOLS , txt ) token = None try : while ( ( token is None ) or re . match ( SYMBOLS , token ) ) : token = tokens . pop ( ) if token . endswith ( '.' ) : token = token [ : ( - 1 ) ] if token . startswith ( '.' ) : return None if last : token += txt [ ( txt . rfind ( token ) + len ( token ) ) ] token += txt_end if token : return token except IndexError : return None
return the last valid object name in string .