o
    ”ÔcdM  ã                   @   sè   d dl Z d dlZd dlZd dlZdd„ Zdd„ ZedkrrdZeej	ƒdkr9ej	d d	kr/d
Zn!e
dƒ e d¡ ne
dƒ e ¡ d  ZedkrLedƒZnedƒZedv rle j d¡Zeeƒd krfeeƒ dS e
dƒ dS e
dƒ dS dS )é    Nc                 C   s€   | D ];}t j |¡r=t ||d ¡ t|dƒ}t|d dƒ}|D ]}| |¡dkr.| |¡ q | ¡  | ¡  t  	|d¡ qd S )Nú~ÚwÚréÿÿÿÿiÀ  )
ÚosÚpathÚexistsÚshutilÚmoveÚopenÚfindÚwriteÚcloseÚchmod)ÚfilelistÚ	searchExpÚfileÚdestinationÚsourceÚline© r   ú,/home/birch/BIRCH/install-scripts/nobirch.pyÚbirchremove   s   

€€ör   c                 C   s  t dƒ tj d¡}t dƒ tj | d¡}tj d|¡ dd l}z| ¡  W n   Y t dƒ tj |d¡g}t|dƒ t d	ƒ tj |d
¡tj |d¡g}t|dƒ t dƒ tj |d¡tj |d¡tj |d¡tj |d¡tj |d¡g}t|dƒ t dƒ t dƒ t dƒ t dƒ d S )Nzgetting home directoryr   zRemoving launcher linksÚscriptr   zWriting .loginz.loginz#_BIRCHzWriting .cshrc & .tcshrcz.cshrcz.tcshrcz:Writing Bourne Shell .profile, .bash_profile, .zshrc, etc.z.profilez.bash_profilez.bash_loginz.bashrcz.zshrczDone - nobirch.py!z;Logout and login again so that the changes can take effect.z)If you wish to restore BIRCH access, typez$BIRCH/admin/newuser)	Úprintr   r   Ú
expanduserÚjoinÚsysÚinsertÚ
rmlauncherr   )ÚBIRCHÚHOMEÚ	pathtoaddr   ÚFILELISTr   r   r   Únobirch"   s8   

ü
r$   Ú__main__Úné   z-QÚYzUseage: nobirch.py [-Q]zE>>> You are about remove access to the BIRCH system for this account!Ú2z">>> Type y to continue, n to exit
)r(   Úyr    z<>>> $BIRCH environment variable not set. Aborting nobirch.pyz&>>> exiting nobirch. No files changed.)r   Úplatformr	   r   r   r$   Ú__name__ÚchoiceÚlenÚargvr   ÚexitÚpython_versionÚpversionÚ	raw_inputÚinputÚenvironÚgetr    r   r   r   r   Ú<module>   s2   +
å