+eT @sddlmZddlZyLddlmZmZejdkrWddlmZnddlmZWn.e k rddlmZmZmZYnXddl Z ddl Z ddl Z ddlZdZGd d d eZed kred Zeejd deejd deejddeejd ddeejd ddeejd ddndS))print_functionN) NoOptionErrorNoSectionErrorz3.2) ConfigParser)SafeConfigParser)rrrz&/etc/update-manager/release-upgrades.dc@sIeZdZdddddZddZddZd d ZdS) DistUpgradeConfigzDistUpgrade.cfgNcCsEtj|tjdddgdtjddjdj}||_tj j |d|rx|d|}ntj j ||}g|_ |rx.t j |d D]}|j j|qWn|j |g7_ |dkrt}n|dk r1x.t j |d D]}|j j|qWn|j|j dS) NZ lsb_releasez-cz-sstdoutZuniversal_newlinesTr.z/*.cfg)r__init__ subprocessPopenPIPEZ communicatestripdatadirospathexistsjoinZ config_filesglobappendCONFIG_OVERRIDE_DIRread)selfrnameZ override_dirZ defaults_dirZ from_releaseZmaincfgZcfgrE/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeConfigParser.pyr s&       zDistUpgradeConfig.__init__c Csyzt|tkr%|j||St|tkrG|j||St|tkri|j||S|j||SWntt fk r|SYnXdS)N) typeboolZ getbooleanfloatZgetfloatintZgetintgetrr)rsectionoptiondefaultrrrgetWithDefault0sz DistUpgradeConfig.getWithDefaultc CsUy|j||}Wnttfk r4gSYnXdd|jdD}|S)NcSsg|]}|jqSr)r).0xrrr @s z-DistUpgradeConfig.getlist..,)r rrsplit)rr!r"Ztmpitemsrrrgetlist;s  zDistUpgradeConfig.getlistc Csy|j||}Wntk r.gSYnXtjj|j|}tjj|smtjd|nddt |D}dd|DS)NzgetListFromFile: no '%s' foundcSsg|]}|jqSr)r)r%r&rrrr'Js z5DistUpgradeConfig.getListFromFile..cSs3g|])}|jd r|dk r|qS)#) startswith)r%srrrr'Ks ) r rrrrrrloggingerroropen)rr!r"filenamepr*rrrgetListFromFileBs  z!DistUpgradeConfig.getListFromFile)__name__ __module__ __qualname__r r$r+r5rrrrrs  r__main__r ZDistroZMetaPkgsZ ForcedPurgesZSourcesZ ValidMirrorsZ EnableApportTZFooFalse)Z __future__rsys configparserrrversionrr ImportErrorr os.pathrr0rrrr6cprintr+r5r$setrrrrs,  !    9