def get_or_add_bugzilla_component()

in treeherder/etl/files_bugzilla_map.py [0:0]


    def get_or_add_bugzilla_component(self, files_bugzilla_data, path):
        product_component_data = files_bugzilla_data[path]
        product_component_str = product_component_data[0] + " :: " + product_component_data[1]
        if product_component_str in self.bugzilla_components:
            return self.bugzilla_components[product_component_str]
        try:
            product = product_component_data[0]
            component = product_component_data[1]
            if len(product) > self.max_product_length:
                logger.error(
                    "error inserting Bugzilla product and component \"'%s' :: '%s'\" into db (file skipped: '%s'): product is too long (has %d characters, max is %d)",
                    product,
                    component,
                    path,
                    len(product),
                    self.max_product_length,
                )
                return
            if len(component) > self.max_component_length:
                logger.error(
                    "error inserting Bugzilla product and component \"'%s' :: '%s'\" into db (file skipped: '%s'): component is too long (has %d characters, max is %d)",
                    product,
                    component,
                    path,
                    len(component),
                    self.max_component_length,
                )
                return
            if len(path) > self.max_path_length:
                logger.error(
                    "error inserting Bugzilla product and component \"'%s' :: '%s'\" into db (file skipped: '%s'): path is too long (has %d characters, max is %d)",
                    product,
                    component,
                    path,
                    len(path),
                    self.max_path_length,
                )
            bugzilla_component_data, _ = BugzillaComponent.objects.get_or_create(
                product=product,
                component=component,
            )
            self.bugzilla_components[product_component_str] = bugzilla_component_data
        except Exception as e:
            logger.error(
                "error inserting Bugzilla product and component \"'%s' :: '%s'\" into db (file skipped: '%s'): %s",
                product,
                component,
                path,
                e,
            )
            return
        return bugzilla_component_data