def bytes_to_elementtree(bytes_or_file):
 if isinstance(bytes_or_file, compat.basestring):
  s = bytes_or_file
 else:
  s = bytes_or_file.read()
 if compat.is_py3:
  s = _unicode(s, 'utf-8')
 f = compat.StringIO(s)
 tree = ET.ElementTree(file=f)
 return tree

def bytes_to_elementtree ( bytes_or_file ) : if isinstance ( bytes_or_file , compat . basestring ) : s = bytes_or_file else : s = bytes_or_file . read ( ) if compat . is_py3 : s = _unicode ( s , 'utf-8' ) f = compat . StringIO ( s ) tree = ET . ElementTree ( file = f ) return tree
given a bytestring or a file-like object that will produce them .