[elbe-devel] [PATCH v2 2/3] dump, elbexml, xmlpreprocess: fix style errors
Akash Satamkar
akash at linutronix.de
Tue Sep 24 12:20:58 CEST 2019
elbexml:change validate_repo method in class ElbeXML
to @staticmethod.
pylint and pycodestyle complains:
__________________________________________________
elbepack/xmlpreprocess.py:44: [W0612(unused-variable),
preprocess_pgp_key] Unused variable 'E'
elbepack/xmlpreprocess.py:35:1: E302 expected 2 blank lines, found 1
elbepack/xmlpreprocess.py:38:80: E501 line too long (96 > 79 characters)
elbepack/xmlpreprocess.py:45:80: E501 line too long (85 > 79 characters)
elbepack/xmlpreprocess.py:47:1: E302 expected 2 blank lines, found 1
elbepack/xmlpreprocess.py:52:80: E501 line too long (80 > 79 characters)
elbepack/xmlpreprocess.py:63:80: E501 line too long (85 > 79 characters)
elbepack/xmlpreprocess.py:65:80: E501 line too long (83 > 79 characters)
elbepack/elbexml.py:140: [W0511(fixme), ] XXX: maybe add cdrom path param ?
elbepack/elbexml.py:44: [R0903(too-few-public-methods), ValidationMode]
Too few public methods (0/2)
elbepack/elbexml.py:176: [R0201(no-self-use), ElbeXML.validate_repo]
Method could be a function
elbepack/elbexml.py:203: [R0915(too-many-statements),
ElbeXML.validate_apt_sources] Too many statements (55/50)
elbepack/elbexml.py:49:1: E302 expected 2 blank lines, found 1
elbepack/dump.py:23:1: E302 expected 2 blank lines, found 1
elbepack/dump.py:83:5: E303 too many blank lines (2)
elbepack/dump.py:105:80: E501 line too long (97 > 79 characters)
elbepack/dump.py:140:80: E501 line too long (91 > 79 characters)
elbepack/dump.py:146:80: E501 line too long (83 > 79 characters)
elbepack/dump.py:152:80: E501 line too long (87 > 79 characters)
elbepack/dump.py:214:5: E303 too many blank lines (3)
elbepack/dump.py:242:5: E303 too many blank lines (2)
elbepack/dump.py:282:5: E303 too many blank lines (2)
_______________________________________________
fixed it.
Signed-off-by: Akash Satamkar <akash at linutronix.de>
---
elbepack/dump.py | 18 +++++++++---------
elbepack/elbexml.py | 7 ++++---
elbepack/xmlpreprocess.py | 16 +++++++++++-----
3 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/elbepack/dump.py b/elbepack/dump.py
index 4642ae92..7594c9df 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -20,6 +20,7 @@ from elbepack.shellhelper import do
report = logging.getLogger("report")
validation = logging.getLogger("validation")
+
def get_initvm_pkglist():
cache = Cache()
cache.open()
@@ -79,7 +80,6 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
# pylint: disable=too-many-statements
# pylint: disable=too-many-branches
-
validation.info("ELBE Package validation")
validation.info("Package List validation")
@@ -102,7 +102,8 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
ver = p.et.get('version')
pkg = cache.get_pkg(nomulti_name)
if ver and (pkg.installed_version != ver):
- validation.error("Package '%s' version '%s' does not match installed version %s",
+ validation.error("Package '%s' version '%s' does "
+ "not match installed version %s",
name, ver, pkg.installed_version)
errors += 1
continue
@@ -137,19 +138,22 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
pkg = cache.get_pkg(name)
if pkg.installed_version != ver:
- validation.error("Package '%s' version %s does not match installed version %s",
+ validation.error("Package '%s' version %s does "
+ "not match installed version %s",
name, ver, pkg.installed_version)
errors += 1
continue
if pkg.installed_md5 != md5:
- validation.error("Package '%s' md5 %s does not match installed md5 %s",
+ validation.error("Package '%s' md5 %s does "
+ "not match installed md5 %s",
name, md5, pkg.installed_md5)
errors += 1
for cp in cache.get_installed_pkgs():
if cp.name not in pindex:
- validation.error("Additional package %s installed, that was not requested",
+ validation.error("Additional package %s installed, "
+ "that was not requested",
cp.name)
errors += 1
@@ -209,8 +213,6 @@ def elbe_report(xml, buildenv, cache, targetfs):
else:
mt_index_post_fine = mt_index_postarch
-
-
report.info("Fileslist")
tgt_pkg_list = set()
@@ -238,7 +240,6 @@ def elbe_report(xml, buildenv, cache, targetfs):
report.info("|+%s+|%s", fpath, pkg)
-
report.info("Deleted Files")
for fpath in list(mt_index.keys()):
if fpath not in mt_index_post_fine:
@@ -278,7 +279,6 @@ def elbe_report(xml, buildenv, cache, targetfs):
if not xml.has("archive") or xml.text("archive") is None:
return
-
validation.info("Archive validation")
errors = 0
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 5972600c..89464952 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -49,6 +49,7 @@ class ValidationMode(object):
CHECK_BINARIES = 2
CHECK_ALL = 0
+
def replace_localmachine(mirror, initvm=True):
if initvm:
localmachine = "10.0.2.2"
@@ -140,7 +141,6 @@ class ElbeXML(object):
return replace_localmachine(mirror, initvm)
- # XXX: maybe add cdrom path param ?
def create_apt_sources_list(self, build_sources=False, initvm=True):
if self.prj is None:
return "# No Project"
@@ -176,7 +176,8 @@ class ElbeXML(object):
return replace_localmachine(mirror, initvm)
- def validate_repo(self, r):
+ @staticmethod
+ def validate_repo(r):
try:
fp = urllib2.urlopen(r["url"] + "InRelease", None, 10)
except urllib2.URLError:
@@ -286,7 +287,7 @@ class ElbeXML(object):
r["url"] = scheme + t[1]
usr, passwd = auth.split(':')
passman.add_password(None, r["url"], usr, passwd)
- if not self.validate_repo(r):
+ if not ElbeXML.validate_repo(r):
raise ValidationError(
["Repository %s can not be validated" % r["url"]])
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index 0e986a75..4f7f8fe9 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -32,17 +32,21 @@ mergepaths = ['//target/finetuning',
class XMLPreprocessError(Exception):
pass
+
def preprocess_pgp_key(xml):
for key in xml.iterfind('.//mirror/url-list/url/key'):
- print("[WARN] <key>%s</key> is deprecated. You should use raw-key instead." % key.text)
+ print("[WARN] <key>%s</key> is deprecated. "
+ "You should use raw-key instead." % key.text)
try:
keyurl = key.text.strip().replace('LOCALMACHINE', 'localhost')
myKey = urllib2.urlopen(keyurl).read()
key.tag = "raw-key"
key.text = "\n%s\n" % myKey
- except urllib2.HTTPError as E:
- raise XMLPreprocessError("Invalid PGP Key URL in <key> tag: %s" % keyurl)
+ except urllib2.HTTPError:
+ raise XMLPreprocessError("Invalid PGP Key URL "
+ "in <key> tag: %s" % keyurl)
+
def preprocess_iso_option(xml):
@@ -60,9 +64,11 @@ def preprocess_iso_option(xml):
if valid is False:
violation = "Invalid ISO option %s" % tag
elif isinstance(valid, int):
- violation = "Option %s will be truncated by %d characters" % (tag, valid)
+ violation = "Option %s will be truncated " \
+ "by %d characters" % (tag, valid)
elif isinstance(valid, str):
- violation = ("Character '%c' (%d) in ISO option %s violated ISO-9660" %
+ violation = ("Character '%c' (%d) in ISO "
+ "option %s violated ISO-9660" %
(valid, ord(valid[0]), tag))
if strict:
raise XMLPreprocessError(violation)
--
2.20.1
More information about the elbe-devel
mailing list