晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /usr/lib/python3.6/site-packages/cloudinit/distros/parsers/ |
Upload File : |
# Copyright (C) 2012 Yahoo! Inc.
#
# Author: Joshua Harlow <harlowja@yahoo-inc.com>
#
# This file is part of cloud-init. See LICENSE file for license information.
import re
import shlex
from io import StringIO
# This library is used to parse/write
# out the various sysconfig files edited (best attempt effort)
#
# It has to be slightly modified though
# to ensure that all values are quoted/unquoted correctly
# since these configs are usually sourced into
# bash scripts...
import configobj
# See: http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html
# or look at the 'param_expand()' function in the subst.c file in the bash
# source tarball...
SHELL_VAR_RULE = r"[a-zA-Z_]+[a-zA-Z0-9_]*"
SHELL_VAR_REGEXES = [
# Basic variables
re.compile(r"\$" + SHELL_VAR_RULE),
# Things like $?, $0, $-, $@
re.compile(r"\$[0-9#\?\-@\*]"),
# Things like ${blah:1} - but this one
# gets very complex so just try the
# simple path
re.compile(r"\$\{.+\}"),
]
def _contains_shell_variable(text):
for r in SHELL_VAR_REGEXES:
if r.search(text):
return True
return False
class SysConf(configobj.ConfigObj):
"""A configobj.ConfigObj subclass specialised for sysconfig files.
:param contents:
The sysconfig file to parse, in a format accepted by
``configobj.ConfigObj.__init__`` (i.e. "a filename, file like object,
or list of lines").
"""
def __init__(self, contents):
configobj.ConfigObj.__init__(
self, contents, interpolation=False, write_empty_values=True
)
def __str__(self):
contents = self.write()
out_contents = StringIO()
if isinstance(contents, (list, tuple)):
out_contents.write("\n".join(contents))
else:
out_contents.write(str(contents))
return out_contents.getvalue()
def _quote(self, value, multiline=False):
if not isinstance(value, str):
raise ValueError('Value "%s" is not a string' % (value))
if len(value) == 0:
return ""
quot_func = None
if value[0] in ['"', "'"] and value[-1] in ['"', "'"]:
if len(value) == 1:
quot_func = (
lambda x: self._get_single_quote(x) % x
) # noqa: E731
else:
# Quote whitespace if it isn't the start + end of a shell command
if value.strip().startswith("$(") and value.strip().endswith(")"):
pass
else:
if re.search(r"[\t\r\n ]", value):
if _contains_shell_variable(value):
# If it contains shell variables then we likely want to
# leave it alone since the shlex.quote function likes
# to use single quotes which won't get expanded...
if re.search(r"[\n\"']", value):
quot_func = (
lambda x: self._get_triple_quote(x) % x
) # noqa: E731
else:
quot_func = (
lambda x: self._get_single_quote(x) % x
) # noqa: E731
else:
quot_func = shlex.quote
if not quot_func:
return value
return quot_func(value)
def _write_line(self, indent_string, entry, this_entry, comment):
# Ensure it is formatted fine for
# how these sysconfig scripts are used
val = self._decode_element(self._quote(this_entry))
key = self._decode_element(self._quote(entry))
cmnt = self._decode_element(comment)
return "%s%s%s%s%s" % (
indent_string,
key,
"=",
val,
cmnt,
)