[libvirt PATCH v3 6/6] ci: helper: Convert private methods to Python common naming practice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As documented at [1], the common practice wrt to private
attributes/methods naming is to prefix them with an underscore.

[1] https://docs.python.org/3/tutorial/classes.html#private-variables

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 ci/helper | 68 +++++++++++++++++++++++++++----------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/ci/helper b/ci/helper
index b5255db835..3d2e0397f5 100755
--- a/ci/helper
+++ b/ci/helper
@@ -97,7 +97,7 @@ class Parser:
             parents=[containerparser, mesonparser],
             formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
-        buildparser.set_defaults(func=Application.action_build)
+        buildparser.set_defaults(func=Application._action_build)
 
         # test action
         testparser = subparsers.add_parser(
@@ -106,7 +106,7 @@ class Parser:
             parents=[containerparser, mesonparser],
             formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
-        testparser.set_defaults(func=Application.action_test)
+        testparser.set_defaults(func=Application._action_test)
 
         # shell action
         shellparser = subparsers.add_parser(
@@ -115,7 +115,7 @@ class Parser:
             parents=[containerparser],
             formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
-        shellparser.set_defaults(func=Application.action_shell)
+        shellparser.set_defaults(func=Application._action_shell)
 
         # list-images action
         listimagesparser = subparsers.add_parser(
@@ -124,7 +124,7 @@ class Parser:
             parents=[gitlabparser],
             formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
-        listimagesparser.set_defaults(func=Application.action_list_images)
+        listimagesparser.set_defaults(func=Application._action_list_images)
 
         # refresh action
         refreshparser = subparsers.add_parser(
@@ -146,7 +146,7 @@ class Parser:
             default="yes",
             help="check for existence of stale images on the GitLab instance"
         )
-        refreshparser.set_defaults(func=Application.action_refresh)
+        refreshparser.set_defaults(func=Application._action_refresh)
 
     def parse(self):
         return self.parser.parse_args()
@@ -161,7 +161,7 @@ class Application:
             if not shutil.which(self.args.lcitool):
                 sys.exit("error: 'lcitool' not installed")
 
-    def make_run(self, target):
+    def _make_run(self, target):
         args = [
             "-C",
             self.basedir,
@@ -185,15 +185,15 @@ class Application:
         if pty.spawn(["make"] + args) != 0:
             sys.exit("error: 'make' failed")
 
-    def lcitool_run(self, args):
+    def _lcitool_run(self, args):
         output = subprocess.check_output([self.args.lcitool] + args)
         return output.decode("utf-8")
 
-    def lcitool_get_hosts(self):
-        output = self.lcitool_run(["hosts"])
+    def _lcitool_get_hosts(self):
+        output = self._lcitool_run(["hosts"])
         return output.splitlines()
 
-    def generate_dockerfile(self, host, cross=None):
+    def _generate_dockerfile(self, host, cross=None):
         args = ["dockerfile", host, "libvirt"]
         outdir = self.basedir.joinpath("containers")
         outfile = f"ci-{host}.Dockerfile"
@@ -206,11 +206,11 @@ class Application:
         if not self.args.quiet:
             print(outpath)
 
-        output = self.lcitool_run(args)
+        output = self._lcitool_run(args)
         with open(outpath, "w") as f:
             f.write(output)
 
-    def generate_vars(self, host):
+    def _generate_vars(self, host):
         args = ["variables", host, "libvirt"]
         outdir = self.basedir.joinpath("cirrus")
         outfile = f"{host}.vars"
@@ -219,11 +219,11 @@ class Application:
         if not self.args.quiet:
             print(outpath)
 
-        output = self.lcitool_run(args)
+        output = self._lcitool_run(args)
         with open(outpath, "w") as f:
             f.write(output)
 
-    def refresh_containers(self):
+    def _refresh_containers(self):
         debian_cross = [
             "aarch64",
             "armv6l",
@@ -240,39 +240,39 @@ class Application:
             "mingw64",
         ]
 
-        for host in self.lcitool_get_hosts():
+        for host in self._lcitool_get_hosts():
             if host.startswith("freebsd-") or host.startswith("macos-"):
                 continue
 
-            self.generate_dockerfile(host)
+            self._generate_dockerfile(host)
 
             if host == "fedora-rawhide":
                 for cross in fedora_cross:
-                    self.generate_dockerfile(host, cross)
+                    self._generate_dockerfile(host, cross)
 
             if host.startswith("debian-"):
                 for cross in debian_cross:
                     if host == "debian-sid" and cross == "mips":
                         continue
-                    self.generate_dockerfile(host, cross)
+                    self._generate_dockerfile(host, cross)
 
-    def refresh_cirrus(self):
-        for host in self.lcitool_get_hosts():
+    def _refresh_cirrus(self):
+        for host in self._lcitool_get_hosts():
             if not (host.startswith("freebsd-") or host.startswith("macos-")):
                 continue
 
-            self.generate_vars(host)
+            self._generate_vars(host)
 
-    def action_build(self):
-        self.make_run(f"ci-build@{self.args.target}")
+    def _action_build(self):
+        self._make_run(f"ci-build@{self.args.target}")
 
-    def action_test(self):
-        self.make_run(f"ci-test@{self.args.target}")
+    def _action_test(self):
+        self._make_run(f"ci-test@{self.args.target}")
 
-    def action_shell(self):
-        self.make_run(f"ci-shell@{self.args.target}")
+    def _action_shell(self):
+        self._make_run(f"ci-shell@{self.args.target}")
 
-    def action_list_images(self):
+    def _action_list_images(self):
         registry_uri = util.get_registry_uri(self.args.namespace,
                                              self.args.gitlab_uri)
         images = util.get_registry_images(registry_uri)
@@ -294,14 +294,14 @@ class Application:
             print("Available cross-compiler container images:\n")
             print(spacing + ("\n" + spacing).join(cross))
 
-    def check_stale_images(self):
+    def _check_stale_images(self):
         if self.args.check_stale != "yes" or self.args.quiet:
             return
 
         namespace = self.args.namespace
         gitlab_uri = self.args.gitlab_uri
         registry_uri = util.get_registry_uri(namespace, gitlab_uri)
-        lcitool_hosts = self.lcitool_get_hosts()
+        lcitool_hosts = self._lcitool_get_hosts()
 
         stale_images = util.get_registry_stale_images(registry_uri,
                                                       lcitool_hosts)
@@ -326,13 +326,13 @@ You can remove the above images over the API with the following code snippet:
 You can generate a personal access token here:
     {gitlab_uri}/-/profile/personal_access_tokens""")
 
-    def action_refresh(self):
+    def _action_refresh(self):
         # refresh Dockerfiles and vars files
-        self.refresh_containers()
-        self.refresh_cirrus()
+        self._refresh_containers()
+        self._refresh_cirrus()
 
         # check for stale images
-        self.check_stale_images()
+        self._check_stale_images()
 
     def run(self):
         self.args.func(self)
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux