Run markdownlint on matched_filenames.
196792
def _run_markdownlint(matched_filenames, show_lint_files):
    """"""
    from prospector.message import Message, Location

    for filename in matched_filenames:
        _debug_linter_status("mdl", filename, show_lint_files)

    try:
        proc = subprocess.Popen(["mdl"] + matched_filenames,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        lines = proc.communicate()[0].decode().splitlines()
    except OSError as error:
        if error.errno == errno.ENOENT:
            return []

    lines = [
        re.match(r"([\w\-.\/\\ ]+)\:([0-9]+)\: (\w+) (.+)", l).groups(1)
        for l in lines
    ]
    return_dict = dict()
    for filename, lineno, code, msg in lines:
        key = _Key(filename, int(lineno), code)
        loc = Location(filename, None, None, int(lineno), 0)
        return_dict[key] = Message("markdownlint", code, loc, msg)

    return return_dict
785899
def match_file(filename):
    """"""
    base_name = os.path.basename(filename)

    if base_name.startswith('.'):
        return False

    if not os.path.isdir(filename) and not filename.lower().endswith('.rst'):
        return False

    return True
1036441
def lint(commit = nil)
      files = pronto(commit)
      return if files.empty?

      markdown offenses_message(files)
    end
143
def match_files(self, matched, unmatched):
        """"""
        for pattern in self.iter():
            pattern.match_files(matched, unmatched)
            if not unmatched:
                # Optimization: If we have matched all files already
                # simply return at this point - nothing else to do
                break
545454
def match(self, files):
        """"""
        if not files:
            return set()

        if (self.matched_inherit.all_files()
                or self.matched_and_subdir.all_files()
                or self.matched_no_subdir.all_files()):
            # Optimization: one of the matched patterns matches everything
            # So simply return it
            return set(files)

        unmatched = set(files)
        matched = set()
        for pattern_set in self._matching_pattern_sets():
            pattern_set.match_files(matched, unmatched)
            if not unmatched:
                # Optimization: If we have matched all files already
                # simply return at this point - nothing else to do
                break

        return matched
547688
def process_includes(self, markdown_file_path: Path, content: str) -> str:
        '''
        '''

        markdown_file_path = markdown_file_path.resolve()

        self.logger.debug(f'Processing Markdown file: {markdown_file_path}')

        processed_content = ''

        include_statement_pattern = re.compile(
            rf'((?<!\<)\<{"|".join(self.tags)}(?:\s[^\<\>]*)?\>.*?\<\/{"|".join(self.tags)}\>)',
            flags=re.DOTALL
        )

        content_parts = include_statement_pattern.split(content)

        for content_part in content_parts:
            include_statement = self.pattern.fullmatch(content_part)

            if include_statement:
                body = self._tag_body_pattern.match(include_statement.group('body').strip())
                options = self.get_options(include_statement.group('options'))

                self.logger.debug(f'Processing include statement; body: {body}, options: {options}')

                if body.group('repo'):
                    repo = body.group('repo')
                    repo_from_alias = self.options['aliases'].get(repo)

                    revision = None

                    if repo_from_alias:
                        self.logger.debug(f'Alias found: {repo}, resolved as: {repo_from_alias}')

                        if '#' in repo_from_alias:
                            repo_url, revision = repo_from_alias.split('#', maxsplit=1)

                        else:
                            repo_url = repo_from_alias

                    else:
                        repo_url = repo

                    if body.group('revision'):
                        revision = body.group('revision')

                        self.logger.debug(f'Highest priority revision specified in the include statement: {revision}')

                    self.logger.debug(f'File in Git repository referenced; URL: {repo_url}, revision: {revision}')

                    repo_path = self._sync_repo(repo_url, revision)

                    self.logger.debug(f'Local path of the repo: {repo_path}')

                    included_file_path = repo_path / body.group('path')

                    self.logger.debug(f'Resolved path to the included file: {included_file_path}')

                    processed_content_part = self._process_include(
                        included_file_path,
                        body.group('from_heading'),
                        body.group('to_heading'),
                        options
                    )

                else:
                    self.logger.debug('Local file referenced')

                    included_file_path = self._get_included_file_path(body.group('path'), markdown_file_path)

                    self.logger.debug(f'Resolved path to the included file: {included_file_path}')

                    processed_content_part = self._process_include(
                        included_file_path,
                        body.group('from_heading'),
                        body.group('to_heading'),
                        options
                    )

                if self.options['recursive'] and self.pattern.search(processed_content_part):
                    self.logger.debug('Recursive call of include statements processing')

                    processed_content_part = self.process_includes(included_file_path, processed_content_part)

                if options.get('inline'):
                    self.logger.debug('Processing included content part as inline')

                    processed_content_part = re.sub(r'\s+', ' ', processed_content_part).strip()

            else:
                processed_content_part = content_part

            processed_content += processed_content_part

        return processed_content
722373
def match_filenames(filenames, pattern):
    """"""
    matching = []

    for filename in filenames:
        if fnmatch(get_filebase(filename, pattern), globify(pattern)):
            matching.append(filename)

    return matching
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)
589581
def match_file(pattern, filename):
    '''
    
    '''

    # Validate user data.

    if pattern is None:
        return None

    if os.stat(filename).st_size == 0:
        return None

    rexobj = REX(pattern, filename)

    rexpatstr = reformat_pattern(pattern)
    #print "rexpatstr: ", rexpatstr

    rexpat = re.compile(rexpatstr)
    rexobj.rex_patternstr = rexpatstr
    rexobj.rex_pattern = rexpat

    sfile = open(filename, 'r')
    data = sfile.read()
    sfile.close()

    line_count = 1
    for line in data.splitlines():
        mobj = rexpat.match(line)
        if mobj:
            populate_resobj(rexobj, mobj, line_count)

        line_count += 1

    return rexobj
1171377
def lint(files, inline_mode = false, options = {})
      final_options = options.merge(json: true)

      issues = files
               .map { |file| Shellwords.escape(file) }
               .map { |file| `hlint lint #{file} #{to_hlint_options(final_options)} 2>/dev/null` }
               .reject { |s| s == '' }
               .map { |lint_result| JSON.parse(lint_result).flatten }
               .flatten

      self.suggestions = issues.select { |issue| issue['severity'] == 'Suggestion' }
      self.warnings = issues.select { |issue| issue['severity'] == 'Warning' }
      self.errors = issues.select { |issue| issue['severity'] == 'Error' }

      if inline_mode
        # Reprt with inline comment
        send_inline_comment(suggestions, 'warn')
        send_inline_comment(warnings, 'warn')
        send_inline_comment(errors, 'fail')

      else
        # Report if any suggestions, warnings or errors
        if suggestions.count > 0 || warnings.count > 0 || errors.count > 0
          message = "### hlint found issues\n\n"
          message << markdown_issues(warnings, 'Suggestions') unless suggestions.empty?
          message << markdown_issues(warnings, 'Warnings') unless warnings.empty?
          message << markdown_issues(errors, 'Errors') unless errors.empty?
          markdown message
        end
      end
    end
134583
def run(self, fnames=None):
        """"""
        if fnames is None:
            fnames = self.get_selected_filenames()
        for fname in fnames:
            self.sig_run.emit(fname)
89919
def select_files_from_pathnames(self, filenames):
        """"""
        selected_filenames = []

        for pattern in self.file_patterns:
            matching = match_filenames(filenames, pattern)
            for fname in matching:
                if fname not in selected_filenames:
                    selected_filenames.append(fname)
        if len(selected_filenames) == 0:
            logger.warning("No filenames found for reader: %s", self.name)
        return selected_filenames
301404
def _run_flake8(filename, stamp_file_name, show_lint_files):
    """"""
    _debug_linter_status("flake8", filename, show_lint_files)
    return _stamped_deps(stamp_file_name,
                         _run_flake8_internal,
                         filename)
13478
def lint():
    """"""
    py_files = subprocess.check_output("git ls-files")
    if PY3:
        py_files = py_files.decode()
    py_files = [x for x in py_files.split() if x.endswith('.py')]
    py_files = ' '.join(py_files)
    sh("%s -m flake8 %s" % (PYTHON, py_files), nolog=True)
448529
def compile_slides(source):
  ''''''
  # if it's a directory, do all md files.
  if os.path.isdir(source):
    for f in os.listdir(source):
      if f.lower().endswith('.md'):
        compile_markdown_file(os.path.join(source, f))
  else:
    compile_markdown_file(source)
601270
def _fn_matches(fn, glob):
    """"""
    if glob not in _pattern_cache:
        pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob))
        return pattern.match(fn)
    return _pattern_cache[glob].match(fn)
224889
def main(args):
    """"""
    filename = args[0]
    marker = args[1]
    for line in fileinput.input(filename, inplace=1):
        print(line.rstrip())
        if line.startswith(marker):
            break