o a@sndZddlZddlZddlmZzddlZWney)ede dYnwddZ Gdd d Z dS) z>This module implements facilities to deal with Debian control.N)Loggerz=Please install 'python3-debian' in order to use this utility.cCsz|jWn tyYnw|||<z |||WdSty&YdSwd}|D]}|r8||}|||<||krBd}|||<q+|sK|||<dSdS)zeInsert new_item into directly after item_before New items added to a dictionary are appended.NFT) order_afterAttributeErrorKeyErrorpop) paragraph item_beforenew_item new_value item_founditemvaluer4/usr/lib/python3/dist-packages/devscripts/control.py _insert_after s2     rc@sJeZdZdZddZddZddZdd d Zd d Zd dZ ddZ dS)Controlz Represents a debian/control filecCsvtj|s Jd|||_g|_t|dd}tjj |D]}|j |q WddS1s4wYdS)Nz%s does not exist.utf8)encoding) ospathisfilefilename paragraphsopendebiandeb822Deb822iter_paragraphsappend)selfrsequencerrrr__init__Bs"zControl.__init__cC|jddS)z*Returns the value of the Maintainer field.r Maintainerrgetr rrrget_maintainerJzControl.get_maintainercCr#)z8Returns the value of the XSBC-Original-Maintainer field.rXSBC-Original-Maintainerr%r'rrrget_original_maintainerNr)zControl.get_original_maintainerNcCsb|r||_ddd|jD}t|jd}||dWddS1s*wYdS)zSaves the control file. cSg|]}|qSr)dump).0xrrr Vz Control.save..wbzutf-8N)rjoinrrwriteencode)r rcontent control_filerrrsaveRs "z Control.savecCs||jdd<dS)z'Sets the value of the Maintainer field.rr$N)r)r maintainerrrrset_maintainerZszControl.set_maintainercCs8d|jdvr||jdd<dSt|jddd|dS)z5Sets the value of the XSBC-Original-Maintainer field.r*rr$N)rr)r original_maintainerrrrset_original_maintainer^s  zControl.set_original_maintainercCs@|jD]}|D]}||d}ddd|D||<qqdS)z1Strips all trailing spaces from the control file.r,cSr-r)rstrip)r/linerrrr1kr2z1Control.strip_trailing_spaces..N)rsplitr4)r rr linesrrrstrip_trailing_spacesfs zControl.strip_trailing_spaces)N) __name__ __module__ __qualname____doc__r"r(r+r9r;r=rBrrrrr?s  r) rFrsysdevscripts.loggerr debian.deb822r ImportErrorerrorexitrrrrrrs