← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] ~ines-almeida/launchpad:svt-refactor-exports into launchpad:master

 


Diff comments:

> diff --git a/lib/lp/bugs/model/exportvulnerabilityjob.py b/lib/lp/bugs/model/exportvulnerabilityjob.py
> index 254b6e6..6da2147 100644
> --- a/lib/lp/bugs/model/exportvulnerabilityjob.py
> +++ b/lib/lp/bugs/model/exportvulnerabilityjob.py
> @@ -157,36 +148,35 @@ class ExportVulnerabilityJob(VulnerabilityJobDerived):
>          parts += ", metadata: %s" % self.metadata
>          return "<%s>" % parts
>  
> -    def _get_exporter_to_record(
> +    def _get_exporter(
>          self,
>          handler: VulnerabilityHandlerEnum,
> -        information_type: InformationType = InformationType.PRIVATESECURITY,
> -    ):
> -        """Decide which parser and importer to use
> +    ) -> SVTExporter:
> +        """Decide which exporter to use
>  
>          :return: a tuple of (parser, importer) where parser is the function
>          that gets a blob and returns a record and importer is the function that
>          gets a record and imports it.
>          """
>  
> -        exporter = HANDLER_EXPORTER_MAP.get(handler)
> -
> -        if not exporter:
> -            exception = VulnerabilityJobException("Handler not found")
> +        if handler == VulnerabilityHandlerEnum.SOSS:

Ideally we just move this to somewhere where this logic can be re-used, but for now as it is I thought it was simpler to have it similar to the Importer for coherence.

Also, I didn't like that we were returning a function rather than the exporter, so updated that as well

> +            return SOSSExporter()
> +        elif handler == VulnerabilityHandlerEnum.UCT:
> +            return UCTExporter()
> +        else:
> +            exception = VulnerabilityJobException(
> +                f"Handler '{handler}' not found"
> +            )
>              self.notifyUserError(exception)
>              raise exception
>  
> -        exporter_to_record = exporter(
> -            information_type=information_type
> -        ).to_record
> -
> -        return exporter_to_record
> -
>      def _get_distribution(self, handler) -> Distribution:
>          distribution_name = HANDLER_DISTRIBUTION_MAP.get(handler)
>  
>          if not distribution_name:
> -            exception = VulnerabilityJobException("Handler not found")
> +            exception = VulnerabilityJobException(
> +                f"Handler '{handler}' not found"
> +            )
>              self.notifyUserError(exception)
>              raise exception
>  


-- 
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/493462
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:svt-refactor-exports into launchpad:master.



References