mariotawfik commited on
Commit
21c5249
·
1 Parent(s): 3fa9dc7
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -95,18 +95,24 @@ def keygen(eval_key):
95
  def safe_eval(encodings):
96
  try:
97
  # Debugging: Print the encodings string to understand its format
98
- print("Encodings String:", encodings)
99
 
100
- # Replace newline characters and ensure proper commas are added
101
- sanitized = encodings.replace('\n', ',').replace(' ', ',')
102
- sanitized = sanitized.replace(',,', ',') # Handle potential double commas
 
 
 
 
 
103
 
104
  # Debugging: Print the sanitized string
105
- print("Sanitized String:", sanitized)
106
 
 
107
  return eval(sanitized)
108
- except SyntaxError:
109
- raise ValueError("Failed to safely parse the encodings string.")
110
 
111
  def encode_quantize(test_file, eval_key, encodings):
112
  ugly = ['Machine', 'SizeOfOptionalHeader', 'Characteristics',
 
95
  def safe_eval(encodings):
96
  try:
97
  # Debugging: Print the encodings string to understand its format
98
+ print("Original Encodings String:", encodings)
99
 
100
+ # Replace newline characters and multiple spaces
101
+ sanitized = encodings.replace('\n', ',').replace(' ', '')
102
+ # Remove any accidental double commas
103
+ sanitized = sanitized.replace(',,', ',')
104
+
105
+ # Make sure we have removed any trailing commas
106
+ if sanitized.endswith(','):
107
+ sanitized = sanitized[:-1]
108
 
109
  # Debugging: Print the sanitized string
110
+ print("Sanitized Encodings String:", sanitized)
111
 
112
+ # Use eval to convert the string to a list or array
113
  return eval(sanitized)
114
+ except SyntaxError as e:
115
+ raise ValueError(f"Failed to safely parse the encodings string: {e}")
116
 
117
  def encode_quantize(test_file, eval_key, encodings):
118
  ugly = ['Machine', 'SizeOfOptionalHeader', 'Characteristics',