def parse_tag_namespaces(tag_list):
 namespaces = {}
 for tag in tag_list:
  ns = (((':' in tag) and ('%s:' % tag.rsplit(':', 1)[0])) or '')
  if (ns not in namespaces):
   namespaces[ns] = []
  namespaces[ns].append(tag)
 return namespaces

def parse_tag_namespaces ( tag_list ) : namespaces = { } for tag in tag_list : ns = ( ( ( ':' in tag ) and ( '%s:' % tag . rsplit ( ':' , 1 ) [ 0 ] ) ) or '' ) if ( ns not in namespaces ) : namespaces [ ns ] = [ ] namespaces [ ns ] . append ( tag ) return namespaces
parse a list of tags out into a dict of lists by namespace .