50 lines
2.1 KiB
Python
50 lines
2.1 KiB
Python
import configparser
|
|
|
|
class LocatorManager:
|
|
def __init__(self, config_file='config.ini'):
|
|
self.config_file = config_file
|
|
self.selectors = {}
|
|
self.load_locators_from_config()
|
|
|
|
def load_locators_from_config(self):
|
|
"""
|
|
config.ini 파일에서 선택자를 불러와 self.selectors에 저장
|
|
"""
|
|
config = configparser.ConfigParser()
|
|
config.read(self.config_file)
|
|
|
|
# PriceLocators 섹션
|
|
self.selectors['PriceLocators'] = {
|
|
'return_fee_input_locator': config.get('PriceLocators', 'return_fee_input_locator'),
|
|
'first_delv_fee_input_locator': config.get('PriceLocators', 'first_delv_fee_input_locator'),
|
|
'exchange_fee_input_locator': config.get('PriceLocators', 'exchange_fee_input_locator'),
|
|
'plus_margin_locator': config.get('PriceLocators', 'plus_margin_locator'),
|
|
'oversea_shipping_locator': config.get('PriceLocators', 'oversea_shipping_locator'),
|
|
'option_count_text_locator': config.get('PriceLocators', 'option_count_text_locator'),
|
|
'product_cost_locator': config.get('PriceLocators', 'product_cost_locator'),
|
|
'standard_selling_price_locator': config.get('PriceLocators', 'standard_selling_price_locator')
|
|
}
|
|
|
|
# OptionLocators 섹션
|
|
self.selectors['OptionLocators'] = {
|
|
'option_input_locator': config.get('OptionLocators', 'option_input_locator'),
|
|
'option_price_locator': config.get('OptionLocators', 'option_price_locator')
|
|
}
|
|
|
|
def get_locator(self, section, key):
|
|
"""
|
|
섹션과 키를 받아서 해당 선택자를 반환
|
|
"""
|
|
return self.selectors.get(section, {}).get(key, None)
|
|
|
|
def get_category_data(self, section, category):
|
|
"""
|
|
Config.ini에서 특정 카테고리에 대한 데이터를 반환하는 메서드
|
|
"""
|
|
try:
|
|
category_data = self.config[section][category]
|
|
return category_data
|
|
except KeyError:
|
|
self.logger.error(f"{section} 섹션에서 {category} 카테고리를 찾을 수 없습니다.")
|
|
return None
|