Checks whether the given file can be parsed by any parser.
2406
public boolean canParse(File file) {
		for(XParser parser : XParserRegistry.instance().getAvailable()) {
			if(parser.canParse(file)) {
				return true;
			}
		}
		return false;
	}
660502
def is_valid_file(parser,arg):
	""""""
	if not os.path.exists(arg):
       		parser.error("File %s not found"%arg)
	else:
	       	return arg
1207647
def is_parseable (self):
        
        if self.is_directory():
            return True
        if firefox.has_sqlite and firefox.extension.search(self.url):
            return True
        if self.content_type in self.ContentMimetypes:
            return True
        log.debug(LOG_CHECK, "File with content type %r is not parseable.", self.content_type)
        return False
73025
def _parse_line(self, file):
        

        line = self._strip_comments(file.readline())
        # check if the file ended
        if not line:
            return False

        # line was empty or it was a comment, continue
        if line.strip() == '':
            return True

        # retrieve keyword and its value
        reg = re.search("^\*(?P<key>[^:#]*)(:\s*(?P<value>.*)\s*)?$", line)
        if reg:
            key = reg.group('key').strip()
            value = reg.group('value')

            if key in self.mapping[self.current_state]:
                self.mapping[self.current_state][key](value)
            elif self.strict:
                raise BadFormat("unknown key: *%s" % key)
        else:
            raise BadFormat("line can not be parsed: %s" % line)

        return True
397049
function parseFile (file, content) {
  let type = getParseType(file)

  debug('parse file: file = %s, parseType = %s', file, type)

  if (type in parser) {
    if (typeof content !== 'string') {
      content = fs.readFileSync(file, 'utf8')
    }

    return parser[type](content)
  }
}
1297405
def canparse(argparser, args):
    """"""
    old_error_method = argparser.error
    argparser.error = _raise_ValueError
    try:
        argparser.parse_args(args)
    except ValueError:
        return False
    else:
        return True
    finally:
        argparser.error = old_error_method
39486
function hasFileType(file, fileExt) {
  file = path.basename(file);
  var ext = path.extname(file);
  do {
    if (ext === fileExt) {
      return true;
    } else {
      file = path.basename(file, ext);
      ext = path.extname(file);
    }
  } while (ext);
  return false;
}
1138165
def parse_file(file_or_path, encoding='utf-8', validate=False):
    
    try:
        is_string = isinstance(file_or_path, basestring)
    except NameError:
        is_string = isinstance(file_or_path, str)
    if is_string:
        with codecs.open(file_or_path, 'r', encoding) as file_:
            result = pattern.parseFile(file_)[0]
    else:
        result = pattern.parseFile(file_or_path)[0]
    if validate:
        result.validate()
    return result
1093962
def parse_file(self, inputstring, addhash=True):
        """"""
        if addhash:
            use_hash = self.genhash(False, inputstring)
        else:
            use_hash = None
        return self.parse(inputstring, self.file_parser, {"nl_at_eof_check": True}, {"header": "file", "use_hash": use_hash})
64896
public void parseFile(File file) throws ParserException, IOException {

        Reader reader = null;

        try {
            reader = new FileReader(file);
            nanoElement.parseFromReader(reader);
        } catch (XMLParseException e) {
            throw new ParserException(e.getMessage());
        } finally {
            if (reader != null) reader.close();
        }
    }
1048638
def is_readable(filename):
    """"""
    return os.path.isfile(filename) and os.access(filename, os.R_OK)
887546
public ResourceFormatParser getParserForFileExtension(final File file) throws UnsupportedFormatException {
        String extension = getFileExtension(file.getName());
        if (null != extension) {
            return getParserForFileExtension(extension);
        } else {
            throw new UnsupportedFormatException("Could not determine format for file: " + file.getAbsolutePath());
        }
    }
372142
def is_filelike(ob):
    
    if hasattr(ob, 'read') and callable(ob.read):
        return True

    if hasattr(ob, 'write') and callable(ob.write):
        return True

    return False
1325953
def can_read(self, timeout=0):
        ""
        sock = self._sock
        if not sock:
            self.connect()
            sock = self._sock
        return self._parser.can_read() or \
            bool(select([sock], [], [], timeout)[0])
1303670
def _is_valid_file(self, path):
        """"""
        return isinstance(path, basestring) and os.path.isfile(path)
95669
def check(filename, content)
      @checkers.each do |checker|
        checker.check(filename, content) if checker.parse_file?(filename)
      end
    end
495161
public Collection<XLog> parse(File file) throws Exception {
		Collection<XLog> result = null;
		for(XParser parser : XParserRegistry.instance().getAvailable()) {
			if(parser.canParse(file)) {
				try {
					result = parser.parse(file);
					return result;
				} catch(Exception e) {
					// ignore and move on
				}
			}
		}
		throw new Exception("No suitable parser could be found!");
	}