def analyze_company_name(name, stripNotes=False):
 if stripNotes:
  name = split_company_name_notes(name)[0]
 o_name = name
 name = name.strip()
 country = None
 if name.startswith('['):
  name = re.sub('[!@#$\\(\\)\\[\\]]', '', name)
 elif name.endswith(']'):
  idx = name.rfind('[')
  if (idx != (-1)):
   country = name[idx:]
   name = name[:idx].rstrip()
 if (not name):
  raise IMDbParserError(('invalid name: "%s"' % o_name))
 result = {'name': name}
 if country:
  result['country'] = country
 return result

def analyze_company_name ( name , stripNotes = False ) : if stripNotes : name = split_company_name_notes ( name ) [ 0 ] o_name = name name = name . strip ( ) country = None if name . startswith ( '[' ) : name = re . sub ( '[!@#$\\(\\)\\[\\]]' , '' , name ) elif name . endswith ( ']' ) : idx = name . rfind ( '[' ) if ( idx != ( - 1 ) ) : country = name [ idx : ] name = name [ : idx ] . rstrip ( ) if ( not name ) : raise IMDbParserError ( ( 'invalid name: "%s"' % o_name ) ) result = { 'name' : name } if country : result [ 'country' ] = country return result
return a dictionary with the name and the optional country keys .