#NEWLINE# def _parse_server_status( body ) : #NEWLINE# #INDENT# status = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# q = pq ( etree . fromstring ( body ) ) #NEWLINE# boxes = q ( '.box' ) #NEWLINE# for box in boxes : #NEWLINE# #INDENT# box_q = pq ( etree . fromstring ( etree . tostring ( box ) ) ) #NEWLINE# category = box_q ( '.category' ) [ 0 ] . text . strip ( ) #NEWLINE# status [ category ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# servers = box_q ( '.server' ) #NEWLINE# for server in servers : #NEWLINE# #INDENT# server_q = pq ( etree . fromstring ( etree . tostring ( server ) ) ) #NEWLINE# server_name = server_q ( '.server-name' ) [ 0 ] . text . strip ( ) . replace ( ' ' , '' ) #NEWLINE# if server_name : #NEWLINE# #INDENT# status_icon = server_q ( '.status-icon' ) [ 0 ] #NEWLINE# class_ = status_icon . get ( 'class' ) #NEWLINE# if class_ : #NEWLINE# #INDENT# st = 0 #NEWLINE# if ( 'up' in class_ ) : #NEWLINE# #INDENT# st = 1 #NEWLINE# #UNINDENT# status [ category ] [ server_name ] = st #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return status