<s> import os , shutil , sys , re , argparse , shutil <EOL> from . import Command <EOL> from arm . util import get_playbook_root <EOL> from git import Repo <EOL> from arm . prompt import query_true_false <EOL> class uninstall ( Command ) : <EOL> help = "<STR_LIT>" <EOL> def __init__ ( self , parser ) : <EOL> parser . description = self . help <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , help = "<STR_LIT>" ) <EOL> def run ( self , argv ) : <EOL> _root = get_playbook_root ( os . getcwd ( ) ) <EOL> _role = os . path . join ( _root , '<STR_LIT>' , argv . role ) <EOL> if not os . path . exists ( _role ) : <EOL> print "<STR_LIT>" % _role <EOL> return <NUM_LIT:1> <EOL> if not os . path . islink ( _role ) : <EOL> print "<STR_LIT>" % _role <EOL> return <NUM_LIT:1> <EOL> _library = os . path . join ( os . path . realpath ( _role ) ) <EOL> repo = Repo ( _library ) <EOL> if repo . git . status ( porcelain = True ) . strip ( ) != '<STR_LIT>' : <EOL> print "<STR_LIT>" % _role <EOL> return <NUM_LIT:1> <EOL> def checkEqual ( lst ) : <EOL> return not lst or lst . count ( lst [ <NUM_LIT:0> ] ) == len ( lst ) <EOL> if not checkEqual ( [ ref . commit for ref in repo . refs ] ) : <EOL> print "<STR_LIT>" <EOL> return <NUM_LIT:1> <EOL> for root , dir , files in os . walk ( _library ) : <EOL> if '<STR_LIT>' in root : <EOL> continue <EOL> for f in files : <EOL> print "<STR_LIT>" % ( root , f ) <EOL> if query_true_false ( '<STR_LIT>' % argv . role , default = True ) : <EOL> os . unlink ( _role ) <EOL> shutil . rmtree ( _library ) <EOL> else : <EOL> print "<STR_LIT>" </s>
