[elbe-devel] [PATCH 3/3] validate, filesystem, shellhelper: fix style errors
Akash Satamkar
akash at linutronix.de
Wed Sep 18 15:28:30 CEST 2019
pylint and pycodestyle complains:
____________________________________________
elbepack/validate.py:37:1: E302 expected 2 blank lines, found 1
elbepack/filesystem.py:14: [W0402(deprecated-module), ]
Uses of a deprecated module 'string'
elbepack/filesystem.py:224: [W0621(redefined-outer-name),
Filesystem.read_file] Redefining name 'gzip' from outer scope (line 15)
elbepack/filesystem.py:19:1: E302 expected 2 blank lines, found 1
elbepack/filesystem.py:53:1: E302 expected 2 blank lines, found 1
elbepack/shellhelper.py:128: [W0102(dangerous-default-value),
get_command_out] Dangerous default value {} as argument
elbepack/shellhelper.py:102:39: E231 missing whitespace after ':'
elbepack/shellhelper.py:109:80: E501 line too long (84 > 79 characters)
elbepack/shellhelper.py:119:1: E303 too many blank lines (3)
elbepack/shellhelper.py:120:22: E231 missing whitespace after ':'
elbepack/shellhelper.py:121:26: E231 missing whitespace after ':'
elbepack/shellhelper.py:122:24: E231 missing whitespace after ':'
elbepack/shellhelper.py:128:1: E302 expected 2 blank lines, found 1
elbepack/shellhelper.py:132:39: E231 missing whitespace after ':'
elbepack/shellhelper.py:139:80: E501 line too long (84 > 79 characters)
____________________________________________________________
fixed it
Signed-off-by: Akash Satamkar <akash at linutronix.de>
---
elbepack/filesystem.py | 9 +++++----
elbepack/shellhelper.py | 22 +++++++++++++---------
elbepack/validate.py | 1 +
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/elbepack/filesystem.py b/elbepack/filesystem.py
index 3dac75ff..fd32ba9e 100644
--- a/elbepack/filesystem.py
+++ b/elbepack/filesystem.py
@@ -11,13 +11,13 @@ import shutil
from glob import glob
from tempfile import mkdtemp
-from string import digits
import gzip
from elbepack.shellhelper import do
+
def size_to_int(size):
- if size[-1] in digits:
+ if size[-1].isdigits():
return int(size)
if size.endswith("M"):
@@ -50,6 +50,7 @@ def size_to_int(size):
return int(s) * unit
+
class Filesystem(object):
# pylint: disable=too-many-public-methods
@@ -221,8 +222,8 @@ class Filesystem(object):
if mode is not None:
self.chmod(path, mode)
- def read_file(self, path, gzip=False):
- if gzip:
+ def read_file(self, path, fname_gzip=False):
+ if fname_gzip:
print('read gzip '+path)
fp = self.open_gz(path, "r")
else:
diff --git a/elbepack/shellhelper.py b/elbepack/shellhelper.py
index 0895c0b0..ff4ec021 100644
--- a/elbepack/shellhelper.py
+++ b/elbepack/shellhelper.py
@@ -99,14 +99,15 @@ def do(cmd, allow_fail=False, stdin=None, env_add=None):
if env_add:
new_env.update(env_add)
- logging.info(cmd, extra={"context":"[CMD] "})
+ logging.info(cmd, extra={"context": "[CMD] "})
r, w = os.pipe()
if stdin is None:
p = Popen(cmd, shell=True, stdout=w, stderr=STDOUT, env=new_env)
else:
- p = Popen(cmd, shell=True, stdin=PIPE, stdout=w, stderr=STDOUT, env=new_env)
+ p = Popen(cmd, shell=True, stdin=PIPE,
+ stdout=w, stderr=STDOUT, env=new_env)
async_logging(r, w, soap, log)
p.communicate(input=stdin)
@@ -115,28 +116,31 @@ def do(cmd, allow_fail=False, stdin=None, env_add=None):
raise CommandError(cmd, p.returncode)
-
def chroot(directory, cmd, env_add=None, **kwargs):
- new_env = {"LANG":"C",
- "LANGUAGE":"C",
- "LC_ALL":"C"}
+ new_env = {"LANG": "C",
+ "LANGUAGE": "C",
+ "LC_ALL": "C"}
if env_add:
new_env.update(env_add)
chcmd = 'chroot %s %s' % (directory, cmd)
do(chcmd, env_add=new_env, **kwargs)
-def get_command_out(cmd, stdin=None, allow_fail=False, env_add={}):
+
+def get_command_out(cmd, stdin=None, allow_fail=False, env_add=None):
new_env = os.environ.copy()
+ if env_add is None:
+ env_add = {}
new_env.update(env_add)
- logging.info(cmd, extra={"context":"[CMD] "})
+ logging.info(cmd, extra={"context": "[CMD] "})
r, w = os.pipe()
if stdin is None:
p = Popen(cmd, shell=True, stdout=PIPE, stderr=w, env=new_env)
else:
- p = Popen(cmd, shell=True, stdin=PIPE, stdout=w, stderr=STDOUT, env=new_env)
+ p = Popen(cmd, shell=True, stdin=PIPE,
+ stdout=w, stderr=STDOUT, env=new_env)
async_logging(r, w, soap, log)
stdout, stderr = p.communicate(input=stdin)
diff --git a/elbepack/validate.py b/elbepack/validate.py
index c1e5c771..f4413168 100644
--- a/elbepack/validate.py
+++ b/elbepack/validate.py
@@ -34,6 +34,7 @@ def error_log_to_strings(error_log):
"behaviour, please specify <install-recommends /> !\n")
return errors
+
def validate_xml(fname):
if os.path.getsize(fname) > (1 << 30):
return ["%s is greater than 1 GiB. "
--
2.20.1
More information about the elbe-devel
mailing list