#NEWLINE# def parse_categories( self , headers ) : #NEWLINE# #INDENT# kind = action = None #NEWLINE# mixins = collections . Counter ( ) #NEWLINE# schemes = collections . defaultdict ( list ) #NEWLINE# try : #NEWLINE# #INDENT# categories = headers [ 'Category' ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise exception . OCCIInvalidSchema ( 'No categories' ) #NEWLINE# #UNINDENT# for ctg in _quoted_split ( categories ) : #NEWLINE# #INDENT# ll = _quoted_split ( ctg , '; ' ) #NEWLINE# d = { #NEWLINE# #INDENT# 'term' : ll [ 0 ] , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# d . update ( dict ( [ _split_unquote ( i ) for i in ll [ 1 : ] ] ) ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# raise exception . OCCIInvalidSchema ( 'Unable to parse category' ) #NEWLINE# #UNINDENT# ctg_class = d . get ( 'class' , None ) #NEWLINE# ctg_type = ( '%(scheme)s%(term)s' % d ) #NEWLINE# if ( ctg_class == 'kind' ) : #NEWLINE# #INDENT# if ( kind is not None ) : #NEWLINE# #INDENT# raise exception . OCCIInvalidSchema ( 'Duplicated Kind' ) #NEWLINE# #UNINDENT# kind = ctg_type #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ctg_class == 'action' ) : #NEWLINE# #INDENT# if ( action is not None ) : #NEWLINE# #INDENT# raise exception . OCCIInvalidSchema ( 'Duplicated action' ) #NEWLINE# #UNINDENT# action = ctg_type #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ctg_class == 'mixin' ) : #NEWLINE# #INDENT# mixins [ ctg_type ] += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# schemes [ d [ 'scheme' ] ] . append ( d [ 'term' ] ) #NEWLINE# #UNINDENT# if ( action and kind ) : #NEWLINE# #INDENT# raise exception . OCCIInvalidSchema ( 'Action and kind together?' ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'category' : ( kind or action ) , #NEWLINE# 'mixins' : mixins , #NEWLINE# 'schemes' : schemes , #NEWLINE# #UNINDENT# }