Skip to content

Commit

Permalink
Add comment to webui.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hassandraga committed Jul 13, 2024
1 parent 450197f commit ecccc7e
Show file tree
Hide file tree
Showing 2 changed files with 1,416 additions and 1,395 deletions.
24 changes: 12 additions & 12 deletions bridge/js2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@

def js_to_c_header(input_filename, output_filename):
try:
# Read JS file content
with open(input_filename, 'r', encoding='utf-8') as file_js:
content = file_js.read()
file_js.close()

print(f"Converting '{input_filename}' to '{output_filename}'...")

# comment
Expand All @@ -27,8 +22,19 @@ def js_to_c_header(input_filename, output_filename):
"// Canada.\n\n"
)

# Read JS file content
with open(input_filename, 'r', encoding='utf-8') as file_js:
content = file_js.read()
file_js.close()

# Add comment to js
new_content = comment + content
with open(input_filename, 'w') as file_js:
file_js.write(new_content)
file_js.close()

# Convert each character in JS content to its hexadecimal value
hex_values = ["0x{:02x}".format(ord(char)) for char in content]
hex_values = ["0x{:02x}".format(ord(char)) for char in new_content]

# Prepare the content for the C header file
header_content = (
Expand All @@ -49,12 +55,6 @@ def js_to_c_header(input_filename, output_filename):
with open(output_filename, 'w', encoding='utf-8') as file_h:
file_h.write(header_content)
file_h.close()

# Add comment to js
new_content = comment + content
with open(input_filename, 'w') as file_js:
file_js.write(new_content)
file_js.close()

except FileNotFoundError:
print(f"Error: File '{input_filename}' not found.")
Expand Down
Loading

0 comments on commit ecccc7e

Please sign in to comment.