
    e:                         d Z ddlZddlZddlZddlZddlmZ ddlZddlm	Z	 ddl
mZ ddlmZ ddlmZ da G d	 d
e      Zd Zd Zd ZddZddZd Zy)a  
configfile.py - Human-readable text configuration file library 
Copyright 2010  Luke Campagnola
Distributed under MIT/X11 license. See license.txt for more information.

Used for reading and writing dictionary objects to a python-like configuration
file format. Data structures may be nested and contain any data type as long
as it can be converted to/from a string using repr and eval.
    N)OrderedDict   )units)ColorMap)Point)QtCorec                       e Zd ZddZd Zy)
ParseErrorNc                 h    || _         || _        || _        || _        t        j                  | |       y N)lineNumlinemessagefileName	Exception__init__)selfr   r   r   r   s        6/usr/lib/python3/dist-packages/pyqtgraph/configfile.pyr   zParseError.__init__   s.    	 4)    c                     | j                   d| j                  z  }nd| j                   | j                  fz  }|| j                  dt        j	                  |       z  }|S )Nz!Error parsing string at line %d:
z+Error parsing config file '%s' at line %d:

)r   r   r   r   __str__)r   msgs     r   r   zParseError.__str__#   sW    == 6EC@DMMSWS_S_C``C499i&7&7&=>>
r   r   )__name__
__module____qualname__r   r    r   r   r
   r
      s    *r   r
   c                 ~    t        |       }t        |d      5 }|j                  |       d d d        y # 1 sw Y   y xY w)Nwt	genStringopenwritedatafnamesfds       r   writeConfigFiler)   ,   7    $A	eT	 b
     3<c                 >   t         Et        j                  j                  t         |       }t        j                  j	                  |      r|} t        j                  j                  t        j                  j                  |             a i |t        j                  }t        |d<   t        |d<   t        |d<   t        |d<   t        |d<   t        |d<   t        j                   |d<   dD ]  }t#        t        |      ||<    	 t%        | d	      5 }|j'                         }d d d        j)                  d
d      }|j)                  dd      }t+        |fi |d   }|S # 1 sw Y   >xY w# t,        $ r | t/        j0                         d   _          t5        d| z          xY w)Nr   readConfigFiler   r   r   datetimearray)int8uint8int16uint16float16int32uint32float32int64uint64float64rtz
r   r   z#Error while reading config file %s:)GLOBAL_PATHospathjoinexistsdirnameabspathr   allUnitsr   r-   r   r   r   r.   numpyr/   getattrr"   readreplaceparseStringr
   sysexc_infor   print)r&   scopefname2localdtyper(   r'   r%   s           r   r-   r-   2   ss    k5177>>&!E''//"''//%"89K'u''E&E-,E
E'NE(O E* E*[[E'N0 - ue,e	-% 	"	A	IIfd#IIdD!1&&q) K	 	
  %*q"3U:;s$    E& E;E& E#E& &6Fc                 ~    t        |       }t        |d      5 }|j                  |       d d d        y # 1 sw Y   y xY w)Natr    r$   s       r   appendConfigFilerS   \   r*   r+   c                    d}| D ]  }t        |      }t        |      dk(  rt        |        t        d      |d   dk(  sd|v rt        |        t        d|z        t	        | |   t
              r!|||z   dz   z  }|t        | |   |dz         z  }|||z   d	z   t        | |         j                  d
d      z   d
z   z  } |S )N r   z,blank dict keys not allowed (see data above) :zKdict keys must not contain ":" or start with spaces [offending key is "%s"]z:
z    : r   \
)	strlenrL   r   
isinstancedictr!   reprrH   )r%   indentr'   ksks        r   r!   r!   b   s    
A QVr7a<$KJKKa5C<3"9$Kilnnood1gt$"u$$A47FVO44A"t#d47m&;&;D&&IIDPPAQ Hr   c                    t               }t        | t              r`| j                  dd      } | j	                  d      } | D cg c]2  }t        j                  d|      st        j                  d|      r1|4 } }t        | |         }|dz
  }	 	 |dz  }|t        |       k\  rni| |   }t        j                  d|      st        j                  d|      sHt        |      }||k  r|dz  }n ||kD  rt        d||fz  |dz   |      d|vrt        d	|dz   |      |j                  d      \  }}	}
|j                         }|
j                         }
t        |      dk  rt        d
|dz   |      |d   dk(  r(|d   dk(  r 	 t        ||      }t        |      t        u r|}t        j                  d|
      r|
d   dk7  r	 t        |
|      }n<|dz   t        |       k\  st        | |dz            |k  ri }nt)        | fd|dz   i|\  }}|||<   ~||fS c c}w #  Y |xY w#  t!        j"                         d   }t        d|
d|j$                  j&                  dt        |      d|dz   |      xY w# t        $ r   t!        j"                         d   }t        |j$                  j&                  dt        |      |dz         xY w)NrY   rU   r   z\Sz\s*#r   z-Indentation is incorrect. Expected %d, got %drW   zMissing colonzMissing name preceding colonr   ()#zError evaluating expression 'z': [rX   ]start)r   r\   rZ   rH   splitresearchmatchmeasureIndentr[   r
   	partitionstripevaltypetuplerJ   rK   	__class__r   rI   )linesrh   rM   r%   lr_   lnlineIndr`   pvk1valexs                 r   rI   rI   s   s   =D%fb)D!!VqRYYua%8'STAUVV5<(F	B<O!GBSZb	A xx#299UA+> $A&Ga !PTZ\cSd!dfhijfjlmnn !| "Q$::C(IQ1	A	A 1vz !?AqIIts{qu|aBBx5( yy"qts{Dq%.C
 a43u:%uRT{)Cv)MC !,E GA G GIRDGk z :G WVD*B$UVXZXdXdXmXmorsuov%wz|}~z~  BC  D  D  O\\^AR\\%:%:CGDbdANNsR   HH5HC0I1  H I1 >H 
AI1 HI1 AI..I1 1AKc                 n    d}|t        |       k  r$| |   dk(  r|dz  }|t        |       k  r	| |   dk(  r|S )Nr   rV   r   )r[   )r'   ns     r   rm   rm      sA    	A
c!f*1	Q c!f*1Hr   )rU   )r   )__doc__r.   r>   rj   rJ   collectionsr   rE   rU   r   colormapr   r   Qtr   r=   r   r
   r)   r-   rS   r!   rI   rm   r   r   r   <module>r      s\     	 	 
 #      "(T"IVr   