Skip to content

Instantly share code, notes, and snippets.

@schnell18
Created April 26, 2025 08:24
Show Gist options
  • Save schnell18/03bab65bf41b080d4e4b9434b5bc977d to your computer and use it in GitHub Desktop.
Save schnell18/03bab65bf41b080d4e4b9434b5bc977d to your computer and use it in GitHub Desktop.

Revisions

  1. schnell18 created this gist Apr 26, 2025.
    31 changes: 31 additions & 0 deletions filter.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/usr/bin/env python

    import re

    import requests

    url = "https://raw.githubusercontent.com/rshkarin/mason-nvim-lint/910dadb99cb2bf0d5176026c7a4ab1861c4e561f/lua/mason-nvim-lint/mapping.lua"

    if __name__ == "__main__":
    try:
    # Send HTTP GET request to the URL
    response = requests.get(url)

    # Check if the request was successful
    if response.status_code == 200:
    # Split the content by newlines and return as a list
    j = 0
    for i, line in enumerate(response.text.splitlines()):
    if i + 1 < 6 or i + 1 > 61:
    continue
    matcher = re.match(r'\s+\["(.*)"\] = "(.*)"', line)
    if matcher and matcher.group(1) != matcher.group(2):
    j += 1
    print(f'{(i + 1):02d}: ["{matcher.group(1)}"] = {matcher.group(2)}')
    else:
    print(line)
    print(f"{j} out of {i + 1}")
    else:
    print(f"Failed to retrieve file. Status code: {response.status_code}")
    except Exception as e:
    print(f"An error occurred: {e}")