def directory_arg(path, optname):
 if (not os.path.isdir(path)):
  raise UsageError('{0} must be a directory, given: {1}'.format(optname, path))
 return path

def directory_arg ( path , optname ) : if ( not os . path . isdir ( path ) ) : raise UsageError ( '{0} must be a directory, given: {1}' . format ( optname , path ) ) return path
argparse type validator for directory arguments .