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

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