JSenkCC commited on
Commit
35ccc0b
·
verified ·
1 Parent(s): b89b96b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -222,12 +222,17 @@ def read_files(file_paths):
222
  file_contents = {}
223
  for file_path in file_paths:
224
  if os.path.exists(file_path):
225
- with open(file_path, 'r') as file:
226
- file_contents[file_path] = file.read()
 
 
 
 
227
  else:
228
  print(f"File not found: {file_path}")
229
  return file_contents
230
 
 
231
  def generate_prompt(file_contents, functionality_description):
232
  """Generates a prompt for Gemini to analyze the files."""
233
  prompt = "Analyze the following code files to identify all functions required to implement the functionality: "
 
222
  file_contents = {}
223
  for file_path in file_paths:
224
  if os.path.exists(file_path):
225
+ try:
226
+ # Attempt to read the file as UTF-8
227
+ with open(file_path, 'r', encoding='utf-8') as file:
228
+ file_contents[file_path] = file.read()
229
+ except UnicodeDecodeError:
230
+ print(f"Skipping binary or non-UTF-8 file: {file_path}")
231
  else:
232
  print(f"File not found: {file_path}")
233
  return file_contents
234
 
235
+
236
  def generate_prompt(file_contents, functionality_description):
237
  """Generates a prompt for Gemini to analyze the files."""
238
  prompt = "Analyze the following code files to identify all functions required to implement the functionality: "