oB]c@s:ddlmZddlmZdefdYZdS(i(tStringIO(t chop_commentt HostsConfcBsGeZdZdZdZdZdZdZdZRS(cCs||_d|_dS(N(t_texttNonet _contents(tselfttext((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyt__init__s cCs+|jdkr'|j|j|_ndS(N(RRt_parseR(R((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pytparsescCsy|jg}xb|jD]W\}}|dkr|\}}t|rq|d|krq|j|dqqqqW|S(Ntoptionii(R Rtlentappend(Rtiptoptionst line_typet componentstpiecest_tail((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyt get_entrys   cCs|jg}x|jD]\}}|dkrK|j||fqq|\}}t|rv|d|krvqt|r|j|t|fqqW||_dS(NR i(R RR R tlist(RRt n_entriesRRRR((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyt del_entries"s     cGs:|j|jjd||gt|dffdS(NR t(R RR R(RRtcanonical_hostnametaliases((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyt add_entry1s  cCsg}x|jD]}t|jsG|jd|gfqnt|jd\}}t|s|jd|gfqn|jd|jd|gfqW|S(Ntblankt#t all_commentR (t splitlinesR tstripR RtsplitR(Rtcontentstentriestlinetheadttail((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyR 6s &cCs|jt}x|jD]\}}|dkrM|jd|dq|dkrq|jd|dq|dkr|\}}g|D]}t|^q}dj|}|jd||fqqW|jS(NRs%s iRR s s%s%s (R RRtwritetstrtjointgetvalue(RR"RRRR&tp((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyt__str__Cs      ( t__name__t __module__RR RRRR R,(((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyRs     N(tsixRtcloudinit.distros.parsersRtobjectR(((sC/usr/lib/python2.7/site-packages/cloudinit/distros/parsers/hosts.pyts