<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> import os <EOL> import shutil <EOL> import phlsys_pid <EOL> import abdi_repoargs <EOL> import abdt_fs <EOL> def getFromfilePrefixChars ( ) : <EOL> return None <EOL> def setupParser ( parser ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT:name>' , <EOL> type = str , <EOL> metavar = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def _remove_file_ignore_fail ( path ) : <EOL> try : <EOL> os . remove ( path ) <EOL> except OSError as e : <EOL> print ( "<STR_LIT>" . format ( path ) ) <EOL> print ( "<STR_LIT>" . format ( e ) ) <EOL> print ( ) <EOL> def _remove_dir_ignore_fail ( path ) : <EOL> try : <EOL> shutil . rmtree ( path ) <EOL> except OSError as e : <EOL> print ( "<STR_LIT>" . format ( path ) ) <EOL> print ( "<STR_LIT>" . format ( e ) ) <EOL> print ( ) <EOL> def process ( args ) : <EOL> fs = abdt_fs . make_default_accessor ( ) <EOL> with fs . lockfile_context ( ) : <EOL> pid = fs . get_pid_or_none ( ) <EOL> if pid is not None and phlsys_pid . is_running ( pid ) : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> repo_name = args . name <EOL> if args . lookup_url : <EOL> repo_name = _determine_name_from_url ( fs , repo_name ) <EOL> _remove_file_ignore_fail ( fs . layout . repo_try ( repo_name ) ) <EOL> _remove_file_ignore_fail ( fs . layout . repo_ok ( repo_name ) ) <EOL> _remove_dir_ignore_fail ( fs . layout . repo ( repo_name ) ) <EOL> fs . remove_repo_config ( repo_name ) <EOL> def _determine_name_from_url ( fs , repo_url ) : <EOL> """<STR_LIT>""" <EOL> repo_config_path_list = fs . repo_config_path_list ( ) <EOL> repo_name_config_list = abdi_repoargs . parse_config_file_list ( <EOL> repo_config_path_list ) <EOL> candidate_names = [ ] <EOL> for repo_name , repo_config in repo_name_config_list : <EOL> url = abdi_repoargs . get_repo_url ( repo_config ) <EOL> if repo_url == url : <EOL> candidate_names . append ( repo_name ) <EOL> if not candidate_names : <EOL> raise Exception ( "<STR_LIT>" . format ( <EOL> url = repo_url ) ) <EOL> if len ( candidate_names ) > <NUM_LIT:1> : <EOL> raise Exception ( "<STR_LIT>" . format ( <EOL> url = repo_url , <EOL> names = candidate_names ) ) <EOL> return candidate_names [ <NUM_LIT:0> ] </s>
