Merge 12d25e487abf203d2e815880b03ef375460abdc8 into fb1e5f2641b3c44e0c6cebd381a9c98d5d01f610

This commit is contained in:
Ghost user 2025-04-12 10:31:04 +08:00 committed by GitHub
commit 85621a59b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,38 @@
import csv
import json
import sys
snippets = []
# Open the CSV file and read the data
with open("../prompts.csv", "r") as file:
reader = csv.reader(file)
for row in reader:
# Extract the snippet information from the row
name = row[0]
description = row[1]
# Create the snippet template
snippet = {name.lower():''}
snippet[name.lower()] = {
"scope": "markdown,python,txt",
"prefix": name.lower(),
"body": [description],
"description": name
}
# Add the snippet to the list
snippets.append(snippet)
# Write the snippets to the Visual Studio Code snippets file
# Where sys.argv[1] is the location of your snippets config file.
# Usually in .vscode folder
# Example: python3 csv_to_vs_snippets.py ./.vscode/chat_gpt_snippets.code-snippets
with open(sys.argv[1], "w") as file:
file.write('{')
for snippet in snippets:
snippet_key = list(snippet.keys())[0]
if snippet_key == 'act':
continue # Skips CSV fields.
file.write(f'"{snippet_key}":')
file.write(json.dumps(snippet[snippet_key], indent=4))
file.write(',')
file.write('}')