Validates arguments for loading from directories, including static image and time series directories.
518811
def _check_directory_arguments(self):
        
        if not os.path.isdir(self.datapath):
            raise (NotADirectoryError('Directory does not exist: %s' % self.datapath))
        if self.time_delay:
            if self.time_delay < 1:
                raise ValueError('Time step argument must be greater than 0, but gave: %i' % self.time_delay)
            if not isinstance(self.time_delay, int):
                raise ValueError('Time step argument must be an integer, but gave: %s' % str(self.time_delay))
770420
def qualified_files(self, absolute=True):
        """"""
        prefix = self.get_directory() if absolute else "."
        for rel_dir_name, file_name in self.files():
            yield os.path.join(prefix, rel_dir_name, file_name)
557130
function processArgs(args, files = []) {
  return args.reduce((acc, arg) => {
    let stats;
    try {
      stats = fs.statSync(arg);
    } catch (err) {
      // Do nothing
    }

    // If argument is a directory, process the files inside
    if (stats && stats.isDirectory()) {
      return processArgs(
        fs.readdirSync(arg).map(file => path.join(arg, file)),
        files
      );
    }

    // If `statSync` failed, validating will handle the error
    // If the argument is a file, check if its a JSON file before validating
    if (!stats || JsonFileRegex.test(arg)) {
      acc.push(validateFile(arg));
    }

    return acc;
  }, files);
}
416091
def validate_paths!
      if self.build_path.exist?
        log self, "Cleaning up previous build \"#{self.build_path}\""
        rm_rf(self.build_path)
      end
        
      if !self.target_path.exist?
        log self, "Creating target path \"#{self.target_path}\""
        mkdir self.target_path
      end
    end
1019822
def directories=(directories)
      valid = []

      if directories
        directories.each do |dir|
          unless File.directory?(dir)
            raise ArgumentError, "The directory #{dir} does not exist"
          end

          valid << File.expand_path(dir)
        end
      end

      @directories = valid
    end
1188935
function loadFiles(directories, files)
{
  // sort extensions to provide deterministic order of loading
  var _instance  = this
    , extensions = resolveExts.call(this)
    , layers     = []
    ;

  // treat all inputs as list of directories
  directories = (typeOf(directories) == 'array') ? directories : [directories];

  files.forEach(function(filename)
  {
    var layer = {file: filename, exts: []};

    extensions.forEach(function(ext)
    {
      var layerExt = {ext: ext, dirs: []};

      directories.forEach(function(dir)
      {
        var cfg, file = path.resolve(dir, filename + '.' + ext);

        if (fs.existsSync(file))
        {
          cfg = loadContent.call(_instance, file, _instance.parsers[ext]);

          // check if any hooks needed to be applied
          cfg = applyHooks.call(_instance, cfg, filename);
        }

        if (cfg)
        {
          layerExt.dirs.push({
            dir   : dir,
            config: cfg
          });
        }
      });

      // populate with non-empty layers only
      if (layerExt.dirs.length)
      {
        layer.exts.push(layerExt);
      }
    });

    // populate with non-empty layers only
    if (layer.exts.length)
    {
      layers.push(layer);
    }

  });

  return layers;
}
851099
def validate_file(parser, arg):
    """"""
    if not os.path.isfile(arg):
        parser.error("%s is not a file." % arg)
    return arg
535084
def ensure_dirs(filename):
    """"""
    dirname = os.path.dirname(filename)
    if dirname and not os.path.exists(dirname):
        os.makedirs(dirname)
1344704
public void validateFileDoesNotExist(UIInput<String> directory, UIInput<String> fileName, UIValidationContext validator) {
        String resourcePath = CamelXmlHelper.createFileName(directory, fileName);
        if (files.contains(resourcePath)) {
            validator.addValidationError(fileName, "A file with that name already exists!");
        }
    }
1185815
def _validate_args(env, args):
    """"""

    if all([args['cpu'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-c | --cpu] not allowed with [-f | --flavor]')

    if all([args['memory'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-m | --memory] not allowed with [-f | --flavor]')

    if all([args['dedicated'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-d | --dedicated] not allowed with [-f | --flavor]')

    if all([args['host_id'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-h | --host-id] not allowed with [-f | --flavor]')

    if all([args['userdata'], args['userfile']]):
        raise exceptions.ArgumentError(
            '[-u | --userdata] not allowed with [-F | --userfile]')

    image_args = [args['os'], args['image']]
    if all(image_args):
        raise exceptions.ArgumentError(
            '[-o | --os] not allowed with [--image]')

    while not any([args['os'], args['image']]):
        args['os'] = env.input("Operating System Code", default="", show_default=False)
        if not args['os']:
            args['image'] = env.input("Image", default="", show_default=False)
913834
def _valid_directory(self, path):
        
        abspath = os.path.abspath(path)
        if not os.path.isdir(abspath):
            raise argparse.ArgumentTypeError('Not a valid directory: {}'.format(abspath))
        return abspath
1013738
function loadModules(dir, container, args) {
  var files = fs.readdirSync(dir);
  for (var i = 0; i < files.length; i++) {
    var file = files[i];
    var filePath = path.join(dir, file);
    if (fs.statSync(filePath).isDirectory()) {
      container[file] = {};
      loadModules(filePath, container[file], args);
      continue;
    }
    if (/.+\.js$/.test(file)) {
      var name = file.replace(/\.js$/, '') 
      container[name] = require(filePath)(args, container);
    }
  }
}
311511
def run_validation(options):
    
    if options.files == sys.stdin:
        results = validate(options.files, options)
        return [FileValidationResults(is_valid=results.is_valid,
                                      filepath='stdin',
                                      object_results=results)]

    files = get_json_files(options.files, options.recursive)

    results = [validate_file(fn, options) for fn in files]

    return results
786090
private void validateSettingsDir() {
         if (!settingsDir.exists()) {
             throw new RuntimeException(SETTINGS_DIR_OPTION + " : " + settingsDir.getPath() + " does not exist!");
         }
         else if (!settingsDir.isDirectory()) {
             throw new RuntimeException(SETTINGS_DIR_OPTION + " : " + settingsDir.getPath() + " is not a directory!");
         }
     }
1199395
public static void validateDirectory(File topIndexDir) {
    if (!topIndexDir.exists() || !topIndexDir.isDirectory()) {
      throw new RuntimeException("Not found or is not a directory:\n" +
              topIndexDir + "\n" +
              "As ngram directory, please select the directory that has a subdirectory like 'en'\n" +
              "(or whatever language code you're using).");
    }
    List<String> dirs = new ArrayList<>();
    for (String name : topIndexDir.list()) {
      if (name.matches("[123]grams")) {
        dirs.add(name);
      }
    }
    if (dirs.isEmpty()) {
      throw new RuntimeException("Directory must contain at least '1grams', '2grams', and '3grams': " + topIndexDir.getAbsolutePath());
    }
    if (dirs.size() < 3) {
      throw new RuntimeException("Expected at least '1grams', '2grams', and '3grams' sub directories but only got " + dirs + " in " + topIndexDir.getAbsolutePath());
    }
  }
232347
def validate_data(args={})
      args = args.slice(:file_path, :data)
      args = args.compact
      file_path = args[:file_path]
      data = args[:data]

      utf_result = validate_csv(file_path) if file_path
      utf_result = validate_hashes(data) if data
      utf_result
    end
1128763
function validateParams(fs, param2) {
  var err;

  if(!fs) {
    err = new Errors.EINVAL('No filesystem provided');
  } else if(!param2) {
    err = new Errors.EINVAL('Second argument must be specified');
  }

  return err;
}