this is for times we need
to check if a media file is
an actual media file

Note: this does not download
the file only checks if the
return code is valid
3401
public function isValid() 
    {
      $headers = get_headers($this->url);
      $header = $headers[0]; // the result code
      $type = $headers[sizeof($headers) - 1]; // content type
      $m = array();

      if (preg_match("/\d{3}/", $header, $m)) {

        if (substr($m[0], 0, 1) == "2")
          return true;
      }

      return false;
    }
332619
function(){
                /*
                 * media_query
                 *   : [ONLY | NOT]? S* media_type S* [ AND S* expression ]*
                 *   | expression [ AND S* expression ]*
                 *   ;
                 */
                var tokenStream = this._tokenStream,
                    type        = null,
                    ident       = null,
                    token       = null,
                    expressions = [];
                if (tokenStream.match(Tokens.IDENT)){
                    ident = tokenStream.token().value.toLowerCase();

                    //since there's no custom tokens for these, need to manually check
                    if (ident !== "only" && ident !== "not"){
                        tokenStream.unget();
                        ident = null;
                    } else {
                        token = tokenStream.token();
                    }
                }
               
                this._readWhitespace();

                if (tokenStream.peek() === Tokens.IDENT){
                    type = this._media_type();
                    if (token === null){
                        token = tokenStream.token();
                    }
                } else if (tokenStream.peek() === Tokens.LPAREN){
                    if (token === null){
                        token = tokenStream.LT(1);
                    }
                    expressions.push(this._media_expression());
                }

                if (type === null && expressions.length === 0){
                    return null;
                } else {
                    this._readWhitespace();
                    while (tokenStream.match(Tokens.IDENT)){
                        if (tokenStream.token().value.toLowerCase() !== "and"){
                            this._unexpectedToken(tokenStream.token());
                        }
                        this._readWhitespace();
                        expressions.push(this._media_expression());
                    }
                }
                return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
            }
1039134
def check_file?(file)
      return true if @everything
      type = mime_type_for_file(file)
      ! ignore_types.any? { |ignored| type.include?(ignored) }
    end
827993
private static boolean checkDownloadPath() {
        if (Checker.isNotEmpty(storageFolder)) {
            File file = new File(storageFolder);
            if (!file.exists() && file.mkdirs()) {
                logger.info("mkdir '" + storageFolder + "' success");
            }
            return true;
        }
        return false;
    }
285952
def validate(self):
        
        from .files import VideoFile, WebVideoFile
        try:
            assert self.kind == content_kinds.VIDEO, "Assumption Failed: Node should be a video"
            assert self.questions == [], "Assumption Failed: Video should not have questions"
            assert len(self.files) > 0, "Assumption Failed: Video must have at least one video file"

            # Check if there are any .mp4 files if there are video files (other video types don't have paths)
            assert any(f for f in self.files if isinstance(f, VideoFile) or isinstance(f, WebVideoFile)), "Assumption Failed: Video should have at least one .mp4 file"

            return super(VideoNode, self).validate()
        except AssertionError as ae:
            raise InvalidNodeException("Invalid node ({}): {} - {}".format(ae.args[0], self.title, self.__dict__))
1303670
def _is_valid_file(self, path):
        """"""
        return isinstance(path, basestring) and os.path.isfile(path)
309602
function checkFile(peripheralId, callback) {
  if (overWriteServices) {
    callback(false);
  } else {
    fs.stat(devicesPath + '/' + peripheralId + '.srv.json', function(err, stat) {
      if(err == null) {
        callback(true);
        //  console.log('File exists');
      } else {
        callback(false)
      }
    });   
  }
}
1294059
public function isFile()
    {
        if ($this->blobExists()) {
            $metadata = $this->storage->getMetaData($this->blob->path);

            return $metadata['type'] === 'file';
        }

        return false;
    }
557483
def validate(self, instance, value):
        
        # Pass if already validated
        if getattr(value, '__valid__', False):
            return value
        # Validate that value is PNG
        if isinstance(value, png.Image):
            pass
        else:
            value = super(ImagePNG, self).validate(instance, value)
            try:
                png.Reader(value).validate_signature()
            except png.FormatError:
                self.error(instance, value, extra='Open file is not PNG.')
            value.seek(0)
        # Write input to new bytestream
        output = BytesIO()
        output.name = self.filename
        output.__valid__ = True
        if isinstance(value, png.Image):
            value.save(output)
        else:
            fid = value
            fid.seek(0)
            output.write(fid.read())
            fid.close()
        output.seek(0)
        return output
1170578
function isJsonFile (file) {
  return file.data &&                             // The file has data
    (typeof file.data === 'string') &&            // and it's a string
    (
      mimeTypePattern.test(file.mimeType) ||      // and it has a JSON MIME type
      extensionPattern.test(file.url)             // or at least a .json file extension
    );
}
321452
private boolean checkSupportedAudio() {
        AudioHeader header = audioFile.getAudioHeader();
        bitrate = header.getBitRateAsNumber();
        sampleRate = header.getSampleRateAsNumber();
        channels = header.getChannels();
        if (header.getChannels().toLowerCase().contains("stereo")) {
            channels = "2";
        }

        if (header instanceof MP3AudioHeader) {
            duration = ((MP3AudioHeader) header).getPreciseTrackLength();
        } else if (header instanceof Mp4AudioHeader) {
            duration = (double) ((Mp4AudioHeader) header).getPreciseLength();
        } else {
            duration = (double) header.getTrackLength();
        }

        // generic frames
        Tag tag = audioFile.getTag();
        artist = tag.getFirst(FieldKey.ARTIST);
        album = tag.getFirst(FieldKey.ALBUM);
        title = tag.getFirst(FieldKey.TITLE);
        comment = tag.getFirst(FieldKey.COMMENT);
        year = tag.getFirst(FieldKey.YEAR);
        track = tag.getFirst(FieldKey.TRACK);
        genre = tag.getFirst(FieldKey.GENRE);

        artwork = new ArrayList<>();
        for (Artwork a : tag.getArtworkList()) {
            AudioMetadataArtwork ama = new AudioMetadataArtwork();
            ama.setMimeType(a.getMimeType());
            if (a.getPictureType() >= 0) {
                ama.setType(a.getPictureType());
            }
            ama.setData(a.getBinaryData());

            artwork.add(ama);
        }

        return true;
    }
599004
def _validate_file_format(self, file_format):
        """"""

        if file_format not in self.valid_file_formats:
            raise InvalidFileFormatError(
                "{} is not a valid file format".format(file_format)
            )

        return file_format
93902
def raw_content
      return if pseudo_license?
      unless File.exist?(path)
        raise Licensee::InvalidLicense, "'#{key}' is not a valid license key"
      end

      @raw_content ||= File.read(path, encoding: 'utf-8')
    end
714169
def isFile(self):
        
        try:
            filetype = file
        except NameError:
            filetype = io.IOBase

        return self._wrap(type(self.obj) is filetype)
1354195
protected boolean hasMatchingMediaType(MediaType mediaType) {
		if (mediaType != null) {
			String subtype = mediaType.getSubtype();
			return "json".equalsIgnoreCase(subtype) || subtype.endsWith("+json") || "javascript".equals(subtype) || "x-javascript".equals(subtype);
		}
		return true;
	}
964737
def is_file(cls, file):
        ''''''
        peeked_data = wpull.util.peek_file(file)

        if is_gzip(peeked_data):
            try:
                peeked_data = wpull.decompression.gzip_uncompress(
                    peeked_data, truncated=True
                )
            except zlib.error:
                pass

        peeked_data = wpull.string.printable_bytes(peeked_data)

        if b'<?xml' in peeked_data \
           and (b'<sitemapindex' in peeked_data or b'<urlset' in peeked_data):
            return True
41588
def is_valid_file(parser, arg):
    """"""
    arg = os.path.abspath(arg)
    if not os.path.exists(arg):
        parser.error("The file %s does not exist!" % arg)
    else:
        return arg