/snap/core18/2979/usr/lib/python3/dist-packages/cloudinit/distros
NameSizeModeActions
parsers/-0755rm
__pycache__/-0755rm
almalinux.py1740644editdlrm
alpine.py68880644editdlrm
amazon.py6150644editdlrm
arch.py85370644editdlrm
bsd.py50290644editdlrm
bsd_utils.py14530644editdlrm
centos.py1740644editdlrm
cloudlinux.py1740644editdlrm
cos.py2700644editdlrm
debian.py136800644editdlrm
dragonflybsd.py2530644editdlrm
eurolinux.py1740644editdlrm
fedora.py4600644editdlrm
freebsd.py65900644editdlrm
gentoo.py91620644editdlrm
mariner.py17590644editdlrm
miraclelinux.py1740644editdlrm
netbsd.py45390644editdlrm
networking.py113500644editdlrm
net_util.py65730644editdlrm
openbsd.py19080644editdlrm
OpenCloudOS.py2770644editdlrm
openEuler.py2980644editdlrm
openmandriva.py2600644editdlrm
opensuse-leap.py2700644editdlrm
opensuse-microos.py2700644editdlrm
opensuse-tumbleweed.py2700644editdlrm
opensuse.py95810644editdlrm
photon.py48490644editdlrm
rhel.py72840644editdlrm
rhel_util.py14730644editdlrm
rocky.py1740644editdlrm
sle-micro.py2700644editdlrm
sles.py2700644editdlrm
sle_hpc.py2700644editdlrm
TencentOS.py2770644editdlrm
ubuntu.py15330644editdlrm
ug_util.py100320644editdlrm
virtuozzo.py1740644editdlrm
__init__.py438680644editdlrm
Edit: /snap/core18/2979/usr/lib/python3/dist-packages/cloudinit/distros/bsd_utils.py (1453B)
# 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_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_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) # vi: ts=4 expandtab