#NEWLINE# def parse( self , img_info_output ) : #NEWLINE# #INDENT# 'Returns dictionary based on human-readable output from\n        `qemu-img info`\n\n        Known problem: breaks if path contains opening parenthesis `(` or\n        colon `:`' #NEWLINE# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for l in img_info_output . split ( '\n' ) : #NEWLINE# #INDENT# if ( not l . strip ( ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# ( name , value ) = l . split ( ':' , 1 ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# name = name . strip ( ) #NEWLINE# if ( name == 'backing file' ) : #NEWLINE# #INDENT# file_end = value . find ( '(' ) #NEWLINE# if ( file_end == ( - 1 ) ) : #NEWLINE# #INDENT# file_end = len ( value ) #NEWLINE# #UNINDENT# result [ 'backing-filename' ] = value [ : file_end ] . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name == 'file format' ) : #NEWLINE# #INDENT# result [ 'format' ] = value . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return result