From nobody Fri Dec 19 20:37:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1616083933; cv=none; d=zohomail.com; s=zohoarc; b=BLSEEsmK/0/TAfK+NPjx7hhiu0jGP8GTO/ngWto5uIMWmdWsiqzzi1FZ5l9qLnHqDyA+B/LNk3ROFpf+MNfh08ow1Nbll4kNvLxdCG7l9ik6AwLFu9b2NKcOLRDdcWc70y9rtFS8DpQ/EaQzbnKvdCkEFW2RdnfzuKDRYoifux8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616083933; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fu4XcQPdwE9hWYZYGnAUBFEdu/3sA2Ph7DDfTv9klFk=; b=galYEGoxedegsggIr9uLCh1W0pT/Rn0G+/C/LFzhvpyQpyOCFSs53GD8SyObSalE0R9b2pUIZsvgoZ+S1mMi61w+HFKCdaZh7DeZecaSWpW2iYwlIEJTFwHNvTmnyJ7Jc7y62ut5Bxxniz+fg8QAWhX/KTVEGORZP7lS3zaenMg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1616083933740674.6089294576078; Thu, 18 Mar 2021 09:12:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-459-aOSHtUgiM82Y6e5zTqp7yQ-1; Thu, 18 Mar 2021 12:12:09 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E047107B7C4; Thu, 18 Mar 2021 16:12:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17B7B37DD; Thu, 18 Mar 2021 16:12:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B6380180B451; Thu, 18 Mar 2021 16:12:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12IGBuWj024234 for ; Thu, 18 Mar 2021 12:11:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id E695560938; Thu, 18 Mar 2021 16:11:56 +0000 (UTC) Received: from nautilus.redhat.com (unknown [10.40.192.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 426C660CDF; Thu, 18 Mar 2021 16:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616083932; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fu4XcQPdwE9hWYZYGnAUBFEdu/3sA2Ph7DDfTv9klFk=; b=Jzy28WBG/59HTjI5Oqx4+affXwIQwkOYbSnpuhIrSO1mUqjBmex4G3DvjCvb1W5RsuJSst DQr/fh7yR+KpaabYqQRY+cFQ8+4gORq7evshC5Iw7VnOpLFW9Ih5t9vzHymj1SfawzYHMI 1BBoA6gOgiDSky7jww5E+Sxl+2FFFWs= X-MC-Unique: aOSHtUgiM82Y6e5zTqp7yQ-1 From: Erik Skultety To: libvir-list@redhat.com Subject: [libvirt PATCH v4 6/6] ci: helper: Apply Python naming practice to private methods/attributes Date: Thu, 18 Mar 2021 17:11:46 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" As documented at [1], the common practice with respect 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 --- ci/helper | 122 +++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/ci/helper b/ci/helper index 0743f95e13..70c9cb4f6b 100755 --- a/ci/helper +++ b/ci/helper @@ -84,8 +84,8 @@ class Parser: ) =20 # Main parser - self.parser =3D argparse.ArgumentParser() - subparsers =3D self.parser.add_subparsers( + self._parser =3D argparse.ArgumentParser() + subparsers =3D self._parser.add_subparsers( dest=3D"action", metavar=3D"ACTION", ) @@ -98,7 +98,7 @@ class Parser: parents=3D[containerparser, mesonparser], formatter_class=3Dargparse.ArgumentDefaultsHelpFormatter, ) - buildparser.set_defaults(func=3DApplication.action_build) + buildparser.set_defaults(func=3DApplication._action_build) =20 # test action testparser =3D subparsers.add_parser( @@ -107,7 +107,7 @@ class Parser: parents=3D[containerparser, mesonparser], formatter_class=3Dargparse.ArgumentDefaultsHelpFormatter, ) - testparser.set_defaults(func=3DApplication.action_test) + testparser.set_defaults(func=3DApplication._action_test) =20 # shell action shellparser =3D subparsers.add_parser( @@ -116,7 +116,7 @@ class Parser: parents=3D[containerparser], formatter_class=3Dargparse.ArgumentDefaultsHelpFormatter, ) - shellparser.set_defaults(func=3DApplication.action_shell) + shellparser.set_defaults(func=3DApplication._action_shell) =20 # list-images action listimagesparser =3D subparsers.add_parser( @@ -125,7 +125,7 @@ class Parser: parents=3D[gitlabparser], formatter_class=3Dargparse.ArgumentDefaultsHelpFormatter, ) - listimagesparser.set_defaults(func=3DApplication.action_list_image= s) + listimagesparser.set_defaults(func=3DApplication._action_list_imag= es) =20 # refresh action refreshparser =3D subparsers.add_parser( @@ -147,56 +147,56 @@ class Parser: default=3D"yes", help=3D"check for existence of stale images on the GitLab inst= ance" ) - refreshparser.set_defaults(func=3DApplication.action_refresh) + refreshparser.set_defaults(func=3DApplication._action_refresh) =20 def parse(self): - return self.parser.parse_args() + return self._parser.parse_args() =20 =20 class Application: def __init__(self): - self.basedir =3D pathlib.Path(__file__).resolve().parent - self.args =3D Parser().parse() + self._basedir =3D pathlib.Path(__file__).resolve().parent + self._args =3D Parser().parse() =20 - if self.args.action =3D=3D "refresh": - if not shutil.which(self.args.lcitool): + if self._args.action =3D=3D "refresh": + if not shutil.which(self._args.lcitool): sys.exit("error: 'lcitool' not installed") =20 - def make_run(self, target): + def _make_run(self, target): args =3D [ "-C", - self.basedir, + self._basedir, target, ] =20 - if self.args.action in ["build", "test", "shell"]: + if self._args.action in ["build", "test", "shell"]: args.extend([ - f"CI_ENGINE=3D{self.args.engine}", - f"CI_USER_LOGIN=3D{self.args.login}", - f"CI_IMAGE_PREFIX=3D{self.args.image_prefix}", - f"CI_IMAGE_TAG=3D{self.args.image_tag}", + f"CI_ENGINE=3D{self._args.engine}", + f"CI_USER_LOGIN=3D{self._args.login}", + f"CI_IMAGE_PREFIX=3D{self._args.image_prefix}", + f"CI_IMAGE_TAG=3D{self._args.image_tag}", ]) =20 - if self.args.action in ["build", "test"]: + if self._args.action in ["build", "test"]: args.extend([ - f"CI_MESON_ARGS=3D{self.args.meson_args}", - f"CI_NINJA_ARGS=3D{self.args.ninja_args}", + f"CI_MESON_ARGS=3D{self._args.meson_args}", + f"CI_NINJA_ARGS=3D{self._args.ninja_args}", ]) =20 if pty.spawn(["make"] + args) !=3D 0: sys.exit("error: 'make' failed") =20 - def lcitool_run(self, args): - output =3D subprocess.check_output([self.args.lcitool] + args) + def _lcitool_run(self, args): + output =3D subprocess.check_output([self._args.lcitool] + args) return output.decode("utf-8") =20 - def lcitool_get_hosts(self): - output =3D self.lcitool_run(["hosts"]) + def _lcitool_get_hosts(self): + output =3D self._lcitool_run(["hosts"]) return output.splitlines() =20 - def generate_dockerfile(self, host, cross=3DNone): + def _generate_dockerfile(self, host, cross=3DNone): args =3D ["dockerfile", host, "libvirt"] - outdir =3D self.basedir.joinpath("containers") + outdir =3D self._basedir.joinpath("containers") outfile =3D f"ci-{host}.Dockerfile" =20 if cross: @@ -204,27 +204,27 @@ class Application: outfile =3D f"ci-{host}-cross-{cross}.Dockerfile" =20 outpath =3D outdir.joinpath(outfile) - if not self.args.quiet: + if not self._args.quiet: print(outpath) =20 - output =3D self.lcitool_run(args) + output =3D self._lcitool_run(args) with open(outpath, "w") as f: f.write(output) =20 - def generate_vars(self, host): + def _generate_vars(self, host): args =3D ["variables", host, "libvirt"] - outdir =3D self.basedir.joinpath("cirrus") + outdir =3D self._basedir.joinpath("cirrus") outfile =3D f"{host}.vars" =20 outpath =3D outdir.joinpath(outfile) - if not self.args.quiet: + if not self._args.quiet: print(outpath) =20 - output =3D self.lcitool_run(args) + output =3D self._lcitool_run(args) with open(outpath, "w") as f: f.write(output) =20 - def refresh_containers(self): + def _refresh_containers(self): debian_cross =3D [ "aarch64", "armv6l", @@ -241,41 +241,41 @@ class Application: "mingw64", ] =20 - for host in self.lcitool_get_hosts(): + for host in self._lcitool_get_hosts(): if host.startswith("freebsd-") or host.startswith("macos-"): continue =20 - self.generate_dockerfile(host) + self._generate_dockerfile(host) =20 if host =3D=3D "fedora-rawhide": for cross in fedora_cross: - self.generate_dockerfile(host, cross) + self._generate_dockerfile(host, cross) =20 if host.startswith("debian-"): for cross in debian_cross: if host =3D=3D "debian-sid" and cross =3D=3D "mips": continue - self.generate_dockerfile(host, cross) + self._generate_dockerfile(host, cross) =20 - 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 =20 - self.generate_vars(host) + self._generate_vars(host) =20 - 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}") =20 - 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}") =20 - 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}") =20 - def action_list_images(self): - registry_uri =3D util.get_registry_uri(self.args.namespace, - self.args.gitlab_uri) + def _action_list_images(self): + registry_uri =3D util.get_registry_uri(self._args.namespace, + self._args.gitlab_uri) images =3D util.get_registry_images(registry_uri) =20 # skip the "ci-" prefix each of our container images' name has @@ -295,11 +295,11 @@ class Application: print("Available cross-compiler container images:\n") print(spacing + ("\n" + spacing).join(cross)) =20 - def check_stale_images(self): - namespace =3D self.args.namespace - gitlab_uri =3D self.args.gitlab_uri + def _check_stale_images(self): + namespace =3D self._args.namespace + gitlab_uri =3D self._args.gitlab_uri registry_uri =3D util.get_registry_uri(namespace, gitlab_uri) - lcitool_hosts =3D self.lcitool_get_hosts() + lcitool_hosts =3D self._lcitool_get_hosts() =20 stale_images =3D util.get_registry_stale_images(registry_uri, lcitool_hosts) @@ -328,15 +328,15 @@ class Application: """) print(msg.replace("STALE_DETAILS", stale_details)) =20 - def action_refresh(self): - self.refresh_containers() - self.refresh_cirrus() + def _action_refresh(self): + self._refresh_containers() + self._refresh_cirrus() =20 - if self.args.check_stale =3D=3D "yes" and not self.args.quiet: - self.check_stale_images() + if self._args.check_stale =3D=3D "yes" and not self._args.quiet: + self._check_stale_images() =20 def run(self): - self.args.func(self) + self._args.func(self) =20 =20 if __name__ =3D=3D "__main__": --=20 2.30.2