o
    `                     @   sN   d dl Z G dd deZdd Zdd Zdd	 Zd
d Zdd ZdddZdS )    Nc                   @   s   e Zd Zdd ZdS )DevErrorc                 C   s   t | d|  d S )Nzprogramming error: %s)RuntimeError__init__)selfmsg r   +/usr/share/virt-manager/virtinst/xmlutil.pyr      s   zDevError.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s    r   c                 C   s    | d u rg S t | ts| gS | S )N)
isinstancelist)lr   r   r   listify   s
   
r   c                 C   sD   | r |  dd} |  dd} |  dd} |  dd} |  d	d
} | S )z=
    Replaces chars ' " < > & with xml safe counterparts
    &z&amp;'z&apos;"z&quot;<z&lt;>z&gt;)replace)xmlr   r   r   
xml_escape   s   r   c                 C   s8   | }| d}|dd D ]}t||}qt||d S )zReturn value of attribute identified by `prop_path`

    Look up the attribute of `obj` identified by `prop_path`
    (separated by "."). If any component along the path is missing an
    `AttributeError` is raised.

    .N)splitgetattr)obj	prop_pathparentpiecespiecer   r   r   get_prop_path&   s
   
r!   c                 C   s:   | }| d}|dd D ]}t||}qt||d |S )zSet value of attribute identified by `prop_path`

    Set the attribute of `obj` identified by `prop_path` (separated by
    ".") to `value`. If any component along the path is missing an
    `AttributeError` is raised.
    r   Nr   )r   r   setattr)r   r   valuer   r   r    r   r   r   set_prop_path6   s
   
r$   c                   C   s
   dt jv S )NVIRTINST_TEST_SUITE)osenvironr   r   r   r   in_testsuiteE   s   
r(   OriginalNewc                 C   s0   dd l }|j| d|d||d}d|S )Nr      )fromfiletofile )difflibunified_diff
splitlinesjoin)origstrnewstrr,   r-   r/   dlistr   r   r   diffI   s   
r6   )r)   r*   )	r&   r   r   r   r   r!   r$   r(   r6   r   r   r   r   <module>   s   	