[Yum-devel] [PATCH 3/3] Minor speedup/cleanup for isPkgInstalled().

Tim Lauridsen tim.lauridsen at googlemail.com
Sun Oct 18 06:23:17 UTC 2009


On 10/18/2009 06:11 AM, James Antill wrote:
> ---
>   yum/depsolve.py |   17 +++++++++--------
>   1 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/yum/depsolve.py b/yum/depsolve.py
> index 5e855d5..d9b5e6f 100644
> --- a/yum/depsolve.py
> +++ b/yum/depsolve.py
> @@ -985,19 +985,20 @@ class Depsolve(object):
>
>
>       def isPackageInstalled(self, pkgname):
> -        installed = False
> -        if self.rpmdb.contains(name=pkgname):
> -            installed = True
> -
>           lst = self.tsInfo.matchNaevr(name = pkgname)
>           for txmbr in lst:
>               if txmbr.output_state in TS_INSTALL_STATES:
>                   return True
> -        if installed and len(lst)>  0:
> -            # if we get here, then it was installed, but it's in the tsInfo
> -            # for an erase or obsoleted -->  not going to be installed at end
> +
> +        if len(lst)>  0:
> +            # if we get here then it's in the tsInfo for an erase or obsoleted
> +            #  -->  not going to be installed
>               return False
> -        return installed
> +
> +        if not self.rpmdb.contains(name=pkgname):
> +            return False
> +
> +        return True
>       _isPackageInstalled = isPackageInstalled
>
>       def _compare_providers(self, pkgs, reqpo):
>    

ACK

Tim


More information about the Yum-devel mailing list