Marthee commited on
Commit
efd3b30
·
verified ·
1 Parent(s): ea5bbe4

Update google_sheet_Legend.py

Browse files
Files changed (1) hide show
  1. google_sheet_Legend.py +4 -9
google_sheet_Legend.py CHANGED
@@ -509,8 +509,7 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
509
  for idx, existing_color in enumerate(color_list):
510
  existing_color = tuple(existing_color) # Ensure it's a tuple for comparison
511
 
512
- flag_area_occurrences=0
513
- flag_perimeter_occurrences=0
514
  # print('eee',existing_color,color)
515
  if is_color_within_tolerance(existing_color, color, tolerance):
516
  print(f'Color {color} found close to {existing_color} at index {idx}')
@@ -535,8 +534,6 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
535
  matches = re.findall(r'\b\d+\b', str(comment))
536
  area_occurrences = int(matches[0]) - 1
537
  perimeter_occurrences = int(matches[1])
538
- if area_occurrences==0:
539
- flag_area_occurrences=1
540
  else:
541
  area_occurrences = int(SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]) - 1
542
  perimeter_occurrences = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]
@@ -549,8 +546,6 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
549
  matches = re.findall(r'\b\d+\b', str(comment))
550
  area_occurrences = int(matches[0])
551
  perimeter_occurrences = int(matches[1]) -1
552
- if perimeter_occurrences==0:
553
- flag_perimeter_occurrences=1
554
  else:
555
 
556
  area_occurrences = int(SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')])
@@ -562,7 +557,7 @@ def deletefromlegend(deletedrows, SimilarAreaDictionarycopy, section, areaPermAr
562
 
563
 
564
  # Handle occurrences and row deletion
565
- if flag_area_occurrences==1 and flag_perimeter_occurrences==1:
566
  # if area_occurrences ==0 and perimeter_occurrences==0:
567
  if str(idx) not in indicies_toDelete:
568
  indicies_toDelete.append(str(idx))
@@ -777,7 +772,7 @@ def deletemarkups(list1, dbPath, path):
777
  deletedrows = deletedrows[['content', 'id', 'subject', 'color']]
778
  # Drop rows where 'content' starts with 'Scale'
779
  deletedrows = deletedrows.drop(deletedrows.index[deletedrows['content'].str.startswith('Scale')])
780
- else:
781
  flag = 0
782
 
783
- return deletedrows
 
509
  for idx, existing_color in enumerate(color_list):
510
  existing_color = tuple(existing_color) # Ensure it's a tuple for comparison
511
 
512
+
 
513
  # print('eee',existing_color,color)
514
  if is_color_within_tolerance(existing_color, color, tolerance):
515
  print(f'Color {color} found close to {existing_color} at index {idx}')
 
534
  matches = re.findall(r'\b\d+\b', str(comment))
535
  area_occurrences = int(matches[0]) - 1
536
  perimeter_occurrences = int(matches[1])
 
 
537
  else:
538
  area_occurrences = int(SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]) - 1
539
  perimeter_occurrences = SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')]
 
546
  matches = re.findall(r'\b\d+\b', str(comment))
547
  area_occurrences = int(matches[0])
548
  perimeter_occurrences = int(matches[1]) -1
 
 
549
  else:
550
 
551
  area_occurrences = int(SimilarAreaDictionarycopy.iloc[int(idx), SimilarAreaDictionarycopy.columns.get_loc('Occurences')])
 
557
 
558
 
559
  # Handle occurrences and row deletion
560
+ if area_occurrences==0 and perimeter_occurrences==0:
561
  # if area_occurrences ==0 and perimeter_occurrences==0:
562
  if str(idx) not in indicies_toDelete:
563
  indicies_toDelete.append(str(idx))
 
772
  deletedrows = deletedrows[['content', 'id', 'subject', 'color']]
773
  # Drop rows where 'content' starts with 'Scale'
774
  deletedrows = deletedrows.drop(deletedrows.index[deletedrows['content'].str.startswith('Scale')])
775
+ else:
776
  flag = 0
777
 
778
+ return deletedrows