def readable_directory(arg):
 arg = directory(arg)
 if (not os.access(arg, os.R_OK)):
  raise argparse.ArgumentTypeError('{0} exists but is not readable with its current permissions'.format(arg))
 return arg

def readable_directory ( arg ) : arg = directory ( arg ) if ( not os . access ( arg , os . R_OK ) ) : raise argparse . ArgumentTypeError ( '{0} exists but is not readable with its current permissions' . format ( arg ) ) return arg
an argument type (for use with the type= argument to argparse .