Detect whether the filename of videofile matches with this SubtitleFile.
        :param video: VideoFile instance
        :return: True if match
550052
def matches_video_filename(self, video):
        

        vid_fn = video.get_filename()
        vid_base, _ = os.path.splitext(vid_fn)
        vid_base = vid_base.lower()

        sub_fn = self.get_filename()
        sub_base, _ = os.path.splitext(sub_fn)
        sub_base = sub_base.lower()

        log.debug('matches_filename(subtitle="{sub_filename}", video="{vid_filename}") ...'.format(
            sub_filename=sub_fn, vid_filename=vid_fn))

        matches = sub_base == vid_base

        lang = None
        if not matches:
            if sub_base.startswith(vid_base):
                sub_rest = sub_base[len(vid_base):]
                while len(sub_rest) > 0:
                    if sub_rest[0].isalnum():
                        break
                    sub_rest = sub_rest[1:]
                try:
                    lang = Language.from_unknown(sub_rest, xx=True, xxx=True)
                    matches = True
                except NotALanguageException:
                    matches = False

        if matches:
            log.debug('... matches (language={language})'.format(language=lang))
        else:
            log.debug('... does not match')
        return matches
268891
def _filter(self, filename):
        
        return self.name_filter is not None and re.search(self.name_filter, filename) is None
339261
def is_archive(filename):
    ''''''
    for archive in archive_formats:
        if filename.endswith(archive_formats[archive]['suffix']):
            return True
    return False
1374634
def matches?(filename, candidates)
      filename = filename.downcase
      candidates = candidates.compact.map(&:name)
      @exts_and_langs.any? { |ext| filename.end_with?(ext) }
    end
634878
def _match_pattern(filename, include, exclude, real, path, follow):
    """"""

    if real:
        symlinks = {}
        if isinstance(filename, bytes):
            curdir = os.fsencode(os.curdir)
            mount = RE_BWIN_MOUNT if util.platform() == "windows" else RE_BMOUNT
        else:
            curdir = os.curdir
            mount = RE_WIN_MOUNT if util.platform() == "windows" else RE_MOUNT

        if not mount.match(filename):
            exists = os.path.lexists(os.path.join(curdir, filename))
        else:
            exists = os.path.lexists(filename)

        if not exists:
            return False
        if path:
            return _match_real(filename, include, exclude, follow, symlinks)

    matched = False
    for pattern in include:
        if pattern.fullmatch(filename):
            matched = True
            break

    if not include and exclude:
        matched = True

    if matched:
        matched = True
        if exclude:
            for pattern in exclude:
                if not pattern.fullmatch(filename):
                    matched = False
                    break
    return matched
93181
def match(self, filename):
        

        try:
            for regex, patterns in self._regex_patterns:
                match = regex.match(filename)

                debug_template = "%s against %s: %%s" % (filename, regex._real_regex.pattern)

                if match:
                    if self.debug:
                        logger.info(debug_template % "hit")
                    return patterns[match.lastindex -1]

                if self.debug:
                    logger.info(debug_template % "miss")

        except Exception as e:
            # We can't show the default e.msg to the user as thats for
            # the combined pattern we sent to regex. Instead we indicate to
            # the user that an ignore file needs fixing.
            logger.error('Invalid pattern found in regex: %s.', e.msg)
            e.msg = "File ~/.bazaar/ignore or .bzrignore contains error(s)."
            bad_patterns = ''
            for _, patterns in self._regex_patterns:
                for p in patterns:
                    if not Globster.is_pattern_valid(p):
                        bad_patterns += ('\n  %s' % p)
            e.msg += bad_patterns
            raise e
        

        return None
464132
protected function matchVideo()
    {
        return ReplyRuleKeyword::find()
            ->andFilterWhere(['type' => [ReplyRuleKeyword::TYPE_VIDEO, ReplyRuleKeyword::TYPE_SHORT_VIDEO]])
            ->wechatRule($this->getWechat()->id)
            ->limitTime(TIMESTAMP)
            ->all();
    }
21988
def match(self, fname, flevel, ftype):
        ''''''
        # if filetype is the same
        # and level isn't set or level is the same
        # and pattern matche the filename
        if self.filetype == ftype and (self.level is None or self.level == flevel) and fnmatch.fnmatch(fname, self.pattern):
            return self.score
        return 0
1058591
def filename_match(filename):
    
    if not options.filename:
        return True
    for pattern in options.filename:
        if fnmatch(filename, pattern):
            return True
1204979
def file_match(file)
      raise ArgumentError, "Filename cannot be nil" if file.nil?
      { filename: file, matched: file, line: 1, column: 1 }
    end
1094827
def is_image(file):
    
    match = re.match(r'\.(png|jpe?g)', _get_extension(file), re.IGNORECASE)
    if match:
        return True
    else:
        return isinstance(resolve_bot_file_id(file), types.Photo)
347238
def search_filename(self, searchterm):
        
        return self.__search(type_attribute=self.__mispfilenametypes(), value=searchterm)
359458
def Matches(self, file_entry):
    
    if not self._names or not file_entry.IsFile():
      return False

    return file_entry.name.lower() in self._names
1260728
def guess_content_kind(path=None, web_video_data=None, questions=None):
    
    # If there are any questions, return exercise
    if questions and len(questions) > 0:
        return content_kinds.EXERCISE

    # See if any files match a content kind
    if path:
        ext = os.path.splitext(path)[1][1:].lower()
        if ext in content_kinds.MAPPING:
            return content_kinds.MAPPING[ext]
        raise InvalidFormatException("Invalid file type: Allowed formats are {0}".format([key for key, value in content_kinds.MAPPING.items()]))
    elif web_video_data:
        return content_kinds.VIDEO
    else:
        return content_kinds.TOPIC
735145
def check_picture(file_name, mediainfo_path=None):
    
    D = call_MediaInfo(file_name, mediainfo_path)
    # Check that the file analyzed was a valid movie
    if (
        ("Image" not in D) or
        ("Width" not in D["Image"]) or
        ("Height" not in D["Image"])
    ):
        raise MediaInfoError("Could not determine all picture paramters")

    return D
137887
def mv_videos(path):
    
    count = 0
    for f in os.listdir(path):
        f = os.path.join(path, f)
        if os.path.isdir(f):
            for sf in os.listdir(f):
                sf = os.path.join(f, sf)
                if os.path.isfile(sf):
                    new_name = os.path.join(path, os.path.basename(sf))
                    try:
                        os.rename(sf, new_name)
                    except (WindowsError, OSError) as e:
                        print('mv {} happens error: {}'.format(sf, e))
                    else:
                        count += 1
                        print('mv {} to {}'.format(sf, new_name))
    return count
407137
def _extract(cls, compressed_file, videofile, exts):
        
        if not CompressedFile.is_compressed_file(compressed_file):
            return [compressed_file]

        root = os.path.dirname(compressed_file)
        subs = []
        cf = CompressedFile(compressed_file)
        for name in cf.namelist():
            if cf.isdir(name):
                continue
            # make `name` to unicode string
            orig_name = CompressedFile.decode_file_name(name)
            _, ext = os.path.splitext(orig_name)
            ext = ext[1:]
            if ext not in exts:
                continue
            subname = cls._gen_subname(videofile, '', '', orig_name=orig_name)
            subpath = os.path.join(root, subname)
            cf.extract(name, subpath)
            subs.append(subpath)
        cf.close()
        return subs