From e13a4eb45e4db2beb1c5b65ec6eb3a8e82e92882 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Mon, 15 Jun 2020 17:00:00 -0400 Subject: [PATCH] ubuntutools/archive: deprecate passing 'lp' object to SourcePackage() There is no point to doing this, as the Launchpad object is a singleton; the caller should just call Launchpad.login_with() directly and leave the SourcePackage class out of it. Signed-off-by: Dan Streetman --- ubuntutools/archive.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index c7d3d3f..a134e3b 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -127,7 +127,6 @@ class SourcePackage(object): latest version from the development series. """ dscfile = kwargs.get('dscfile') - lp = kwargs.get('lp') mirrors = kwargs.get('mirrors', ()) workdir = kwargs.get('workdir', '.') series = kwargs.get('series') @@ -138,8 +137,14 @@ class SourcePackage(object): assert (package is not None or dscfile is not None) + if 'lp' in kwargs: + # deprecated - please don't use this; if you want to use an + # existing lp object, just call login_existing() directly + Logger.warning("Deprecation warning: please don't pass 'lp' to SourcePackage") + if not Launchpad.logged_in: + Launchpad.login_existing(kwargs['lp']) + self.source = package - self._lp = lp self.binary = None self.try_binary = try_binary self.workdir = workdir @@ -185,12 +190,6 @@ class SourcePackage(object): if self._spph: return self._spph - if not Launchpad.logged_in: - if self._lp: - Launchpad.login_existing(self._lp) - else: - Launchpad.login_anonymously() - archive = self.getArchive() params = {} if self._version: