def check_path_action(self):
class CheckPathAction(argparse.Action):<EOL><INDENT>def __call__(self, parser, args, value, option_string=None):<EOL><INDENT>if type(value) is list:<EOL><INDENT>value = value[<NUM_LIT:0>]<EOL><DEDENT>user_value = value<EOL>if option_string == '<STR_LIT:None>':<EOL><INDENT>if not os.path.isdir(value):<EOL><INDENT>_current_user = os.path.expanduser("<STR_LIT>")<EOL>if not value.startswith(_current_user)and not value.startswith(os.getcwd()):<EOL><INDENT>if os.path.isdir(os.path.join(_current_user, value)):<EOL><INDENT>value = os.path.join(_current_user, value)<EOL><DEDENT>elif os.path.isdir(os.path.join(os.getcwd(), value)):<EOL><INDENT>value = os.path.join(os.getcwd(), value)<EOL><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT><DEDENT><DEDENT>elif option_string == '<STR_LIT>':<EOL><INDENT>if not os.path.isdir(value):<EOL><INDENT>if not os.path.isdir(os.path.join(args.target, value)):<EOL><INDENT>value = None<EOL><DEDENT><DEDENT><DEDENT>if not value:<EOL><INDENT>logger.error("<STR_LIT>"<EOL>"<STR_LIT>",<EOL>user_value, option_string)<EOL>exit(<NUM_LIT:1>)<EOL><DEDENT>setattr(args, self.dest, value)<EOL><DEDENT><DEDENT>return CheckPathAction<EOL>
custom command line action to check file exist