Check format of inputfile.
338830
def check_format(inputfile):
    
    t = word_embedding.classify_format(inputfile)
    if t == word_embedding._glove:
        _echo_format_result('glove')
    elif t == word_embedding._word2vec_bin:
        _echo_format_result('word2vec-binary')
    elif t == word_embedding._word2vec_text:
        _echo_format_result('word2vec-text')
    else:
        assert not "Should not get here!"
1088991
def getinputfilename(self, inputtemplate, filename):
        
        if inputtemplate.filename:
            filename = inputtemplate.filename
        elif inputtemplate.extension:
            if filename.lower()[-4:] == '.zip' or filename.lower()[-7:] == '.tar.gz' or filename.lower()[-8:] == '.tar.bz2':
                #pass archives as-is
                return filename

            if filename[-len(inputtemplate.extension) - 1:].lower() != '.' +  inputtemplate.extension.lower():
                filename += '.' + inputtemplate.extension

        return filename
1165469
def check_header_comment(filename):
    """"""
    # Check input file.
    name = os.path.basename( filename )
    # Read content of input file.
    sourcefile = open( filename, "rU" )
    content = sourcefile.read()
    sourcefile.close()
    # Search content for '$Id$'.
    match = re.search(r'\$Id\$', content)
    if match == None:
        # Make sure that the correct value for '$Id$' was already set.
        match = re.search(r'\$Id: ' + name + r'\s+[^$]+\$', content)
        if match != None:
            # The given file needs no fixing.
            return False
    # The given file needs fixing.
    return True
96786
def input_format(self, content_type):
        """"""
        return getattr(self, '_input_format', {}).get(content_type, hug.defaults.input_format.get(content_type, None))
493962
private void readFormDataFromFile() {
		List<FormInput> formInputList =
				FormInputValueHelper.deserializeFormInputs(config.getSiteDir());

		if (formInputList != null) {
			InputSpecification inputSpecs = config.getCrawlRules().getInputSpecification();

			for (FormInput input : formInputList) {
				inputSpecs.inputField(input);
			}
		}
	}
1088882
def checkParametersInputFile(filename):
    
    fin = open(filename, 'r')
    line = fin.readline()
    line2 = fin.readline()
    fin.close()

    temp = re.split('\s+', line)
    temp2 = re.split('\s+', line2)

    if temp[0] == '#Minor':
        return groovesParameters

    if temp[0] == '#Shift':
        return baseStepParameters

    if temp[0] == '#X-disp':
        return helicalBaseStepParameters

    if temp[0] == '#Shear':
        return basePairParameters

    if temp[0] == '#Position':
        return helicalAxisParameters

    if temp2[0] == '#P':
        return helicalRadiusParameters

    if temp2[0] == '#alpha':
        return backboneDihedrals
694189
def guess(system):
    
    files = system.files
    maybe = []
    if files.input_format:
        maybe.append(files.input_format)
    # first, guess by extension
    for key, val in input_formats.items():
        if type(val) == list:
            for item in val:
                if files.ext.strip('.').lower() == item:
                    maybe.append(key)
        else:
            if files.ext.strip('.').lower() == val:
                maybe.append(key)

    # second, guess by lines
    true_format = ''
    fid = open(files.case, 'r')
    for item in maybe:
        try:
            parser = importlib.import_module('.' + item, __name__)
            testlines = getattr(parser, 'testlines')
            if testlines(fid):
                true_format = item
                break
        except ImportError:
            logger.debug(
                'Parser for {:s} format is not found. '
                'Format guess will continue.'.
                format(item))
    fid.close()

    if true_format:
        logger.debug('Input format guessed as {:s}.'.format(true_format))
    else:
        logger.error('Unable to determine case format.')

    files.input_format = true_format

    # guess addfile format
    if files.addfile:
        _, add_ext = os.path.splitext(files.addfile)
        for key, val in input_formats.items():
            if type(val) == list:
                if add_ext[1:] in val:
                    files.add_format = key
            else:
                if add_ext[1:] == val:
                    files.add_format = key

    return true_format
1026220
def _validate_inputs(self, inputdict):
        
        # Check inputdict
        try:
            parameters = inputdict.pop(self.get_linkname('parameters'))
        except KeyError:
            raise InputValidationError("No parameters specified for this "
                                       "calculation")
        if not isinstance(parameters, ParameterData):
            raise InputValidationError("parameters not of type "
                                       "ParameterData")
        # Check code
        try:
            code = inputdict.pop(self.get_linkname('code'))
        except KeyError:
            raise InputValidationError("No code specified for this "
                                       "calculation")

        # Check input files
        try:
            structure = inputdict.pop(self.get_linkname('structure'))
            if not isinstance(structure, SinglefileData):
                raise InputValidationError(
                    "structure not of type SinglefileData")
        except KeyError:
            raise InputValidationError(
                "No input structure specified for calculation")

        try:
            surface_sample = inputdict.pop(self.get_linkname('surface_sample'))
            if not isinstance(surface_sample, SinglefileData):
                raise InputValidationError(
                    "surface_sample not of type SinglefileData")
        except KeyError:
            raise InputValidationError(
                "No surface sample specified for calculation")

        # Check that nothing is left unparsed
        if inputdict:
            raise ValidationError("Unrecognized inputs: {}".format(inputdict))

        return parameters, code, structure, surface_sample
926511
private function checkCompileInput()
    {
        
        $defaults = array('extension' => null,
                          'language' => null,
                          'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
                          'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR);
                          
        $this->options = array_merge($defaults, $this->options);
        
        if ($this->options['extension'] == null){
            $this->err("Please provide the 'extension' parameter.", true);
        }
        else if ($this->options['language'] == null){
            $this->err("Please provide the 'language' parameter.", true);
        }
        
    }
90670
def file_match_any(self, filename):
        """"""
        if filename.startswith('.' + os.sep):
            filename = filename[len(os.sep) + 1:]
        if os.sep != '/':
            filename = filename.replace(os.sep, '/')

        for selector in self.file_selectors:
            if (selector.pattern.endswith('/') and
                    filename.startswith(selector.pattern)):
                return True
            if fnmatch.fnmatch(filename, selector.pattern):
                return True
        return False
308519
def check_bed_file(fname):
    
    if not os.path.exists(fname):
        logger.error("Inputfile %s does not exist!", fname)
        sys.exit(1)

    for i, line in enumerate(open(fname)):
        if line.startswith("#") or line.startswith("track") or line.startswith("browser"):
            # comment or BED specific stuff
            pass
        else:
            vals = line.strip().split("\t")
            if len(vals) < 3:
                logger.error("Expecting tab-seperated values (chromosome<tab>start<tab>end) on line %s of file %s", i + 1, fname)
                sys.exit(1)
            try:
                start, end = int(vals[1]), int(vals[2])
            except ValueError:
                logger.error("No valid integer coordinates on line %s of file %s", i + 1, fname)
                sys.exit(1)
            if len(vals) > 3:
                try:
                    float(vals[3])
                except ValueError:
                    pass
360085
def validate_contents(file_contents):
    """"""
    for name, contents in file_contents.items():
        if os.path.splitext(name)[1] != '.ipynb':
            continue
        if not contents:
            return False
        try:
            json_object = json.loads(contents)
        except ValueError:
            return False
    return True
1257931
def _check_content(self, content_str):
        """"""
        if self.do_content_check:
            space_ratio = float(content_str.count(' '))/len(content_str)
            if space_ratio > self.max_space_ratio:
                return "space-ratio: %f > %f" % (space_ratio,
                                                 self.max_space_ratio)
            if len(content_str) > self.input_character_limit:
                return "too long: %d > %d" % (len(content_str),
                                              self.input_character_limit)
        return None
1151385
def check_rst(code, ignore):
    """"""
    filename = '<string>'

    for result in check(code,
                        filename=filename,
                        ignore=ignore):
        yield result
766595
def read_input_data(filename):
    """"""
    logging.info('Opening file %s for reading input', filename)
    input_file = open(filename, 'r')
    data = []
    labels = []
    for line in input_file:
        tokens = line.split(',', 1)
        labels.append(tokens[0].strip())
        data.append(tokens[1].strip())
    return labels, data
1166048
def guess_format(path):
    """"""
    for fmt in formats:
        if fmt.verify(path):
            return fmt.__name__
    else:
        msg = "Undefined file format: '{}'".format(path)
        raise UnknownFileFormatError(msg)
830655
private void checkFreeDiskSpace(List<File> inputFiles) {
    //Check for free space
    long usableSpace = 0;
    long totalSize = 0;
    for (File f : inputFiles) {
      if (f.exists()) {
        totalSize += f.length();
        usableSpace = f.getUsableSpace();
      }
    }
    LOGGER.log(Level.INFO, "Total expected store size is {0} Mb",
        new DecimalFormat("#,##0.0").format(totalSize / (1024 * 1024)));
    LOGGER.log(Level.INFO, "Usable free space on the system is {0} Mb",
        new DecimalFormat("#,##0.0").format(usableSpace / (1024 * 1024)));
    if (totalSize / (double) usableSpace >= 0.66) {
      throw new RuntimeException("Aborting because there isn' enough free disk space");
    }
  }