Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
CodedRedGIT committed Aug 21, 2024
1 parent ca4daca commit 70abad1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
74 changes: 37 additions & 37 deletions ingredients/combine.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import os
import json

def collect_files():
current_dir = os.getcwd()
file_dict = {}

for filename in os.listdir(current_dir):
if os.path.isfile(filename):
file_path = os.path.join(current_dir, filename)
file_name_without_ext = os.path.splitext(filename)[0]
print(file_name_without_ext)

if (file_name_without_ext == 'combine' or file_name_without_ext == 'file_contents'):
continue

try:
with open(file_path, 'r', encoding='utf-8') as file:
file_contents = file.read()
file_dict[file_name_without_ext] = file_contents
except Exception as e:
print(f"Error reading file {filename}: {str(e)}")

return file_dict

def create_js_dictionary(file_dict):
js_dict = json.dumps(file_dict, indent=2)
js_output = f"const fileContents = {js_dict};"

with open('file_contents.js', 'w', encoding='utf-8') as js_file:
js_file.write(js_output)

print("JavaScript dictionary has been created in 'file_contents.js'")

if __name__ == "__main__":
file_dict = collect_files()
create_js_dictionary(file_dict)
import os
import json

def collect_files():
current_dir = os.getcwd()
file_dict = {}

for filename in os.listdir(current_dir):
if os.path.isfile(filename):
file_path = os.path.join(current_dir, filename)
file_name_without_ext = os.path.splitext(filename)[0]
print(file_name_without_ext)

if (file_name_without_ext == 'combine' or file_name_without_ext == 'file_contents'):
continue

try:
with open(file_path, 'r', encoding='utf-8') as file:
file_contents = file.read()
file_dict[file_name_without_ext] = file_contents
except Exception as e:
print(f"Error reading file {filename}: {str(e)}")

return file_dict

def create_js_dictionary(file_dict):
js_dict = json.dumps(file_dict, indent=2)
js_output = f"export const fileContents = {js_dict};"

with open('file_contents.js', 'w', encoding='utf-8') as js_file:
js_file.write(js_output)

print("JavaScript dictionary has been created in 'file_contents.js'")

if __name__ == "__main__":
file_dict = collect_files()
create_js_dictionary(file_dict)
Loading

0 comments on commit 70abad1

Please sign in to comment.