<s> import os <EOL> import re <EOL> import commands <EOL> def get_vimrc_locations ( ) : <EOL> version_info = commands . getoutput ( "<STR_LIT>" ) <EOL> return [ os . path . expandvars ( x ) for x in re . findall ( r'<STR_LIT>' , version_info ) ] <EOL> def get_git_repo ( bundle_str ) : <EOL> parts = bundle_str . split ( "<STR_LIT:/>" ) <EOL> if len ( parts ) == <NUM_LIT:2> : <EOL> return '<STR_LIT>' % ( parts [ <NUM_LIT:0> ] , parts [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return bundle_str <EOL> def main ( ) : <EOL> bundles = [ ] <EOL> for vimrc_file in get_vimrc_locations ( ) : <EOL> vimrc = open ( vimrc_file , "<STR_LIT:r>" ) . read ( ) <EOL> bundles += re . findall ( re . compile ( '<STR_LIT>' , re . IGNORECASE ) , vimrc ) <EOL> bundle_dir = os . path . expandvars ( "<STR_LIT>" ) <EOL> if not os . path . exists ( bundle_dir ) : <EOL> os . makedirs ( bundle_dir ) <EOL> for bundle in set ( bundles ) : <EOL> url = get_git_repo ( bundle ) <EOL> dest_folder = url . split ( "<STR_LIT:/>" ) [ - <NUM_LIT:1> ] . split ( "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> clone_command = '<STR_LIT>' % { <EOL> '<STR_LIT>' : url , <EOL> '<STR_LIT>' : os . path . normpath ( '<STR_LIT>' % ( bundle_dir , dest_folder ) ) , <EOL> } <EOL> print "<STR_LIT>" % bundle <EOL> status = commands . getstatusoutput ( clone_command ) <EOL> if status [ <NUM_LIT:0> ] is not <NUM_LIT:0> : <EOL> print status [ <NUM_LIT:1> ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
