nowy sufix i retry
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
import re
|
||||
import logging
|
||||
|
||||
SUFFIX_TO_CATEGORY = {
|
||||
'G': 'gloss',
|
||||
'S': 'satin',
|
||||
'M': 'mat',
|
||||
'R': 'mat',
|
||||
'MAT': 'mat',
|
||||
'RAW': 'mat',
|
||||
'AG': 'aged',
|
||||
}
|
||||
|
||||
def normalize(text):
|
||||
if not text:
|
||||
return ""
|
||||
@@ -11,7 +21,13 @@ def get_finish_suffix(color):
|
||||
"""Extracts the finish suffix (e.g., 'G', 'S', 'M') from a color string."""
|
||||
if not color:
|
||||
return None
|
||||
return color.strip().split('-')[-1].upper()
|
||||
known_suffixes = list(SUFFIX_TO_CATEGORY.keys())
|
||||
pattern = r'\b(' + '|'.join(known_suffixes) + r')\b'
|
||||
matches = re.findall(pattern, color.upper())
|
||||
if matches:
|
||||
return matches[-1]
|
||||
return None
|
||||
|
||||
|
||||
def get_finish_type(row_data):
|
||||
"""Determines the finish type (GLOSS, SATIN, MAT, MIX) based on color suffixes."""
|
||||
@@ -26,31 +42,25 @@ def get_finish_type(row_data):
|
||||
top_suffix = top_suffix or body_suffix
|
||||
body_suffix = body_suffix or top_suffix
|
||||
|
||||
suffix_to_category = {
|
||||
'G': 'gloss',
|
||||
'S': 'satin',
|
||||
'M': 'mat',
|
||||
'R': 'mat',
|
||||
'MAT': 'mat',
|
||||
'RAW': 'mat',
|
||||
}
|
||||
|
||||
top_category = suffix_to_category.get(top_suffix)
|
||||
body_category = suffix_to_category.get(body_suffix)
|
||||
top_category = SUFFIX_TO_CATEGORY.get(top_suffix)
|
||||
body_category = SUFFIX_TO_CATEGORY.get(body_suffix)
|
||||
|
||||
if not top_category or not body_category:
|
||||
return None # Suffix not in our map
|
||||
return None # Suffix not in our map
|
||||
|
||||
if top_category == body_category:
|
||||
return top_category.upper()
|
||||
|
||||
if 'mat' in {top_category, body_category}:
|
||||
# If categories are different, and one of them is 'mat' or 'aged', it's a MIX.
|
||||
mix_triggers = {'mat', 'aged'}
|
||||
categories = {top_category, body_category}
|
||||
if categories.intersection(mix_triggers):
|
||||
return 'MIX'
|
||||
|
||||
except (KeyError, AttributeError):
|
||||
# This will catch if row_data is not a dict or keys are missing
|
||||
return None
|
||||
|
||||
|
||||
return None
|
||||
|
||||
def process_row(row, mayo, counter):
|
||||
|
||||
Reference in New Issue
Block a user