3
i(]~                 @   s  d dl mZmZ d dlZd dlZd dlmZ d dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZyd dlmZ W n ek
r   ejZY nX d dlZyd dlZW n ek
r   d dlZY nX d dlmZ d dlmZ yd dlmZ W n" ek
r   d dlmZ Y nX d dlmZ d dlZd dlZd dlZd	d
lmZ d dl m!Z!m"Z" d	dl#m$Z$ d	dl#m%Z% d	dl#m&Z& d dl'm(Z( e%j)e&j)e$j)gZ*G dd de+Z,dd Z)e-dkre, Z.e/e.j0  e.j1d  dS )    )absolute_importprint_functionN)md5)	maketrans)NamedTemporaryFile)escape)ConfigParser)gettext   )AptAuth)SourcesListSourceEntry)	shortcuts)ppa)cloudarchive)Gioc               @   s  e Zd ZdZdZeed\ZZZ	edede	diZ
dsd	d
Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Z d5d6 Z!d7d8 Z"d9d: Z#d;d< Z$d=d> Z%d?d@ Z&dAdB Z'dCdD Z(dEdF Z)dGdH Z*dIdJ Z+dKdL Z,dMdN Z-dOdP Z.dQdR Z/dSdT Z0dUdV Z1dWdX Z2dYdZ Z3d[d\ Z4d]d^ Z5d_d` Z6dadb Z7dtdddeZ8dudfdgZ9dvdidjZ:dkdl Z;dmdn Z<dodp Z=dqdr Z>dS )wSoftwarePropertiesz /usr/share/app-install/channels/z$/etc/update-manager/release-upgrades   ZnormalZltsZneverN/c             C   s   |d | _ || _|dkr&tjjd| |dkr2d}|| _|| _t | _t	j
j | _
g | _d| _| j  | j  | j  g | _tj | _t|d| _tj | _tj| j dS )z Provides the core functionality to configure the used software 
        repositories, the corresponding authentication keys and 
        update automation z/etc/popularity-contest.confr   ZDirNz/usr/share/software-properties/F)rootdir)
popconfiler   apt_pkgconfigsetoptionsdatadirr   sourceslist
aptsourcesdistroZ
get_distroZseen_servermodified_sourceslistreload_sourceslistbackup_sourceslistbackup_apt_confZcustom_mirrorsqueueQueuemyqueuer   apt_keyr   ZCancellableZcancellableatexitregisterwait_for_threads)selfr   r   r    r+   G/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py__init___   s(    


zSoftwareProperties.__init__c             C   s.   x(t j D ]}|jt j jkr
|j  q
W dS )z9 wait for all running threads (PPA key fetchers) to exit N)	threading	enumerateZidentZcurrent_threadjoin)r*   tr+   r+   r,   r)      s    z#SoftwareProperties.wait_for_threadsc             C   s:   i | _ x.tjj D ] }tjjtj| }|| j |< qW dS )z$Backup all apt configuration optionsN)apt_conf_backupsoftwarepropertiesCONF_MAPkeysr   r   find_i)r*   optionvaluer+   r+   r,   r"      s    z"SoftwareProperties.backup_apt_confc             C   s>   x0| j j D ]"}tjjtj| t| j |  qW | j  dS )z$Restore the stored apt configurationN)	r2   r5   r   r   r   r3   r4   strwrite_config)r*   r7   r+   r+   r,   restore_apt_conf   s    z#SoftwareProperties.restore_apt_confc             C   s   t jjtjd dkrt jjtjd dkr>tjjdr>tjS t jjtjd dkrpt jjtjd dkrptj	S t jjtjd dkrt jjtjd dkrtj
S dS n6t jjtjd dkrt jjtjd dkrtjS dS dS )z Parse the apt cron configuration. Try to fit a predefined use case 
        and return it. Special case: if the user made a custom 
        configurtation, that we cannot represent it will return None 
autoupdater   
unattendedr
   z/usr/bin/unattended-upgradeautodownloadN)r   r   r6   r3   r4   ospathexistsUPDATE_INST_SECUPDATE_DOWNLOADUPDATE_NOTIFYZUPDATE_MANUAL)r*   r+   r+   r,   get_update_automation_level   s    z.SoftwareProperties.get_update_automation_levelc             C   s  |t jkr<tjjt jd td tjjt jd td n|t jkrxtjjt jd td tjjt jd td n|t jkrtjjt jd td tjjt jd td nHtjjt jd td tjjt jd td tjjt jd td | j	  dS )z Set the apt periodic configurtation to the selected 
        update automation level. To synchronize the cache update and the 
        actual upgrading function, the upgrade function, e.g. unattended, 
        will run every day, if enabled. r=   r
   r>   r   r<   N)
r3   rB   r   r   r   r4   r9   rC   rD   set_modified_config)r*   stater+   r+   r,   set_update_automation_level   s    


z.SoftwareProperties.set_update_automation_levelc             C   s:   |t jjtjd ks6t jjtjd t| | j  dS )z8Set the interval in which we check for available updatesr<   N)r   r   r6   r3   r4   r   r9   rF   )r*   Zdaysr+   r+   r,   set_update_interval   s    z&SoftwareProperties.set_update_intervalc             C   s   t jjtjd S )z3 Returns the interval of the apt periodic cron job r<   )r   r   r6   r3   r4   )r*   r+   r+   r,   get_update_interval   s    z&SoftwareProperties.get_update_intervalc             C   sl   t jj| js| jS t }|j| j |jddrf|jddj	 }x"| j
j D ]\}}||krN|S qNW | jS )z
    return the release upgrade policy:
     RELEASE_UPGRADES_NORMAL,
     RELEASE_UPGRADES_LTS,
     RELEASE_UPGRADES_NEVER
    ZDEFAULTZPrompt)r?   r@   rA   RELEASE_UPGRADES_CONFRELEASE_UPGRADES_NORMALr   readZ
has_optiongetlowerrelease_upgrades_policy_mapitems)r*   parsertypekvr+   r+   r,   get_release_upgrades_policy   s    z.SoftwareProperties.get_release_upgrades_policyc             C   s   t jj| js2t| jd}|jd| j|   dS t| jd}tdd}xF|D ]>}|j }|j	 j
dr~|jd| j|   qN|j|d	  qNW |j  tj| j|j tj|j| j dS )
z
    set the release upgrade policy:
     RELEASE_UPGRADES_NORMAL,
     RELEASE_UPGRADES_LTS,
     RELEASE_UPGRADES_NEVER
     wz[DEFAULT]
Prompt=%s
Trzw+)modepromptz
Prompt=%s

)r?   r@   rA   rK   openwriterP   r   striprO   
startswithflushshutilZcopymodenamecopy)r*   ifoutliner+   r+   r,   set_release_upgrades_policy   s    

z.SoftwareProperties.set_release_upgrades_policyc             C   s   t jj| jrt| jj jd}d}xT|D ]L}y0|jd\}}|dkr^|jdj dkr^d}W q, t	k
rv   w,Y q,X q,W |S dS dS )	z Will return True if the user wants to participate in the popularity 
        contest. Otherwise it will return False. Special case: if no 
        popcon is installed it will return False r[   F=ZPARTICIPATE"yesTN)
r?   r@   rA   r   r\   rM   splitr^   rO   
ValueError)r*   linesZactiverg   keyr8   r+   r+   r,   get_popcon_participation   s    
z+SoftwareProperties.get_popcon_participationc          
      s   |dkrd nd t jj| jrLt| jd} fdd|D }W dQ R X nRt }|jtdd	jd
 |j }g }|j	d|  |j	dt
   |j	d t| jdj| dS )z? Enable or disable the participation in the popularity contest Trk   norX   c                s   g | ]}t jd d  |qS )z^(PARTICIPATE=)(".+?")z\1"%s")resub).0rg   )r8   r+   r,   
<listcomp>  s   z@SoftwareProperties.set_popcon_pariticipation.<locals>.<listcomp>Nz/dev/urandomrbi   zMY_HOSTID="%s"
zPARTICIPATE="%s"
zUSE_HTTP="yes"
rW   )r?   r@   rA   r   r\   r   updaterM   Z	hexdigestappendr9   
writelines)r*   Z
is_helpfulr   rn   midr+   )r8   r,   set_popcon_pariticipation  s    

z,SoftwareProperties.set_popcon_pariticipationc             C   s(  t | jjdk rd| j_dS d| j_i }g }|j| jj |j| jj xH|D ]@}|j|kr~x0|jD ]}||j j	| qdW qNt
|j||j< qNW t | jjdkr| jj|| jj< xp| jjD ]d}|j|ks|j|krt t
||j t
|jA dkpt t
|j| jjA dk rd| j_dS qW dS )zReturn True if all distro componets are also available as 
       source code. Otherwise return Flase. Special case: If the
       configuration cannot be represented return Noner
   FTr   N)lenr   source_code_sourcesZget_source_codeextendmain_sourceschild_sourcestemplatecompsaddr   cdrom_sourcesZcdrom_compssource_templateenabled_comps)r*   Z	templatessourcessourcecompr+   r+   r,   get_source_code_state'  s0    


"z(SoftwareProperties.get_source_code_statec             C   s   xDd|j fd|jfd|j fd|j fgD ]\}}td||f  q*W |jrx4d|jjfd|jjfgD ]\}}td||f  qfW td d	S )
z4Print the data of a source entry to the command linezURI:zComps:zEnabled:zValid:z %s %sz	MatchURI:zBaseURI:r[   N)urir   disabledinvalidprintr   Z	match_uribase_uri)r*   r   Zlabelr8   r+   r+   r,   print_source_entryN  s    

z%SoftwareProperties.print_source_entryc             C   s0   t d x| jD ]}t |j  qW t d dS )zPrint the complete sources.listzSTART SOURCES.LIST:zEND SOURCES.LIST
N)r   r   r9   )r*   r   r+   r+   r,   massive_debug_output[  s    z'SoftwareProperties.massive_debug_outputc             C   s    || j _| j j|}| j  |S )z! change the main download server )r   default_serverZchange_serverset_modified_sourceslist)r*   Zserverresr+   r+   r,   change_main_download_serverb  s    z.SoftwareProperties.change_main_download_serverc             C   s   | j j| | j  dS )z Enable a component of the distroN)r   enable_componentr   )r*   r   r+   r+   r,   r   i  s    z#SoftwareProperties.enable_componentc             C   s   | j j| | j  dS )z!Disable a component of the distroN)r   disable_componentr   )r*   r   r+   r+   r,   r   n  s    z$SoftwareProperties.disable_componentc             C   s&   x | j jjD ]}|j|kr|S qW d S )N)r   r   Zchildrenrb   )r*   rb   r   r+   r+   r,   _find_template_from_strings  s    
z-SoftwareProperties._find_template_from_stringc             C   sp   t |tr| j|}x&| jjD ]}|j|kr| jj| qW x&| jjD ]}|j|krF| jj| qFW | j	  dS )z7Enable a child repo of the distribution main repositoryN)

isinstancer9   r   r   r   r   r   remover~   r   )r*   r   r   r+   r+   r,   disable_child_sourcex  s    



z'SoftwareProperties.disable_child_sourcec             C   sL   t |tr| j|}|jdkr(| jj}n|j}| jj||jd | j  dS )z7Enable a child repo of the distribution main repositoryN)r   dist)	r   r9   r   r   r   r   Z
add_sourcerb   r   )r*   r   Z	child_urir+   r+   r,   enable_child_source  s    



z&SoftwareProperties.enable_child_sourcec             C   sJ   g }|j | jj |j | jj x| jjD ]}| jj| q*W | j  dS )z%Remove all distro source code sourcesN)r   r   r   r   r~   r   r   r   )r*   r   r   r+   r+   r,   disable_source_code_sources  s    z.SoftwareProperties.disable_source_code_sourcesc          	   C   s   g }|j | jj |j | jj x| jjD ]}| jj| q*W x:|D ]2}| jjd|j|j	|j
d| jjj|d |j qDW xF| jjD ]:}| jjd| jjj| jjj|j
d| jjj|d |j qW | j  dS )z0Enable source code source for all distro sourceszdeb-srczAdded by software-propertiesr
   N)r   r   r   r   r~   r   r   r   r   r   r   listindexfiler   r   r   rb   r   )r*   r   r   r+   r+   r,   enable_source_code_sources  s,    
z-SoftwareProperties.enable_source_code_sourcesc             C   s8   g | _ x,| jjD ] }t|j|jd}| j j| qW dS )z+Store a backup of the source.list in memory)rg   r   N)sourceslist_backupr   r   r   rg   r   rx   )r*   r   Z
source_bkpr+   r+   r,   r!     s    z%SoftwareProperties.backup_sourceslistc             C   s.   | j   x | jjD ]}t||kr|S qW d S )N)r    r   r   r9   )r*   rg   r   r+   r+   r,   _find_source_from_string  s
    z+SoftwareProperties._find_source_from_stringc             C   s*   t |tr| j|}|j |_| j  dS )z&Enable or disable the selected channelN)r   r9   r   r   r   )r*   r   r+   r+   r,   toggle_source_use  s    


z$SoftwareProperties.toggle_source_usec             C   sV   xPt | jjD ]@\}}t||kr| jj| j}t||| jj|< | j  dS qW dS )NTF)r/   r   r   r9   r   r   r   )r*   Z	old_entryZ	new_entryr   entryr   r+   r+   r,   replace_source_entry  s    z'SoftwareProperties.replace_source_entryc             C   s   | j   | j  dS )zNRevert all settings to the state when software-properties 
       was launchedN)r;   revert_sourceslist)r*   r+   r+   r,   revert  s    zSoftwareProperties.revertc             C   sJ   g | j _x,| jD ]"}t|j|jd}| j jj| qW | j  | j  dS )z6Restore the source list from the startup of the dialog)rg   r   N)	r   r   r   r   rg   r   rx   save_sourceslistr    )r*   r   Zsource_resetr+   r+   r,   r     s    z%SoftwareProperties.revert_sourceslistc             C   s0   d| _ | jr| jjr| j  | j  | j  dS )zCThe sources list was changed and now needs to be saved and reloadedTN)r   r   Zmassive_debugr   r   r    )r*   r+   r+   r,   r     s
    z+SoftwareProperties.set_modified_sourceslistc             C   s   | j   dS )z+Write the changed apt configuration to fileN)r:   )r*   r+   r+   r,   rF     s    z&SoftwareProperties.set_modified_configc             C   st  |j dkr|jr|dt|jj |jf }t|jdkrRx|jD ]}|d| 7 }q>W |jdkrl|dtd 7 }|d|j	 7 }nFd	|j	|jf }x|jD ]}|d| 7 }qW |jdkr|dtd 7 }|S d
|j j
 }|jdkr|dtd 7 }|jr|d|j 7 }|j jdkrlxZ|jD ]P}|j j|rZx:|j jD ] }|j|kr4|d|j
 7 }q4W n|d| 7 }qW |S dS )z5Render a nice output to show the source in a treeviewNz<b>%s</b> %sr
   z %sdeb-srcrpm-srcz(Source Code)z
%sz<b>%s %s</b>z	<b>%s</b>z (%s)zSource CodeF)r   r   )r   r   )r   r   )r   commentr   r^   r   r}   r   rS   _r   descriptionchildZhas_componentZ
componentsrb   )r*   r   contentscr   r+   r+   r,   render_source  s:    




z SoftwareProperties.render_sourcec             C   s   d}d}d}d}t dd}|jr@d}|jj}|jj| jkr^d}nd|j|j|jf }|jr^d}|j	j
drnd}|||||j|fS )z&extract attributes to sort the sourcesr
   
0123456789Z
9876543210r   z%s %s %ssrc)r   r   r   Zdistributionr   r   r   r   r   rS   find	translate)r*   r   Zcur_sysZhas_templateZhas_commentZ	is_sourceZrevert_numbersZdescr+   r+   r,   get_comparable  s"    
z!SoftwareProperties.get_comparablec             C   sh   g }x^| j jD ]R}|j r|| jjkr|| jjkr|| jjkr|| jjkr|| jjkr|j	| qW |S )z>Return a list of sources that are not part of the distribution)
r   r   r   r   r   r   r   Zdisabled_sourcesr~   rx   )r*   Zisv_sourcesr   r+   r+   r,   get_isv_sources4  s    z"SoftwareProperties.get_isv_sourcesc             C   s   | j jS )z-Return the list of CDROM based distro sources)r   r   )r*   r+   r+   r,   get_cdrom_sourcesA  s    z$SoftwareProperties.get_cdrom_sourcesc             C   s   |j | jjkdfS )zReturn a tuple: the first value describes if a component is enabled
       in the Internet repositories. The second value describes if the
       first value is inconsistent.F)rb   r   Zdownload_comps)r*   r   r+   r+   r,   get_comp_download_stateE  s    z*SoftwareProperties.get_comp_download_statec             C   s   g }x&| j jD ]}|j|kr|j|j qW t|dkrTt| j jt|A dkrTdS t|dkr|t| j jt|A dkr|dS dS dS )zReturn a tuple: the first value describes if a component is enabled
       in one of the child source that matcth the given template. 
       The second value describes if the first value is inconsistent.r   TFN)TF)FT)FF)r   r   r   r   r   r}   r   r   )r*   r   r   r   r+   r+   r,   get_comp_child_stateL  s    
z'SoftwareProperties.get_comp_child_statec             C   s"   | j j  g | _| jj| j  d S )N)r   ZrefreshZsourceslist_visibler   Zget_sources)r*   r+   r+   r,   r    a  s    
z%SoftwareProperties.reload_sourceslistc             C   sH  | j d | j d | j d g}x0|D ]}tjj|r"P q"W td t|d d d}tjj|rtj|tj }|tj	@ std|  tj
|d	 x|D ]}g }tjj|rt|d
j }tjjd}t|d}x<|D ]4}x.|j D ]}	|jd|	 dkrP qW |j| qW x*|j D ]}
|jd|
|j|
f  qW |j  qW dS )z+Write the current apt configuration to filez/etc/apt/apt.conf.d/10periodicz#/etc/apt/apt.conf.d/20auto-upgradesz+/etc/apt/apt.conf.d/15adept-periodic-updatezNo config found, creating oner   rW   z/etc/cron.daily/aptz file '%s' not executable, fixingi  rX   zAPT::PeriodiczAPT::Periodic::%szAPT::Periodic::%s "%s";
N)r   r?   r@   isfiler   r\   rA   statST_MODES_IXUSRchmod	readlinesr   r   Zsubtreer   r   r]   r6   close)r*   Z	conffilesre   ZacZpermZperiodicZcontentZcnfrg   ro   rd   r+   r+   r,   r:   f  s8    




zSoftwareProperties.write_configc             C   s   | j jd | j j  dS )zRBackup the existing sources.list files and write the current 
       configurationz.saveN)r   ZbackupZsave)r*   r+   r+   r,   r     s    z#SoftwareProperties.save_sourceslistc             C   sz   t |}tjj| jrvx^tjd| j D ]J}xDt|D ]8}|j jdrJq6|t |kr6tjj	tjj
|d S q6W q(W dS )zs
    helper that checks if a given line is in the source list
    return the channel name or None if not found
    z	%s/*.list#r   N)r   r?   r@   rA   CHANNEL_PATHglobr\   r^   r_   splitextbasename)r*   srclineZsrcentryre   rg   r+   r+   r,   _is_line_in_whitelisted_channel  s     z2SoftwareProperties._is_line_in_whitelisted_channelc             C   s   | j t|S )N)*check_and_add_key_for_whitelisted_shortcutshortcut_handler)r*   r   r+   r+   r,   *check_and_add_key_for_whitelisted_channels  s    z=SoftwareProperties.check_and_add_key_for_whitelisted_channelsc                s   |j jjjjj d\}}j|}|rDdj|f }j| |jdjoVjj	if  fdd}t
j|d}|j  |S )z
    helper that adds the gpg key of the channel to the apt
    keyring *if* the channel is in the whitelist
    /usr/share/app-install/channels or it is a public Launchpad PPA.
    )codenamer   z	%s/%s.key	keyserverc                 sf    \} }d}y| f |}|s d}W n. t k
rP } zd}t|}W Y d d }~X nX jj||g d S )Nz
Added key.zFailed to add key.F)	Exceptionr9   r%   Zput)funckwargsmsgrete)cdatar*   r+   r,   addkey_func  s    
zRSoftwareProperties.check_and_add_key_for_whitelisted_shortcut.<locals>.addkey_func)target)expandr   r   r{   rO   r   r   add_keyr   r   r.   ZThreadstart)r*   shortcutr   Z_fnameZchannelZkeypr   workerr+   )r   r*   r,   r     s    

z=SoftwareProperties.check_and_add_key_for_whitelisted_shortcutc             C   s   dS )z) abstract interface to keep the UI alive Nr+   )r*   r+   r+   r,   update_interface  s    z#SoftwareProperties.update_interfacec             C   s^   |j ds|S |j d }y|jddd }W n tk
rF   d}Y nX d|| jj|f }|S )z
    short cut - this:
      apt-add-repository http://packages.medibuntu.org free non-free
    same as
      apt-add-repository 'deb http://packages.medibuntu.org/ '$(lsb_release -cs)' free non-free'
    Zhttpr    r
   mainzdeb %s %s %s)r_   rl   
IndexErrorr   r   )r*   rg   ZrepoZareasr+   r+   r,   expand_http_line  s    

z#SoftwareProperties.expand_http_lineFc             C   s   | j t|j |dS )z*
    Add a source for the given line.
    )r   enable_source_code)add_source_from_shortcutr   r^   )r*   rg   r   r+   r+   r,   add_source_from_line  s    
z'SoftwareProperties.add_source_from_linec          	   C   s<  |j | jj| jjj d\}}| j|}|r0dnd}||dd  }t||}t||}|jsd|jrhdS | j|}	| j	j
|j|j|j|j|j|j|jd | j	j
||j|j|j|j|j|jd | j  |	r|	jd |	j rtjd	| jj \}
}|
stj|| jr8| jjr8d
dl}|j }|j|jd dS )z
    Add a source with the given shortcut and add the signing key if the
    site is in whitelist or the shortcut implementer adds it.
    )r   r   zdeb-srcz	# deb-srcr   NF)r   r   architectures   z$Error: retrieving gpg key timed out.r   )Zsources_listT)r   r   r   r{   rO   r   r   r   r   r   r   rS   r   r   r   r   r   r   r   r0   ZisAliver   ShortcutExceptionr%   rN   r   rw   aptZCache)r*   r   r   Zdeb_liner   Zdebsrc_entry_typeZdebsrc_lineZnew_deb_entryZnew_debsrc_entryr   resultr   r   cacher+   r+   r,   r     sJ    









z+SoftwareProperties.add_source_from_shortcutTc             C   s   |rrt |tr&| j|}| j|d nH|dk	rn| j|d tj|}d|_d|_| j|d d|_| j|d dS t |tr| j|}|dkrdS |jtj	j
dkr| jjjtd|jd y| jj| W n tk
r   Y nX | j  dS )zRemove the given sourceTNFzdeb-srczDir::Etc::sourcelist )r   )r   r9   r   remove_sourcerc   rS   r   r   r   r   Z	find_filer   r   rx   r   r   rm   r   )r*   r   Zremove_source_coder+   r+   r,   r     s0    




z SoftwareProperties.remove_sourcec          	   C   s8   t jj|sdS y| jj|}| j  |S    dS dS )z7Add a gnupg key to the list of trusted software vendorsFN)r?   r@   rA   r&   r   KeysModified)r*   r@   r   r+   r+   r,   r   >  s    zSoftwareProperties.add_keyc             C   s,   t j }|j|jd |j  | j|jS )z<Add a gnupg key from a utf-8 data string (e.g. copy-n-paste)zutf-8)tempfiler   r]   encoder`   r   rb   )r*   ZkeydataZtmpr+   r+   r,   add_key_from_dataI  s    z$SoftwareProperties.add_key_from_datac          	   C   s(   y| j j| | j  dS    dS dS )z<Remove a gnupg key from the list of trusted software vendorsTFN)r&   Zrmr   )r*   Zkeyidr+   r+   r,   
remove_keyP  s    zSoftwareProperties.remove_keyc          	   C   s&   y| j j  | j  dS    dS dS )z Run apt-key update TFN)r&   rw   r   )r*   r+   r+   r,   update_keysY  s    
zSoftwareProperties.update_keys)NNr   )F)F)T)?__name__
__module____qualname__r   rK   r   rangerL   ZRELEASE_UPGRADES_LTSZRELEASE_UPGRADES_NEVERrP   r-   r)   r"   r;   rE   rH   rI   rJ   rV   rh   rp   r|   r   r   r   r   r   r   r   r   r   r   r   r!   r   r   r   r   r   r   rF   r   r   r   r   r   r   r    r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r+   r+   r+   r,   r   L   st   
)'


	'-

/
(	r   c             C   s4   x t D ]}|| }|d k	r|S qW tjd|  d S )NzUnable to handle input '%s')_SHORTCUT_FACTORIESr   r   )r   factoryr   r+   r+   r,   r   b  s
    
r   __main__)2Z
__future__r   r   r   rc   Zhashlibr   rr   r?   r   ra   r.   r'   r   stringr   ImportErrorr9   r   r#   r$   r   Zxml.sax.saxutilsr   configparserr   r	   r   r   Zaptsources.distror3   r   Zaptsources.sourceslistr   r   r   r   r   r   Zgi.repositoryr   r   r   objectr   r   Zspr   rV   rh   r+   r+   r+   r,   <module>   sd         	
