pylint patches for createrepo
Tim Lauridsen <[email protected]>
| Newsgroups | gmane.linux.rpm.metadata |
|---|---|
| Message-ID | <[email protected]> |
Here is some patches to add pylint checks to createrepo and fixes the most common warnings. use: make pylint or make pylint-short to check do the check (pylint-short shows only errors and warnings and no report in the end) > $ make pylint-short > ************* Module dmd > F0401: 22: Unable to import 'lxml.etree.parse' (No module named lxml) > F0401: 22: Unable to import 'lxml.etree.tostring' (No module named lxml) > F0401: 22: Unable to import 'lxml.etree.Element' (No module named lxml) > ************* Module modifyrepo > E1103: 98:RepoMetadata.add: Instance of 'Document' has no 'firstChild' member (but some types could not be inferred) > E1103:101:RepoMetadata.add: Instance of 'Document' has no 'firstChild' member (but some types could not be inferred) > ************* Module createrepo > E0203:633:MetaDataGenerator._get_old_package_dict: Access to member '_old_package_dict' before its definition line 635 > ************* Module createrepo.deltarpms > E0602: 69:DeltaRPMPackage._getOldInfo: Undefined variable 'zlibError' Here is the current output of errors, there needs to be dealt with. Tim _______________________________________________ Rpm-metadata mailing list [email protected] http://lists.baseurl.org/mailman/listinfo/rpm-metadata
0001-Added-the-pylint-basic-and-disabled-the-warning-we-d.patch
(text/plain, 733 B)
>From cee96285ec091d4880b0627b1b1f9c6f6cd68b12 Mon Sep 17 00:00:00 2001 From: Tim Lauridsen <[email protected]> Date: Tue, 21 Apr 2009 09:06:10 +0200 Subject: [PATCH] Added the pylint basic and disabled the warning we dont care about --- Makefile | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index facbc5b..c821ae4 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,12 @@ distclean: clean $(MAKE) -C $$subdir distclean VERSION=$(VERSION) PKGNAME=$(PKGNAME); \ done +pylint: + @pylint --rcfile=test/createrepo-pylintrc *.py createrepo + +pylint-short: + @pylint -r n --rcfile=test/createrepo-pylintrc *.py createrepo + mostlyclean: $(MAKE) clean -- 1.6.0.6
0002-pylint-fixed-Bad-indentation.patch
(text/plain, 910 B)
>From 783f75cab3943ff24ac29cd878d868696f95c602 Mon Sep 17 00:00:00 2001 From: Tim Lauridsen <[email protected]> Date: Tue, 21 Apr 2009 09:09:05 +0200 Subject: [PATCH] pylint: fixed Bad indentation --- createrepo/readMetadata.py | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/createrepo/readMetadata.py b/createrepo/readMetadata.py index 7ed79e2..285e54d 100644 --- a/createrepo/readMetadata.py +++ b/createrepo/readMetadata.py @@ -210,10 +210,10 @@ if __name__ == "__main__": idx = MetadataIndex(cwd, opts) for fn in idx.basenodes.keys(): - a,b,c, = idx.getNodes(fn) - a.serialize() - b.serialize() - c.serialize() - idx.freeNodes(fn) + a,b,c, = idx.getNodes(fn) + a.serialize() + b.serialize() + c.serialize() + idx.freeNodes(fn) -- 1.6.0.6
0003-pylint-fixed-unused-imports.patch
(text/plain, 1.2 KB)
>From 909c60ff7eb2ad46483be330c0565932559f8d79 Mon Sep 17 00:00:00 2001 From: Tim Lauridsen <[email protected]> Date: Tue, 21 Apr 2009 09:13:06 +0200 Subject: [PATCH] pylint: fixed unused imports --- createrepo/deltarpms.py | 3 +-- createrepo/yumbased.py | 4 ---- 2 files changed, 1 insertions(+), 6 deletions(-) diff --git a/createrepo/deltarpms.py b/createrepo/deltarpms.py index f201ab7..26a6715 100644 --- a/createrepo/deltarpms.py +++ b/createrepo/deltarpms.py @@ -19,8 +19,7 @@ import os.path import commands from yum import misc import gzip -import yumbased -from utils import _, errorprint, MDError +from utils import MDError class DeltaRPMPackage: """each drpm is one object, you pass it a drpm file diff --git a/createrepo/yumbased.py b/createrepo/yumbased.py index e8b5667..f04f4fb 100644 --- a/createrepo/yumbased.py +++ b/createrepo/yumbased.py @@ -18,14 +18,10 @@ import os import rpm import types -import re from yum.packages import YumLocalPackage from yum.Errors import * from yum import misc -from yum.sqlutils import executeSQL -from rpmUtils.transaction import initReadOnlyTransaction -from rpmUtils.miscutils import flagToString, stringToVersion import utils import tempfile -- 1.6.0.6
0004-pylint-fixed-Redefining-built-in.patch
(text/plain, 4 KB)
>From 6033baed12651147c6c7d35b2e1e4b27d0a41248 Mon Sep 17 00:00:00 2001 From: Tim Lauridsen <[email protected]> Date: Tue, 21 Apr 2009 09:21:20 +0200 Subject: [PATCH] pylint: fixed Redefining built-in --- createrepo/__init__.py | 26 +++++++++++++------------- createrepo/utils.py | 18 +++++++++--------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/createrepo/__init__.py b/createrepo/__init__.py index 7566628..25d3b0c 100644 --- a/createrepo/__init__.py +++ b/createrepo/__init__.py @@ -297,14 +297,14 @@ class MetaDataGenerator: def trimRpms(self, files): badrpms = [] - for file in files: + for rpm_file in files: for glob in self.conf.excludes: - if fnmatch.fnmatch(file, glob): - if file not in badrpms: - badrpms.append(file) - for file in badrpms: - if file in files: - files.remove(file) + if fnmatch.fnmatch(rpm_file, glob): + if rpm_file not in badrpms: + badrpms.append(rpm_file) + for rpm_file in badrpms: + if rpm_file in files: + files.remove(rpm_file) return files def _setup_old_metadata_lookup(self): @@ -785,8 +785,8 @@ class MetaDataGenerator: dbversion = '9' rp = sqlitecachec.RepodataParserSqlite(repopath, repoid, None) - for (file, ftype) in workfiles: - complete_path = os.path.join(repopath, file) + for (rpm_file, ftype) in workfiles: + complete_path = os.path.join(repopath, rpm_file) zfo = _gzipOpen(complete_path) uncsum = misc.checksum(sumtype, zfo) @@ -873,16 +873,16 @@ class MetaDataGenerator: location.newProp('xml:base', self.conf.baseurl) if self.conf.unique_md_filenames: res_file = '%s-%s.xml.gz' % (csum, ftype) - orig_file = os.path.join(repopath, file) + orig_file = os.path.join(repopath, rpm_file) dest_file = os.path.join(repopath, res_file) os.rename(orig_file, dest_file) else: - res_file = file + res_file = rpm_file - file = res_file + rpm_file = res_file - location.newProp('href', os.path.join(self.conf.finaldir, file)) + location.newProp('href', os.path.join(self.conf.finaldir, rpm_file)) if not self.conf.quiet and self.conf.database: self.callback.log('Sqlite DBs complete') diff --git a/createrepo/utils.py b/createrepo/utils.py index 894594c..fb23964 100644 --- a/createrepo/utils.py +++ b/createrepo/utils.py @@ -76,25 +76,25 @@ def returnFD(filename): raise MDError, "Error opening file" return fdno -def checkAndMakeDir(dir): +def checkAndMakeDir(directory): """ - check out the dir and make it, if possible, return 1 if done, else return 0 + check out the directory and make it, if possible, return 1 if done, else return 0 """ - if os.path.exists(dir): - if not os.path.isdir(dir): - #errorprint(_('%s is not a dir') % dir) + if os.path.exists(directory): + if not os.path.isdir(directory): + #errorprint(_('%s is not a dir') % directory) result = False else: - if not os.access(dir, os.W_OK): - #errorprint(_('%s is not writable') % dir) + if not os.access(directory, os.W_OK): + #errorprint(_('%s is not writable') % directory) result = False else: result = True else: try: - os.mkdir(dir) + os.mkdir(directory) except OSError, e: - #errorprint(_('Error creating dir %s: %s') % (dir, e)) + #errorprint(_('Error creating dir %s: %s') % (directory, e)) result = False else: result = True -- 1.6.0.6
0005-pylint-fixed-Uses-of-a-deprecated-module-string.patch
(text/plain, 1 KB)
>From 1929e17adaf4da84e4582b3b0fad44e320145af2 Mon Sep 17 00:00:00 2001 From: Tim Lauridsen <[email protected]> Date: Tue, 21 Apr 2009 09:24:33 +0200 Subject: [PATCH] pylint: fixed Uses of a deprecated module 'string' --- createrepo/__init__.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/createrepo/__init__.py b/createrepo/__init__.py index 25d3b0c..29a4b8d 100644 --- a/createrepo/__init__.py +++ b/createrepo/__init__.py @@ -16,7 +16,6 @@ import os import sys import libxml2 -import string import fnmatch import time import yumbased @@ -1030,7 +1029,7 @@ class SplitMetaDataGenerator(MetaDataGenerator): for fn in names: if os.path.isdir(fn): continue - elif string.lower(fn[-extlen:]) == '%s' % (ext): + elif fn[-extlen:].lower() == '%s' % (ext): reldir = os.path.basename(dirname) if reldir == os.path.basename(directory): reldir = "" -- 1.6.0.6