diff --git a/concho/hpev2.py b/concho/hpev2.py index fa20f99..90cc116 100644 --- a/concho/hpev2.py +++ b/concho/hpev2.py @@ -26,6 +26,78 @@ class Quantity(): class HpeV2ConfiguratorParser(IHtmlConfiguratorParser): + # the body of the HpeV2 html pages look like this: + # + #
+ #
+ #
+ # + #
+ #
+ #
+ # DL380 Gen11 (Cat2 Conf16) + # HPE ProLiant DL380 Gen11 8SFF NC Configure-to-order Server + #
+ #
Expand All
+ #
+ #
+ #
    + #
  • + #
+ #
+ #
+ #
+ # + #
+ #
+ # ... + #
+ #
+ #
Reference Model ID: 46951646
+ #
+ # + # + # EUR + # 1,375.99 + # + # + # + # 15 + # business days + # + #
+ + # inside the : + #
#
# Processors @@ -253,6 +325,29 @@ class HpeV2ConfiguratorParser(IHtmlConfiguratorParser): assert len(ram_options.options) > 0 return ram_options, selected_dimms + @staticmethod + def _parse_base_config_info(html_root: HtmlElement) -> Tuple[str, Price]: + prod_titles_grp_el = html_root.xpath(r".//div[@class='prod-titles-grp']")[0] + assert prod_titles_grp_el + + #
+ # DL380 Gen11 (Cat2 Conf16) + # HPE ProLiant DL380 Gen11 8SFF NC Configure-to-order Server + #
+ product_subtitle = prod_titles_grp_el.xpath(r".//span[@class='product_subtitle']")[0].text.replace('\n', '').replace('\t', '') # eg HPE ProLiant DL380 Gen11 8SFF NC Configure-to-order Server + # print(product_subtitle) + match = re.match(r'^HPE ProLiant DL(?P[3][68][05]) *Gen11 *8SFF *NC *Configure-to-order *Server$', product_subtitle) + assert match + chassis_number = match['chassis_number'] + # configurator.base_config = self._parse_base_config() + chassis_id = f"hpe-proliant-dl{chassis_number}-gen11" + + # 1,375.99 + config_price_as_str = html_root.xpath(r".//span[@class='total_price']")[0].text + config_price = Price(config_price_as_str.replace(',', '')) + print(f'config_price = {config_price}') + return chassis_id, config_price + def parse(self, hpe_configurator_html_file_path: Path, configurator: Configurator): ''' hpe_configurator_html_file_path : eg '/home/graffy/work/concho/catalogs/hpev2/20250314-cat2-conf16-hpe-dl380-gen11.html' @@ -262,33 +357,41 @@ class HpeV2ConfiguratorParser(IHtmlConfiguratorParser): html_root: HtmlElement = parse_html(str(hybris_file_path)).getroot() # print(type(html_root)) - # configurator.base_config = self._parse_base_config() - chassis_id = "hpe-proliant-dl380-gen11" - configurator.chassis = Option(Chassis(chassis_id), 1000.0) # TODO: compute the chassis price - - # configurator.base_config = self._parse_base_config(html_root, configurator) - - configurator.base_config = Config(configurator) - configurator.base_config.num_servers = 1 - configurator.base_config.num_cpu_per_server = 2 - configurator.base_config.get_price - proc_table = self._parse_module_html_table(html_root, 'additional_cpus') proc_module, selected_procs = self._parse_proc_options(proc_table) configurator.add_module(proc_module) assert len(selected_procs) == 1 - configurator.base_config.set_cpu(selected_procs[0]) ram_table = self._parse_module_html_table(html_root, 'ram') ram_module, selected_dimms = self._parse_ram_options(ram_table) configurator.add_module(ram_module) + + chassis_id, config_price = HpeV2ConfiguratorParser._parse_base_config_info(html_root) + + selected_procs_price = sum([proc_module.options[cpu.uid].price for cpu in selected_procs]) + selected_dimms_price = sum([ram_module.options[dimm.uid].price for dimm in selected_dimms]) + chassis_price = config_price - selected_procs_price - selected_dimms_price + base_config = Config(configurator) + base_config.num_servers = 1 + base_config.num_cpu_per_server = 2 + print(f'selected_procs_price = {selected_procs_price}') + print(f'selected_dimms_price = {selected_dimms_price}') + print(f'chassis_price = {chassis_price}') + configurator.chassis = Option(Chassis(chassis_id), chassis_price) + + base_config.set_cpu(selected_procs[0]) + channel_index = 0 for dimm in selected_dimms: - configurator.base_config.cpu_slots_mem[0].mem_channels[channel_index].dimms.append(dimm) + base_config.cpu_slots_mem[0].mem_channels[channel_index].dimms.append(dimm) channel_index += 1 + configurator.base_config = base_config + + # configurator.add_module(self._parse_ram_options(html_root)) # script_elements = html_root.xpath(".//script[@type='text/javascript']") # print('number of javascript scripts:', len(script_elements)) # # script type="text/javascript" # db_jscript = None +