일단업로드드

This commit is contained in:
Envy_PC 2025-04-08 23:24:56 +09:00
parent 69eba1d843
commit f1070e2218
17 changed files with 208 additions and 91 deletions

View File

@ -70,7 +70,7 @@ class BrowserController(QThread):
self.supabase_manager = supabase_manager
self.parsing_page = None
self.current_options_info = None
self.chrome_hwnd = None
# 임시 디렉토리 생성
self.temp_dir = tempfile.mkdtemp() # 임시 디렉토리 생성
@ -1235,6 +1235,24 @@ class BrowserController(QThread):
except Exception as e:
self.logger.log(f"저장 버튼 클릭 중 오류: {e}", level=logging.ERROR, exc_info=True)
def reset_detail_trans_state(self):
"""detail_trans에 사용되는 상태를 초기화합니다."""
self.logger.log("BrowserController detail_trans 상태 초기화", level=logging.DEBUG)
# 임시 파일 처리
import os
import glob
try:
# 임시 디렉토리의 모든 파일 삭제
for file_path in glob.glob(os.path.join(self.temp_dir, "*.png")):
try:
os.remove(file_path)
self.logger.log(f"상세페이지 임시 파일 삭제: {file_path}", level=logging.DEBUG)
except Exception as e:
self.logger.log(f"상세페이지 임시 파일 삭제 실패: {file_path}, 오류: {e}", level=logging.WARNING)
except Exception as e:
self.logger.log(f"상세페이지 임시 파일 처리 중 오류 발생: {e}", level=logging.ERROR)
async def save_and_ecs_product_edit(self):
"""상품 수정 후 저장 버튼 클릭 및 ESC 전송, 그리고 다이얼로그 닫힘 버튼 클릭을 통한 다이얼로그 종료 처리"""
try:
@ -1609,6 +1627,15 @@ class BrowserController(QThread):
memo_button = button_set.get("memo_button")
shipping_button = button_set.get("shipping_button") # 해외배송비 수정 버튼
# 상태 초기화 코드 추가
self.optionHandler.reset_state()
self.thumbnailHandler.reset_state()
self.titleGenerator.reset_state()
self.clipboardImageManager.reset_state() # 클립보드 초기화
self.reset_detail_trans_state() # detail_trans 관련 상태 초기화
# 그 외 임시 변수 초기화
self.current_options_info = None
# 상품명 수집 오류 처리
self.logger.log(f'{index}/{len(product_buttons)} 버튼의 활성상태 확인 중...', level=logging.DEBUG)

View File

@ -29,6 +29,12 @@ class ClipboardImageManager:
# self.debug = True
def reset_state(self):
"""클립보드 이미지 관리자의 상태를 초기화합니다."""
self.logger.log("ClipboardImageManager 상태 초기화", level=logging.DEBUG)
# 클립보드 비우기
self.clear_clipboard()
def get_base_dir(self):
"""
실행 환경에 따라 base_dir을 설정하는 메서드.

View File

@ -414,7 +414,7 @@ class AutoPercentyGUI(QWidget):
'clientSecret': "",
'optionTrnas': False,
'optionIMGTrans': False,
'optionIMGTrans_type': 0,
'optionIMGTrans_type': False,
'optionAutoSelect': False,
'price': False,
'thumb': False,
@ -423,7 +423,7 @@ class AutoPercentyGUI(QWidget):
'tag': False,
'detail_Option': False,
'detail_IMGTrans': False,
'detail_IMGTrans_type': 0,
'detail_IMGTrans_type': False,
'debug_mode': False,
'recovery_mode': False,
'ed_mode': False, # 등록된 상품을 수정할때
@ -564,11 +564,11 @@ class AutoPercentyGUI(QWidget):
self.optionAutoSelect_toggle.clicked.connect(lambda checked: self.on_toggle_clicked_generic('optionAutoSelect', checked))
# 옵션이미지 번역 타입
self.optionIMGTrans_type_toggle_label = QLabel("옵션번역타입", self)
self.optionIMGTrans_type_toggle = ToggleSwitch(self)
self.optionIMGTrans_type_toggle.clicked.connect(lambda checked: self.on_toggle_clicked_generic('optionIMGTrans_type', checked))
self.optionIMGTrans_type_toggle.setOnText("")
self.optionIMGTrans_type_toggle.setOffText("")
# self.optionIMGTrans_type_toggle_label = QLabel("옵션번역타입", self)
# self.optionIMGTrans_type_toggle = ToggleSwitch(self)
# self.optionIMGTrans_type_toggle.clicked.connect(lambda checked: self.on_toggle_clicked_generic('optionIMGTrans_type', checked))
# self.optionIMGTrans_type_toggle.setOnText("네")
# self.optionIMGTrans_type_toggle.setOffText("퍼")
# 가격 수정 토글
self.price_toggle_label = QLabel("가격 수정", self)
@ -612,11 +612,11 @@ class AutoPercentyGUI(QWidget):
self.detail_IMGTrans_toggle.clicked.connect(lambda checked: self.on_toggle_clicked_generic('detail_IMGTrans', checked))
# 상페 이미지 번역 타입
self.detail_IMGTrans_type_toggle_label = QLabel("상페번역타입", self)
self.detail_IMGTrans_type_toggle = ToggleSwitch(self)
self.detail_IMGTrans_type_toggle.clicked.connect(lambda checked: self.on_toggle_clicked_generic('detail_IMGTrans_type', checked))
self.detail_IMGTrans_type_toggle.setOnText("")
self.detail_IMGTrans_type_toggle.setOffText("")
# self.detail_IMGTrans_type_toggle_label = QLabel("상페번역타입", self)
# self.detail_IMGTrans_type_toggle = ToggleSwitch(self)
# self.detail_IMGTrans_type_toggle.clicked.connect(lambda checked: self.on_toggle_clicked_generic('detail_IMGTrans_type', checked))
# self.detail_IMGTrans_type_toggle.setOnText("네")
# self.detail_IMGTrans_type_toggle.setOffText("퍼")
# 디버그 모드 토글~
self.debug_toggle_label = QLabel("디버그 모드", self)# 작업 완료 메서드 수정
@ -1084,8 +1084,8 @@ class AutoPercentyGUI(QWidget):
self.toggle_layout.addWidget(self.optionIMGTrans_toggle, current_row, 3)
self.toggle_layout.addWidget(self.optionAutoSelect_toggle_label, current_row, 4)
self.toggle_layout.addWidget(self.optionAutoSelect_toggle, current_row, 5)
self.toggle_layout.addWidget(self.optionIMGTrans_type_toggle_label, current_row, 6)
self.toggle_layout.addWidget(self.optionIMGTrans_type_toggle, current_row, 7)
# self.toggle_layout.addWidget(self.optionIMGTrans_type_toggle_label, current_row, 6)
# self.toggle_layout.addWidget(self.optionIMGTrans_type_toggle, current_row, 7)
current_row += 1
self.toggle_layout.addWidget(self.price_toggle_label, current_row, 0)
@ -1106,8 +1106,8 @@ class AutoPercentyGUI(QWidget):
self.toggle_layout.addWidget(self.detail_Option_toggle, current_row, 1)
self.toggle_layout.addWidget(self.detail_IMGTrans_toggle_label, current_row, 2)
self.toggle_layout.addWidget(self.detail_IMGTrans_toggle, current_row, 3)
self.toggle_layout.addWidget(self.detail_IMGTrans_type_toggle_label, current_row, 4)
self.toggle_layout.addWidget(self.detail_IMGTrans_type_toggle, current_row, 5)
# self.toggle_layout.addWidget(self.detail_IMGTrans_type_toggle_label, current_row, 4)
# self.toggle_layout.addWidget(self.detail_IMGTrans_type_toggle, current_row, 5)
current_row += 1
self.toggle_layout.addWidget(self.debug_toggle_label, current_row, 0)
@ -1199,8 +1199,8 @@ class AutoPercentyGUI(QWidget):
label_text = self.optionTrnas_toggle_label.text()
elif key == 'optionIMGTrans':
label_text = self.optionIMGTrans_toggle_label.text()
elif key == 'optionIMGTrans_type':
label_text = self.optionIMGTrans_type_toggle_label.text()
# elif key == 'optionIMGTrans_type':
# label_text = self.optionIMGTrans_type_toggle_label.text()
elif key == 'optionAutoSelect':
label_text = self.optionAutoSelect_toggle_label.text()
elif key == 'price':
@ -1215,8 +1215,8 @@ class AutoPercentyGUI(QWidget):
label_text = self.detail_Option_toggle_label.text()
elif key == 'detail_IMGTrans':
label_text = self.detail_IMGTrans_toggle_label.text()
elif key == 'detail_IMGTans_type':
label_text = self.detail_IMGTrans_type_toggle_label.text()
# elif key == 'detail_IMGTans_type':
# label_text = self.detail_IMGTrans_type_toggle_label.text()
elif key == 'debug_mode':
label_text = self.debug_toggle_label.text()
elif key == 'discord':
@ -1426,7 +1426,7 @@ class AutoPercentyGUI(QWidget):
# self.toggle_states['clientSecret'] = bool(self.client_secret_input.text().strip())
self.toggle_states['optionTrnas'] = self.optionTrnas_toggle.isChecked()
self.toggle_states['optionIMGTrans'] = self.optionIMGTrans_toggle.isChecked()
self.toggle_states['optionIMGTrans_type'] = self.optionIMGTrans_type_toggle.isChecked()
# self.toggle_states['optionIMGTrans_type'] = self.optionIMGTrans_type_toggle.isChecked()
self.toggle_states['optionAutoSelect'] = self.optionAutoSelect_toggle.isChecked()
self.toggle_states['price'] = self.price_toggle.isChecked()
self.toggle_states['thumb'] = self.thumb_toggle.isChecked()
@ -1434,7 +1434,7 @@ class AutoPercentyGUI(QWidget):
self.toggle_states['tag'] = self.tag_toggle.isChecked()
self.toggle_states['detail_Option'] = self.detail_Option_toggle.isChecked()
self.toggle_states['detail_IMGTrans'] = self.detail_IMGTrans_toggle.isChecked()
self.toggle_states['detail_IMGTrans_type'] = self.detail_IMGTrans_type_toggle.isChecked()
# self.toggle_states['detail_IMGTrans_type'] = self.detail_IMGTrans_type_toggle.isChecked()
self.toggle_states['debug_mode'] = self.debug_toggle.isChecked()
# self.toggle_states['recovery_mode'] = self.recovery_mode_toggle.isChecked()
# self.toggle_states['ed_mode'] = self.ed_mode_toggle.isChecked()

View File

@ -94,6 +94,27 @@ class OptionHandler:
'checked_states': {} # 체크된 상태를 저장하는 추가 변수
}
def reset_state(self):
"""옵션 핸들러의 상태를 초기화합니다."""
self.logger.log("OptionHandler 상태 초기화", level=logging.DEBUG)
self.is_percenty_success = False
self.is_gpt_success = False
self.is_not_option_wm = True
self.init_option_info()
# 임시 파일 처리
import os
import glob
try:
# 임시 디렉토리의 모든 파일 삭제
for file_path in glob.glob(os.path.join(self.temp_dir, "*.png")):
try:
os.remove(file_path)
self.logger.log(f"임시 파일 삭제: {file_path}", level=logging.DEBUG)
except Exception as e:
self.logger.log(f"임시 파일 삭제 실패: {file_path}, 오류: {e}", level=logging.WARNING)
except Exception as e:
self.logger.log(f"임시 파일 처리 중 오류 발생: {e}", level=logging.ERROR)
def get_selected_translated_options(self):
"""클래스 변수에 저장된 선택된 번역된 옵션들을 반환"""
return self.option_info.get('selected_translated_options', [])
@ -800,7 +821,7 @@ class OptionHandler:
await self.page.click(self.low_order_button_locator)
async def update_option_image_to_per(self):
async def update_option_image_to_per(self, debug_flag):
pass

View File

@ -337,10 +337,10 @@ class PriceHandler:
"""
try:
total_shipping_cost = base_cost
min_price_for_extra_shipping = self.shipping_config.get('min_price_for_extra_shipping', 0)
min_price_for_extra_shipping = self.shipping_config.get('min_shipping', 0)
thresholds = self.shipping_config.get('thresholds', [])
increment_unit = self.shipping_config.get('increment_unit', 0)
additional_costs = self.shipping_config.get('additional_costs', [])
additional_costs = self.shipping_config.get('extra_costs', [])
if not thresholds or not additional_costs:
raise ValueError("기준 구간과 추가 비용 정보는 비워둘 수 없습니다.")
@ -585,7 +585,7 @@ class PriceHandler:
"""
try:
thresholds = self.margin_config.get('thresholds', [])
additional_margins = self.margin_config.get('additional_margins', [])
additional_margins = self.margin_config.get('margins', [])
if not thresholds or not additional_margins:
raise ValueError("기준 구간과 추가 마진 정보는 비워둘 수 없습니다.")

View File

@ -1010,40 +1010,34 @@ class DBManager:
# 관련 키프리스 결과도 가져오기
kipris_results = common_word_data.get("kipris_results", [])
# 키프리스 결과 저장
for kipris in kipris_results:
# 키프리스 결과에 대한 새로운 UUID 생성
kipris_id = str(uuid.uuid4())
now = datetime.now(timezone.utc).isoformat()
# 필드 가져오기 (None인 경우 빈 문자열로 대체)
application_status = kipris.get("application_status", "") or ""
registration_date = kipris.get("registration_date", "") or ""
applicant_name = kipris.get("applicant_name", "") or ""
classification_code = kipris.get("classification_code", "") or ""
category_description = kipris.get("category_description", "") or ""
drawing = kipris.get("drawing", "") or ""
bigDrawing = kipris.get("bigDrawing", "") or ""
# 키프리스 결과의 ID가 문자열이 아니면 문자열로 변환
kipris_id = str(kipris.get("id", str(uuid.uuid4())))
self.cursor.execute("""
INSERT INTO user_banned_words_kipris
(id, banned_word_id, application_status, registration_date, applicant_name,
classification_code, category_description, drawing, bigDrawing, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
INSERT OR IGNORE INTO user_banned_words_kipris
(id, word_id, application_number, title, applicant, status,
application_date, registration_date, expiration_date,
similar_group, local_drawing_path, local_bigDrawing_path)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (
kipris_id,
user_word_id, # 새로 생성된 또는 기존 사용자 금지어 ID
application_status,
registration_date,
applicant_name,
classification_code,
category_description,
drawing,
bigDrawing,
now,
now
user_word_id,
kipris.get("application_number"),
kipris.get("title"),
kipris.get("applicant"),
kipris.get("status"),
kipris.get("application_date"),
kipris.get("registration_date"),
kipris.get("expiration_date"),
kipris.get("similar_group"),
kipris.get("local_drawing_path"),
kipris.get("local_bigDrawing_path")
))
self.conn.commit()
self.logger.log(f"키워드 '{keyword}'에 대한 키프리스 결과 {len(kipris_results)}개 저장 완료", level=logging.INFO)
return user_word_id
except Exception as e:

View File

@ -798,10 +798,11 @@ class KeywordManager(QDialog):
selected_data = [item.data(1) for item in selected_items if item is not None]
menu = QMenu()
sources = set()
# 공통금지어 보기 모드인 경우, 메뉴 내용 변경
if self.toggle_common_banned.isChecked():
# 공통금지어 보기 모드에서는 "내 리스트로 가져오기" 옵션만 제공
sources = set()
for data in selected_data:
if data is not None:
sources.add(data.get("source", "local"))
@ -1179,9 +1180,22 @@ class KeywordManager(QDialog):
self.logger.log(f"키워드 '{keyword}'의 공통 금지어 레코드를 찾을 수 없습니다.", level=logging.WARNING)
continue
# 공통 금지어의 키프리스 결과 조회
common_word_id = common_record.get("id")
if common_word_id:
kipris_results = self.db_manager.spManager.fetch_kipris_results_for_common_word(common_word_id)
self.logger.log(f"공통 금지어 '{keyword}'의 키프리스 결과 {len(kipris_results)}개 조회 완료", level=logging.INFO)
else:
kipris_results = []
self.logger.log(f"공통 금지어 '{keyword}'의 ID가 없습니다.", level=logging.WARNING)
# 공통 금지어와 키프리스 데이터를 함께 로컬 DB에 저장
keyword_id = self.db_manager.import_common_keyword(keyword, grade_online)
kipris_results = common_record.get("kipris_results", [])
common_word_data = {
"banned_word": keyword,
"grade": grade_online,
"kipris_results": kipris_results
}
keyword_id = self.db_manager.import_common_keyword(common_word_data)
self.logger.log(f"키워드 '{keyword}' (ID: {keyword_id})에 연결된 키프리스 결과 {len(kipris_results)}", level=logging.DEBUG)
@ -2100,7 +2114,12 @@ class KeywordManager(QDialog):
if reply == QMessageBox.Yes:
# 가져오기 처리
success = self.db_manager.import_common_keyword(keyword, grade)
common_word_data = {
"banned_word": keyword,
"grade": grade,
"kipris_results": self._keyword_items.get(keyword, {}).get("record", {}).get("kipris_results", [])
}
success = self.db_manager.import_common_keyword(common_word_data)
if success:
QMessageBox.information(dialog, "가져오기 완료", f"'{keyword}'가 내 리스트에 추가되었습니다.")

View File

@ -280,14 +280,14 @@ class PriceSettingManager(QDialog):
optimal_layout.setSpacing(10)
optimal_layout.addWidget(QLabel("하한 비율 (%):"), 0, 0)
self.spin_lower_bound = CommaSpinBox()
self.spin_lower_bound.setRange(0, 100)
self.spin_lower_bound.setRange(0, 200)
self.spin_lower_bound.setValue(85) # 85%
self.spin_lower_bound.setSuffix("%")
optimal_layout.addWidget(self.spin_lower_bound, 0, 1)
optimal_layout.addWidget(QLabel("상한 비율 (%):"), 1, 0)
self.spin_upper_bound = CommaSpinBox()
self.spin_upper_bound.setRange(0, 100)
self.spin_upper_bound.setRange(0, 200)
self.spin_upper_bound.setValue(115) # 115%
self.spin_upper_bound.setSuffix("%")
optimal_layout.addWidget(self.spin_upper_bound, 1, 1)
@ -541,6 +541,9 @@ class PriceSettingManager(QDialog):
self.category_tree.setColumnWidth(5, 80)
self.category_tree.setColumnWidth(6, 80)
# 더블클릭 이벤트 연결
self.category_tree.itemDoubleClicked.connect(self.on_category_item_double_clicked)
# 스페이스바 이벤트 처리를 위한 키 프레스 이벤트 연결
self.category_tree.keyPressEvent = self.tree_key_press_event
@ -1160,14 +1163,14 @@ class PriceSettingManager(QDialog):
'margin_add_to_shipping_cost': self.shippingToggleButton.isChecked()
}
def set_optimal_price_config(self, sold_price, cost_price2X, calculated_price, lower_bound, upper_bound, weights):
def set_optimal_price_config(self, sold_price, cost_price2X, calculated_price, lower_bound, upper_bound, ratios):
return {
'sold_price': sold_price,
'cost_price2X': cost_price2X,
'calculated_price': calculated_price,
'lower_bound': lower_bound,
'upper_bound': upper_bound,
'weights': weights
'ratios': ratios
}
def round_to_UP(self, number, nearest=1000):
@ -1437,7 +1440,7 @@ class PriceSettingManager(QDialog):
optimal = price_settings["optimal_price_config"]
self.spin_lower_bound.setValue(optimal.get("lower_bound", 0.85) * 100)
self.spin_upper_bound.setValue(optimal.get("upper_bound", 1.15) * 100)
weights = optimal.get("weights", {"sold_price": 0.5, "cost_price2X": 0.3, "calculated_price": 0.2})
weights = optimal.get("ratios", {"sold_price": 0.5, "cost_price2X": 0.3, "calculated_price": 0.2})
self.spin_ratio_sold.setValue(weights.get("sold_price", 0.5) * 100)
self.spin_ratio_cost.setValue(weights.get("cost_price2X", 0.3) * 100)
self.spin_ratio_calc.setValue(weights.get("calculated_price", 0.2) * 100)
@ -1493,23 +1496,46 @@ class PriceSettingManager(QDialog):
QMessageBox.critical(self, "저장 오류", f"설정 저장 중 오류가 발생했습니다: {e}")
def get_category_settings(self):
settings = []
count = self.category_tree.topLevelItemCount()
for i in range(count):
item = self.category_tree.topLevelItem(i)
# 여기서는 첫 번째 열에 p_ss_category_code가 저장되어 있다고 가정
p_ss_category_code = item.text(0)
cmb_stage_text = item.text(5)
banned_flag_text = item.text(6)
mapping = {"미적용": 0, "1단계": 1, "2단계": 2, "3단계": 3}
crmobi_stage = mapping.get(cmb_stage_text, 0)
banned_flag = 1 if banned_flag_text == "True" else 0
settings.append({
"p_ss_category_code": p_ss_category_code,
"crmobi_stage": crmobi_stage,
"banned_flag": banned_flag
})
return settings
try:
# 기존 설정 가져오기
user_settings = self.db_manager.get_user_settings_for_price(self.user_id)
existing_settings = {}
if user_settings and "category_settings" in user_settings:
for cs in user_settings["category_settings"]:
existing_settings[cs["p_ss_category_code"]] = cs
# 현재 트리의 설정으로 업데이트
count = self.category_tree.topLevelItemCount()
for i in range(count):
item = self.category_tree.topLevelItem(i)
p_ss_category_code = item.text(0)
cmb_stage_text = item.text(5)
banned_flag_text = item.text(6)
mapping = {"미적용": 0, "1단계": 1, "2단계": 2, "3단계": 3}
crmobi_stage = mapping.get(cmb_stage_text, 0)
banned_flag = 1 if banned_flag_text == "True" else 0
if p_ss_category_code in existing_settings:
# 기존 설정 업데이트
existing_settings[p_ss_category_code].update({
"crmobi_stage": crmobi_stage,
"banned_flag": banned_flag
})
else:
# 새로운 설정 추가
existing_settings[p_ss_category_code] = {
"p_ss_category_code": p_ss_category_code,
"crmobi_stage": crmobi_stage,
"banned_flag": banned_flag
}
# 딕셔너리를 리스트로 변환하여 반환
return list(existing_settings.values())
except Exception as e:
self.logger.log(f"카테고리 설정 가져오기 중 오류: {e}", level=logging.ERROR, exc_info=True)
return []
def update_cmb_settings_from_db(self):
"""DB의 crmobi_stages 테이블에서 값을 읽어와 각 단계별 설정 위젯에 반영합니다."""

View File

@ -520,8 +520,9 @@ class WhaleTranslator:
time.sleep(1) # 페이지 로딩 대기
# 이미지 우클릭 및 쇼핑 렌즈 실행
image = whale_window.child_window(control_type="Image")
image.right_click_input()
image_element = self.whale_window.child_window(title="누락된 이미지 설명을 확인하려면 컨텍스트 메뉴를 여세요.", control_type="Image")
if image_element.exists():
self.safe_click(image_element, right=True)
self.logger.log(f"쇼핑 렌즈 검색", level=logging.INFO)
menu_item = whale_window.child_window(title="쇼핑렌즈로 검색하기", control_type="MenuItem")

View File

@ -2,6 +2,7 @@ import os
import sys
import logging
import asyncio
import glob
class ThumbnailHandler:
def __init__(self, locator_manager, browser_controller, logger, whale_translator, clipboardImageManager, toggle_states, update_detail_progress_signal, set_progress_visible_signal):
@ -57,6 +58,22 @@ class ThumbnailHandler:
self.whale_translator = self.browser_controller.get_whale()
self.logger.log(f"whale_translator 업데이트 : {self.whale_translator}", level=logging.DEBUG)
def reset_state(self):
"""썸네일 핸들러의 상태를 초기화합니다."""
self.logger.log("ThumbnailHandler 상태 초기화", level=logging.DEBUG)
# 임시 파일 처리
try:
# 임시 디렉토리의 모든 파일 삭제
for file_path in glob.glob(os.path.join(self.temp_dir, "*.png")):
try:
os.remove(file_path)
self.logger.log(f"썸네일 임시 파일 삭제: {file_path}", level=logging.DEBUG)
except Exception as e:
self.logger.log(f"썸네일 임시 파일 삭제 실패: {file_path}, 오류: {e}", level=logging.WARNING)
except Exception as e:
self.logger.log(f"썸네일 임시 파일 처리 중 오류 발생: {e}", level=logging.ERROR)
async def process_thumbnails(self, title_infos):
thumb_trans_type = title_infos['thumb_trans_type']

View File

@ -91,6 +91,12 @@ class TitleGenerator:
"top_product_prices": None, # 추가된 필드
}
def reset_state(self):
"""타이틀 생성기의 상태를 초기화합니다."""
self.logger.log("TitleGenerator 상태 초기화", level=logging.DEBUG)
self.initial_title_infos()
# 기타 상태 변수 초기화가 필요하면 여기에 추가
def update_page(self, page1):
self.page = page1
self.logger.log(f"page객체 업데이트 : {page1}", level=logging.DEBUG)
@ -301,9 +307,9 @@ class TitleGenerator:
keyword_title = list(set(keyword_title))
# 11. 금지어 처리
# 먼저 “금지” 등급이 있는 단어 리스트를 추출
# 먼저 "금지" 등급이 있는 단어 리스트를 추출
forbidden_grade_words = self.forbidden_word_manager.get_forbidden_grade_words(keyword_title)
# “비허용” 등급 단어는 제목에서 제거
# "비허용" 등급 단어는 제목에서 제거
keyword_title = [word for word in keyword_title if not self.forbidden_word_manager.is_word_forbidden(word)]
self.logger.log(f'keyword_title after forbidden filter : {keyword_title}', level=logging.DEBUG)
@ -320,7 +326,7 @@ class TitleGenerator:
product_title = keyword_title.append(' '.join(keyword_title))
self.logger.log(f'because product_title is None, final product_title: {product_title}', level=logging.DEBUG)
# 13. 만약 “금지” 등급 단어가 있었다면 접두어 추가 (해당 단어도 함께 표기)
# 13. 만약 "금지" 등급 단어가 있었다면 접두어 추가 (해당 단어도 함께 표기)
if forbidden_grade_words:
product_title = self.add_forbidden_prefix(product_title, forbidden_grade_words)
return product_title
@ -397,9 +403,9 @@ class TitleGenerator:
keyword_title = list(set(keyword_title))
# 9. 금지어 처리
# 먼저 “금지” 등급이 있는지 확인 (최종 제목에 접두어 추가 용도)
# 먼저 "금지" 등급이 있는지 확인 (최종 제목에 접두어 추가 용도)
has_forbidden_grade = self.forbidden_word_manager.check_forbidden_grade(keyword_title)
# “비허용” 등급 단어는 제목에서 제거
# "비허용" 등급 단어는 제목에서 제거
keyword_title = [word for word in keyword_title if not self.forbidden_word_manager.is_word_forbidden(word)]
self.logger.log(f'keyword_title after forbidden filter : {keyword_title}', level=logging.DEBUG)
@ -407,7 +413,7 @@ class TitleGenerator:
product_title = self.gpt_client.generate_product_name_next(words=keyword_title, original_name=original_name, top_titles=top_titles)
self.logger.log(f'final product_title: {product_title}', level=logging.DEBUG)
# 11. 만약 “금지” 등급 단어가 있었다면 접두어 추가
# 11. 만약 "금지" 등급 단어가 있었다면 접두어 추가
if has_forbidden_grade:
product_title = self.add_forbidden_prefix(product_title)
return product_title
@ -552,7 +558,7 @@ class TitleGenerator:
def set_banned_category_title(self, banned_category_info: dict) -> str:
"""
title_infos의 카테고리 정보를 기반으로,
[금지카테고리]카테1-카테2-카테3-카테4 형식의 제목을 생성하여 반환합니다.
"[금지카테고리]카테1-카테2-카테3-카테4" 형식의 제목을 생성하여 반환합니다.
"""
banned_product_title = "금지카테고리//미지정"
@ -1036,7 +1042,7 @@ class TitleGenerator:
ss_element = self.page.locator(ss_selector)
count_ss = await ss_element.count()
if count_ss > 1:
# 요소 2개 이상이면 첫 번째는 인증 요소, 두 번째가 실제 텍스트
# 인증 요소 등이 포함되어 있으므로 두 번째 요소에서 실제 텍스트 추출
category_text_ss = await ss_element.nth(1).inner_text()
self.logger.log("SS: 인증 요소 포함되어 있어 두 번째 요소에서 카테고리 텍스트 추출.", level=logging.DEBUG)
category_data["is_certified_ss"] = True

Binary file not shown.

Before

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB