
    g                     @    d dl Z d dlZd dlmc mZ ddlmZ ddZd Z	y)    N   )compatc                 d   t        | t        j                        r| }ntt        | t        j                        rE|t        j
                  j                  }|t        j                         }| j                  |d      }nt        j                  |       }|j                  dd      j                         S )zTry to decode byte strings to unicode.
    This can only be a guess, but this might be better than failing.
    It is safe to use this on numbers or strings that are already unicode.
    ignore  )
isinstancer   unicodebytessysstdinencodinglocalegetpreferredencodingdecodereplacestrip)stringr   unicode_strings      (/opt/Tautulli/lib/musicbrainzngs/util.py_unicoder      s    
 &&..)	FFLL	)yy))H224Hx:/!!&"-3355    c                     t        | t        j                        r| }n| j                         }t        j                  rt        |d      }t        j                  |      }t        j                  |      }|S )zdGiven a bytestring or a file-like object that will produce them,
	parse and return an ElementTree.
	zutf-8)file)	r	   r   
basestringreadis_py3r   StringIOETElementTree)bytes_or_filesftrees       r   bytes_to_elementtreer%      s[     }f//0!!
MMq'!__Q
Ar   )N)
r   r   xml.etree.ElementTreeetreer    r   r   r   r   r%    r   r   <module>r)      s       " " 6$r   