[PATCH] yumdownloader - code cleanup
Julien Pivotto
roidelapluie at inuits.eu
Thu Jul 23 07:20:19 UTC 2015
* Remove unused imports
* Remove trailing whitespaces
---
yumdownloader.py | 37 ++++++++++++++++---------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/yumdownloader.py b/yumdownloader.py
index 1b95e8d..e09a4fd 100755
--- a/yumdownloader.py
+++ b/yumdownloader.py
@@ -14,20 +14,15 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import sys
-import os
-import os.path
sys.path.insert(0,'/usr/share/yum-cli')
import yum
from yum.misc import setup_locale
from yum.packages import parsePackages
-from yum.Errors import RepoError
from yum.i18n import exception2msg
from utils import YumUtilBase
from urlparse import urljoin
-from urlgrabber.progress import TextMeter
-import shutil
import rpmUtils
import logging
@@ -59,18 +54,18 @@ class YumDownloader(YumUtilBase):
NAME = 'yumdownloader'
VERSION = '1.0'
USAGE = '"yumdownloader [options] package1 [package2] [package..]'
-
+
def __init__(self):
YumUtilBase.__init__(self,
YumDownloader.NAME,
YumDownloader.VERSION,
YumDownloader.USAGE)
- self.logger = logging.getLogger("yum.verbose.cli.yumdownloader")
-
+ self.logger = logging.getLogger("yum.verbose.cli.yumdownloader")
+
self.localPackages = []
-
+
# Add util commandline options to the yum-cli ones
- self.optparser = self.getOptionParser()
+ self.optparser = self.getOptionParser()
try:
self.main()
except (OSError, IOError), e:
@@ -86,9 +81,9 @@ class YumDownloader(YumUtilBase):
except yum.Errors.RepoError, e:
self.logger.error(exception2msg(e))
sys.exit(50)
-
+
# Check if there is anything to do.
- if len(self.cmds) < 1:
+ if len(self.cmds) < 1:
print self.optparser.format_help()
sys.exit(0)
@@ -99,7 +94,7 @@ class YumDownloader(YumUtilBase):
# override all pkgdirs
self.conf.downloaddir = opts.destdir
-
+
if opts.source:
# Setup source repos
self.arch.archlist.append('src')
@@ -109,7 +104,7 @@ class YumDownloader(YumUtilBase):
self.doUtilYumSetup()
# Do the real action
self.exit_code = self.downloadPackages(opts)
-
+
def setupSourceRepos(self):
# enable the -source repos for enabled primary repos
@@ -128,11 +123,11 @@ class YumDownloader(YumUtilBase):
if not repo.isEnabled() and enabled.get(primary):
self.logger.info('Enabling %s repository' % repo.id)
repo.enable()
-
+
def downloadPackages(self,opts):
-
+
toDownload = []
-
+
packages = self.cmds
for pkg in packages:
toActOn = []
@@ -185,7 +180,7 @@ class YumDownloader(YumUtilBase):
toDownload.extend(self.bestPackagesFromList(pkgs, arch))
else:
toDownload.extend(self.bestPackagesFromList(pkgs))
-
+
# If the user supplies to --resolve flag, resolve dependencies for
# all packages
# note this might require root access because the headers need to be
@@ -228,7 +223,7 @@ class YumDownloader(YumUtilBase):
for error in probs[key]:
self.logger.error('%s: %s', key, error)
return exit_code
-
+
def _groupPackages(self,pkglist):
pkgGroups = {}
for po in pkglist:
@@ -238,13 +233,13 @@ class YumDownloader(YumUtilBase):
else:
pkgGroups[na].append(po)
return pkgGroups
-
+
def addCmdOptions(self):
# this if for compatibility with old API (utils.py from yum < 3.2.23)
if hasattr(self,'getOptionGroup'): # check if the group option API is available
group = self.getOptionGroup()
else:
- group = self.optparser
+ group = self.optparser
group.add_option("--destdir", default=".", dest="destdir",
help='destination directory (defaults to current directory)')
group.add_option("--urls", default=False, dest="urls", action="store_true",
--
2.4.5
More information about the Yum-devel
mailing list