[elbe-devel] [PATCH 1/3] soapclient, templates, virtapt, xmldefaults: fix style errors

Akash Satamkar akash at linutronix.de
Thu Sep 26 15:22:04 CEST 2019


pylint and pycodestyle complains:
__________________________________________________
elbepack/soapclient.py:101:80: E501 line too long (80 > 79 characters)
elbepack/soapclient.py:202:1: E302 expected 2 blank lines, found 1
elbepack/soapclient.py:211:80: E501 line too long (84 > 79 characters)
elbepack/soapclient.py:226:80: E501 line too long (82 > 79 characters)
elbepack/soapclient.py:232:1: E305 expected 2 blank lines
after class or function definition, found 1
elbepack/soapclient.py:234:1: E302 expected 2 blank lines, found 1
elbepack/soapclient.py:422:80: E501 line too long (95 > 79 characters)
elbepack/soapclient.py:428:80: E501 line too long (95 > 79 characters)
elbepack/soapclient.py:610:1: E305 expected 2 blank lines
after class or function definition, found 1
elbepack/soapclient.py:776:1: E302 expected 2 blank lines, found 1
elbepack/soapclient.py:808:1: E302 expected 2 blank lines, found 1
elbepack/soapclient.py:828:1: E302 expected 2 blank lines, found 1
elbepack/soapclient.py:914:80: E501 line too long (86 > 79 characters)
elbepack/soapclient.py:930:80: E501 line too long (80 > 79 characters)

elbepack/templates.py:14: [C0411(wrong-import-order), ] third
party import "from mako.template import Template" should
be placed before "from elbepack.treeutils import etree"
elbepack/templates.py:15: [C0411(wrong-import-order), ] third
party import "from mako import exceptions" should
be placed before "from elbepack.treeutils import etree"

elbepack/virtapt.py:25: [W0404(reimported), ]
Reimport 'system' (imported line 16)
elbepack/virtapt.py:14: [W0611(unused-import), ]
Unused BaseManager imported from multiprocessing.managers
elbepack/virtapt.py:25: [W0611(unused-import), ]
Unused CommandError imported from elbepack.shellhelper
elbepack/virtapt.py:27: [W0611(unused-import), ]
Unused ElbeDefaults imported from elbepack.xmldefaults
elbepack/virtapt.py:21: [C0411(wrong-import-order), ] third party
import "import apt" should be placed before
"from elbepack.shellhelper import system"
elbepack/virtapt.py:25: [C0412(ungrouped-imports), ]
Imports from package elbepack are not grouped
elbepack/virtapt.py:172:80: E501 line too long (105 > 79 characters)

elbepack/xmldefaults.py:12: [W0611(unused-import), ] Unused import sys
elbepack/xmldefaults.py:190:1: E302 expected 2 blank lines, found 1
elbepack/xmldefaults.py:205:80: E501 line too long (85 > 79 characters)
_______________________________________________________
fixed it

Signed-off-by: Akash Satamkar <akash at linutronix.de>
---
 elbepack/soapclient.py  | 34 +++++++++++++++++++++++-----------
 elbepack/templates.py   |  6 +++---
 elbepack/virtapt.py     | 16 +++++++++-------
 elbepack/xmldefaults.py |  5 +++--
 4 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index edcffe76..ca9f635a 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -98,7 +98,8 @@ class ElbeSoapClient(object):
             except BadStatusLine as e:
                 retry = retry - 1
 
-                print("get_file part %d failed, retry %d times" % (part, retry),
+                print("get_file part %d failed, retry "
+                      "%d times" % (part, retry),
                       file=sys.stderr)
                 print(e.message, file=sys.stderr)
                 print(repr(e.line), file=sys.stderr)
@@ -199,6 +200,7 @@ class ListUsersAction(ClientAction):
 
 ClientAction.register(ListUsersAction)
 
+
 class AddUserAction(ClientAction):
     tag = 'add_user'
 
@@ -207,9 +209,9 @@ class AddUserAction(ClientAction):
 
     def execute(self, client, _opt, args):
         if len(args) != 4:
-            print(
-                "usage: elbe control add_user <name> <fullname> <password> <email>",
-                file=sys.stderr)
+            print("usage: elbe control add_user <name>"
+                  "<fullname> <password> <email>",
+                  file=sys.stderr)
             sys.exit(20)
 
         name     = args[0]
@@ -223,14 +225,17 @@ class AddUserAction(ClientAction):
             if not hasattr(e.fault, 'faultstring'):
                 raise
 
-            if not e.fault.faultstring.endswith('already exists in the database'):
+            if not e.fault.faultstring.endswith('already exists '
+                                                'in the database'):
                 raise
 
             # when we get here, the user we wanted to create already exists.
             # that is fine, and we dont need to do anything now.
 
+
 ClientAction.register(AddUserAction)
 
+
 class CreateProjectAction(ClientAction):
 
     tag = 'create_project'
@@ -418,14 +423,15 @@ class BuildCDROMsAction(ClientAction):
 
     def execute(self, client, opt, args):
         if len(args) != 1:
-            print(
-                "usage: elbe control build-cdroms [--build-bin|--build-sources] <project_dir>",
-                file=sys.stderr)
+            print("usage: elbe control build-cdroms "
+                  "[--build-bin|--build-sources] <project_dir>",
+                  file=sys.stderr)
             sys.exit(20)
 
         if (not opt.build_bin) and (not opt.build_sources):
             print(
-                "usage: elbe control build-cdroms [--build-bin|--build-sources] <project_dir>",
+                "usage: elbe control build-cdroms "
+                "[--build-bin|--build-sources] <project_dir>",
                 file=sys.stderr)
             sys.exit(20)
 
@@ -607,6 +613,7 @@ class WaitProjectBusyAction(ClientAction):
 
             print(msg)
 
+
 ClientAction.register(WaitProjectBusyAction)
 
 
@@ -773,6 +780,7 @@ class UpdatePbuilderAction(ClientAction):
 
 ClientAction.register(UpdatePbuilderAction)
 
+
 class InstallElbeVersion(ClientAction):
 
     tag = 'install_elbe_version'
@@ -805,6 +813,7 @@ class InstallElbeVersion(ClientAction):
 
 ClientAction.register(InstallElbeVersion)
 
+
 class RepoAction(ClientAction):
     repoactiondict = {}
 
@@ -825,6 +834,7 @@ class RepoAction(ClientAction):
     def execute(self, _client, _opt, _args):
         raise NotImplementedError('execute() not implemented')
 
+
 class ListPackagesAction(RepoAction):
 
     tag = 'list_packages'
@@ -911,7 +921,8 @@ class UploadPackageAction(RepoAction):
     def execute(self, client, _opt, args):
         if len(args) != 2:
             print(
-                "usage: elbe prjrepo upload_pkg <project_dir> <deb/dsc/changes file>",
+                "usage: elbe prjrepo upload_pkg "
+                "<project_dir> <deb/dsc/changes file>",
                 file=sys.stderr)
             sys.exit(20)
 
@@ -927,7 +938,8 @@ class UploadPackageAction(RepoAction):
 
         # Check filetype
         if filetype not in ['.dsc', '.deb', '.changes']:
-            print("Error: Only .dsc, .deb or .changes files allowed to upload.")
+            print("Error: Only .dsc, .deb or .changes "
+                  "files allowed to upload.")
             sys.exit(20)
 
         files = [filename]  # list of all files which will be uploaded
diff --git a/elbepack/templates.py b/elbepack/templates.py
index 6d902278..ee67c20c 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -8,12 +8,12 @@ from __future__ import print_function
 
 import os
 
-from elbepack.treeutils import etree
-from elbepack.directories import mako_template_dir, default_preseed_fname
-
 from mako.template import Template
 from mako import exceptions
 
+from elbepack.treeutils import etree
+from elbepack.directories import mako_template_dir, default_preseed_fname
+
 
 def fix_linebreak_escapes(s):
     return s.replace('\\\n', '${"\\\\"}\n')
diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index f74facd0..15150e5a 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -10,10 +10,7 @@ from __future__ import print_function
 
 import os
 import sys
-
-from multiprocessing.managers import BaseManager
-
-from elbepack.shellhelper import system
+import textwrap
 
 # don't remove the apt import, it is really needed, due to some magic in
 # apt_pkg
@@ -22,9 +19,8 @@ import apt  # pylint: disable=unused-import
 import apt_pkg
 
 
-from elbepack.shellhelper import CommandError, system
+from elbepack.shellhelper import system
 from elbepack.filesystem import TmpdirFilesystem
-from elbepack.xmldefaults import ElbeDefaults
 from elbepack.rfs import create_apt_prefs
 
 
@@ -169,9 +165,15 @@ class VirtApt(object):
             # I could make a none global 'noauth' flag for mirrors
             for url in self.xml.node('project/mirror/url-list'):
                 if url.has('raw-key'):
-                    key = "\n".join(line.strip(" \t") for line in url.text('raw-key').splitlines()[1:-1])
+                    for line in url.text('raw-key'):
+                        key = self.key_strip(line)
                     self.add_key(key)
 
+    def key_strip(self, k):
+        key = textwrap.dedent(k)
+        key = key.strip('\n')
+        return key
+
     def start(self):
         pass
 
diff --git a/elbepack/xmldefaults.py b/elbepack/xmldefaults.py
index 1979b67d..61780400 100644
--- a/elbepack/xmldefaults.py
+++ b/elbepack/xmldefaults.py
@@ -9,7 +9,6 @@
 from __future__ import print_function
 
 import random
-import sys
 
 from elbepack.kvm import find_kvm_exe
 
@@ -187,6 +186,7 @@ defaults = {"armel": armel_defaults,
             "i386": i386_defaults,
             "nodefaults": {}}
 
+
 def get_random_mac():
     binaddr = [random.randint(0, 255) for _ in range(6)]
     binaddr[0] &= 0xfe
@@ -202,7 +202,8 @@ class ElbeDefaults(object):
 
         assert build_type in defaults, ("Invalid buildtype %s\n"
                                         "Valid buildtypes are:\n  - %s" %
-                                        (build_type, "\n  - ".join(defaults.keys())))
+                                        (build_type,
+                                         "\n  - ".join(defaults.keys())))
 
         self.defaults = defaults[build_type]
         self.defaults["nicmac"] = get_random_mac()
-- 
2.20.1




More information about the elbe-devel mailing list