/snap/core24/1587/usr/lib/python3/dist-packages/cloudinit/distros
NameSizeModeActions
package_management/-0755rm
parsers/-0755rm
__pycache__/-0755rm
almalinux.py1510644editdlrm
alpine.py249320644editdlrm
amazon.py9070644editdlrm
aosc.py44820644editdlrm
arch.py50370644editdlrm
azurelinux.py24050644editdlrm
bsd.py64900644editdlrm
bsd_utils.py14400644editdlrm
centos.py1510644editdlrm
cloudlinux.py1510644editdlrm
cos.py2470644editdlrm
debian.py108570644editdlrm
dragonflybsd.py2300644editdlrm
eurolinux.py1510644editdlrm
fedora.py4370644editdlrm
freebsd.py87350644editdlrm
gentoo.py49900644editdlrm
mariner.py17400644editdlrm
miraclelinux.py1510644editdlrm
netbsd.py56470644editdlrm
networking.py110700644editdlrm
openbsd.py24230644editdlrm
OpenCloudOS.py2770644editdlrm
openeuler.py2750644editdlrm
openmandriva.py2370644editdlrm
opensuse-leap.py2470644editdlrm
opensuse-microos.py2470644editdlrm
opensuse-tumbleweed.py2470644editdlrm
opensuse.py102010644editdlrm
photon.py54860644editdlrm
raspberry_pi_os.py22570644editdlrm
rhel.py81720644editdlrm
rhel_util.py14300644editdlrm
rocky.py1510644editdlrm
sle-micro.py2470644editdlrm
sles.py2470644editdlrm
sle_hpc.py2470644editdlrm
suse.py810644editdlrm
TencentOS.py2770644editdlrm
ubuntu.py23740644editdlrm
ug_util.py100010644editdlrm
virtuozzo.py1510644editdlrm
__init__.py675420644editdlrm
Edit: /snap/core24/1587/usr/lib/python3/dist-packages/cloudinit/distros/bsd_utils.py (1440B)
# This file is part of cloud-init. See LICENSE file for license information. import shlex from cloudinit import util # On NetBSD, /etc/rc.conf comes with a if block: # if [ -r /etc/defaults/rc.conf ]; then # as a consequence, the file is not a regular key/value list # anymore and we cannot use cloudinit.distros.parsers.sys_conf # The module comes with a more naive parser, but is able to # preserve these if blocks. def _unquote(value): if value[0] == value[-1] and value[0] in ['"', "'"]: return value[1:-1] return value def get_rc_config_value(key, fn="/etc/rc.conf"): key_prefix = "{}=".format(key) for line in util.load_text_file(fn).splitlines(): if line.startswith(key_prefix): value = line.replace(key_prefix, "") return _unquote(value) def set_rc_config_value(key, value, fn="/etc/rc.conf"): lines = [] done = False value = shlex.quote(value) original_content = util.load_text_file(fn) for line in original_content.splitlines(): if "=" in line: k, v = line.split("=", 1) if k == key: v = value done = True lines.append("=".join([k, v])) else: lines.append(line) if not done: lines.append("=".join([key, value])) new_content = "\n".join(lines) + "\n" if new_content != original_content: util.write_file(fn, new_content)