Skip to content

Commit

Permalink
update: generate-snippet.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryoga-exe committed Oct 23, 2022
1 parent d88328a commit d0f82c5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions generate-snippet.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/usr/bin/env python3

import os
import glob
import json
import yaml
import sys

OUTPUT_EXTENSION = '.code-snippets'
CONFIG_FILE = './config.yml'

g_ignore = []
g_scope = []
Expand Down Expand Up @@ -66,13 +69,12 @@ def create_snippets(dir_name):

def write_file(snippets, directory, filename):
output = str(os.path.join(directory, filename))
if not os.path.exists(directory):
os.makedirs(directory)
os.makedirs(directory, exist_ok=True)
with open(output, mode='w') as f:
f.write(json.dumps(snippets, ensure_ascii=False, indent=4))

if __name__ == '__main__':
with open('./config.yml') as file:
with open(CONFIG_FILE) as file:
config = yaml.safe_load(file)

config_general = config.get('config', 'None')
Expand Down

0 comments on commit d0f82c5

Please sign in to comment.