本文整理汇总了Python中karesansui.lib.dict_op.DictOp.iscomment方法的典型用法代码示例。如果您正苦于以下问题:Python DictOp.iscomment方法的具体用法?Python DictOp.iscomment怎么用?Python DictOp.iscomment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.dict_op.DictOp
的用法示例。
在下文中一共展示了DictOp.iscomment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from karesansui.lib.dict_op import DictOp [as 别名]
# 或者: from karesansui.lib.dict_op.DictOp import iscomment [as 别名]
#.........这里部分代码省略.........
match = True
if match is False:
if _aline.lstrip()[0:1] == self._comment:
footer_regex = re.compile(self._footer)
m = footer_regex.search(_aline)
if not m:
comment = _aline[_aline.find(self._comment):]
pre_comment.append(comment)
continue
if len(pre_comment) > 0:
eof_key = "%sEOF" % (self._reserved_key_prefix,)
new_value = self.build_value("",pre_comment,post_comment)
dop.set("__",[eof_key],new_value)
return dop.getconf("__")
def _value_to_lines(self,conf_arr,level=0):
lines = []
orders_key = "%sORDERS" % (self._reserved_key_prefix,)
dop = DictOp()
dop.addconf("__",conf_arr)
for _k,_v in dop.getconf("__").iteritems():
action = dop.action("__",[_k])
if action == "delete":
continue
iscomment = dop.iscomment("__",[_k])
value = dop.get("__",[_k])
if type(value) == list:
_val = value[0]
if type(_val) != dict:
_pre_comment = value[1][0]
_post_comment = value[1][1]
pre_comment = []
try:
for _aline in _pre_comment:
if _aline.strip() == "":
pass
elif _aline[0:1] != self._comment:
_prefix = ""
if level > 0:
_prefix += str_repeat(self._indent,level)
_prefix += self._comment
_aline = "%s %s" % (_prefix,_aline,)
pre_comment.append(_aline)
except:
pass
if len(pre_comment) > 0:
#preprint_r(pre_comment)
lines = lines + pre_comment
post_comment = _post_comment
try:
示例2: _value_to_lines
# 需要导入模块: from karesansui.lib.dict_op import DictOp [as 别名]
# 或者: from karesansui.lib.dict_op.DictOp import iscomment [as 别名]
def _value_to_lines(self,conf_arr,level=0):
lines = []
orders_key = "%sORDERS" % (self._reserved_key_prefix,)
dop = DictOp()
dop.addconf("__",conf_arr)
for _k,_v in dop.getconf("__").iteritems():
action = dop.action("__",[_k])
if action == "delete":
continue
iscomment = dop.iscomment("__",[_k])
value = dop.get("__",[_k])
if type(value) == list:
_val = value[0]
if type(_val) != dict:
_pre_comment = value[1][0]
_post_comment = value[1][1]
pre_comment = []
try:
for _aline in _pre_comment:
if _aline.strip() == "":
pass
elif _aline[0:1] != self._comment:
_prefix = ""
if level > 0:
_prefix += str_repeat(self._indent,level)
_prefix += self._comment
_aline = "%s %s" % (_prefix,_aline,)
pre_comment.append(_aline)
except:
pass
if len(pre_comment) > 0:
#preprint_r(pre_comment)
lines = lines + pre_comment
post_comment = _post_comment
try:
if post_comment is not None and post_comment[0:1] != self._comment:
post_comment = "%s %s" % (self._comment,post_comment,)
except:
pass
else:
pass
else:
_val = value
_prefix = ""
if iscomment is True:
_prefix += self._comment
if level > 0:
_prefix += str_repeat(self._indent,level)
if type(_val) == dict:
# ORDER順に設定する
orders = []
try:
old_orders = _val[orders_key]['value']
except:
old_orders = []
for kk in old_orders:
if type(kk) is list:
orders.append(kk[0])
elif type(kk) is str:
orders.append(kk)
for kk in _val.keys():
if not kk in orders:
orders.append(kk)
#for _k2,_v2 in _val.iteritems():
for _k2 in orders:
if _k2 == orders_key:
continue
_v2 = _val[_k2]
sub_value = {}
sub_value[_k2] = _v2
try:
iscomment = sub_value[_k2]['comment']
except:
iscomment = False
try:
action = sub_value[_k2]['action']
except:
action = ""
#.........这里部分代码省略.........