ifire commited on
Commit
a15d1a4
1 Parent(s): 286009e

Try again.

Browse files
Files changed (1) hide show
  1. app.py +18 -6
app.py CHANGED
@@ -96,18 +96,30 @@ def prompt_to_layout(user_prompt, intensity, fpath=None):
96
  split_txt = txt.split(':')
97
  coords.append(split_txt[1].rstrip())
98
  coordinates = [re.findall(regex, coord) for coord in coords]
99
-
100
  num_coords = []
 
101
  for coord in coordinates:
102
- temp = []
 
103
  for xy in coord:
104
  numbers = xy.split(',')
 
105
  for num in numbers:
106
- clean_num = re.sub(r'^\D*|\D*$', '', num)
107
- if clean_num.isdigit():
108
- temp.append(int(clean_num)/14.2)
 
 
 
 
 
 
 
 
109
  num_coords.append(temp)
110
-
 
111
  new_spaces = []
112
  for i, v in enumerate(spaces):
113
  totalcount = spaces.count(v)
 
96
  split_txt = txt.split(':')
97
  coords.append(split_txt[1].rstrip())
98
  coordinates = [re.findall(regex, coord) for coord in coords]
99
+ # Initialize an empty list to store the numerical coordinates
100
  num_coords = []
101
+ # Iterate over each coordinate in the coordinates list
102
  for coord in coordinates:
103
+ temp = [] # Temporary list to store the cleaned numbers
104
+ # Split the coordinate into individual numbers
105
  for xy in coord:
106
  numbers = xy.split(',')
107
+ # Clean each number and convert it to an integer
108
  for num in numbers:
109
+ clean_num = re.sub(r'^\D*|\D*$', '', num) # Remove non-digit characters
110
+ # Check if the cleaned number is a digit
111
+ if clean_num.isdigit():
112
+ # Convert the cleaned number to an integer and divide it by 14.2
113
+ # If division by zero occurs, skip this number
114
+ try:
115
+ temp.append(int(clean_num)/14.2)
116
+ except ZeroDivisionError:
117
+ continue # Skip this number and continue with the next one
118
+
119
+ # Append the temporary list to the num_coords list
120
  num_coords.append(temp)
121
+
122
+
123
  new_spaces = []
124
  for i, v in enumerate(spaces):
125
  totalcount = spaces.count(v)