mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
style: Format Python script with linter
This commit is contained in:
parent
59af4114dd
commit
ae6192111d
1 changed files with 20 additions and 17 deletions
|
@ -2,20 +2,22 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import requests
|
|
||||||
from pathlib import Path
|
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Path to the language definitions file
|
# Path to the language definitions file
|
||||||
lang_def_path = "../../tmp/tree-sitter-language-pack/sources/language_definitions.json"
|
lang_def_path = "../../tmp/tree-sitter-language-pack/sources/language_definitions.json"
|
||||||
|
|
||||||
# Path to store the tags.scm files
|
# Path to store the tags.scm files
|
||||||
output_dir = os.path.expanduser("~/tmp/tsl-pack")
|
output_dir = os.path.expanduser("~/tmp/tsl-pack")
|
||||||
|
|
||||||
# Create the output directory if it doesn't exist
|
# Create the output directory if it doesn't exist
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Load the language definitions
|
# Load the language definitions
|
||||||
with open(lang_def_path, "r") as f:
|
with open(lang_def_path, "r") as f:
|
||||||
|
@ -23,55 +25,56 @@ def main():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error loading language definitions: {e}")
|
print(f"Error loading language definitions: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print(f"Found {len(lang_defs)} language definitions")
|
print(f"Found {len(lang_defs)} language definitions")
|
||||||
|
|
||||||
# Process each language
|
# Process each language
|
||||||
for lang, config in lang_defs.items():
|
for lang, config in lang_defs.items():
|
||||||
print(f"Processing {lang}...")
|
print(f"Processing {lang}...")
|
||||||
|
|
||||||
# Extract repo URL and branch from the config
|
# Extract repo URL and branch from the config
|
||||||
repo_url = config.get("repo")
|
repo_url = config.get("repo")
|
||||||
if not repo_url:
|
if not repo_url:
|
||||||
print(f"Skipping {lang}: No repository URL found")
|
print(f"Skipping {lang}: No repository URL found")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
branch = config.get("branch", "master")
|
branch = config.get("branch", "master")
|
||||||
directory = config.get("directory", "")
|
directory = config.get("directory", "")
|
||||||
|
|
||||||
# Parse the GitHub repository URL
|
# Parse the GitHub repository URL
|
||||||
if "github.com" not in repo_url:
|
if "github.com" not in repo_url:
|
||||||
print(f"Skipping {lang}: Not a GitHub repository")
|
print(f"Skipping {lang}: Not a GitHub repository")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Extract the owner and repo name from the URL
|
# Extract the owner and repo name from the URL
|
||||||
_, _, _, owner, repo = repo_url.rstrip("/").split("/")
|
_, _, _, owner, repo = repo_url.rstrip("/").split("/")
|
||||||
|
|
||||||
# Construct the raw file URL
|
# Construct the raw file URL
|
||||||
if directory:
|
if directory:
|
||||||
tags_url = f"https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{directory}/queries/tags.scm"
|
tags_url = f"https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{directory}/queries/tags.scm"
|
||||||
else:
|
else:
|
||||||
tags_url = f"https://raw.githubusercontent.com/{owner}/{repo}/{branch}/queries/tags.scm"
|
tags_url = f"https://raw.githubusercontent.com/{owner}/{repo}/{branch}/queries/tags.scm"
|
||||||
|
|
||||||
# Create the language directory in the output path
|
# Create the language directory in the output path
|
||||||
lang_dir = os.path.join(output_dir, lang)
|
lang_dir = os.path.join(output_dir, lang)
|
||||||
os.makedirs(os.path.join(lang_dir, "queries"), exist_ok=True)
|
os.makedirs(os.path.join(lang_dir, "queries"), exist_ok=True)
|
||||||
|
|
||||||
# Fetch the tags.scm file
|
# Fetch the tags.scm file
|
||||||
try:
|
try:
|
||||||
response = requests.get(tags_url)
|
response = requests.get(tags_url)
|
||||||
response.raise_for_status() # Raise an exception for HTTP errors
|
response.raise_for_status() # Raise an exception for HTTP errors
|
||||||
|
|
||||||
# Save the file
|
# Save the file
|
||||||
output_file = os.path.join(lang_dir, "queries", "tags.scm")
|
output_file = os.path.join(lang_dir, "queries", "tags.scm")
|
||||||
with open(output_file, "w") as f:
|
with open(output_file, "w") as f:
|
||||||
f.write(response.text)
|
f.write(response.text)
|
||||||
|
|
||||||
print(f"Successfully downloaded tags for {lang}")
|
print(f"Successfully downloaded tags for {lang}")
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
print(f"Error fetching tags for {lang}: {e}")
|
print(f"Error fetching tags for {lang}: {e}")
|
||||||
|
|
||||||
print("All language tags processed")
|
print("All language tags processed")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue