本文整理汇总了Python中core.inputfile.Section.value方法的典型用法代码示例。如果您正苦于以下问题:Python Section.value方法的具体用法?Python Section.value怎么用?Python Section.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.inputfile.Section
的用法示例。
在下文中一共展示了Section.value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_text
# 需要导入模块: from core.inputfile import Section [as 别名]
# 或者: from core.inputfile.Section import value [as 别名]
def set_text(self, new_text):
self.value = []
item_lines = []
found_non_comment = False
for line in new_text.splitlines():
if line.startswith(";;") or line.startswith('['):
self.set_comment_check_section(line)
elif line.startswith(';'):
if found_non_comment: # This comment must be the start of the next one, so build the previous one
try:
make_one = self.list_type()
make_one.set_text('\n'.join(item_lines))
self.value.append(make_one)
item_lines = []
found_non_comment = False
except Exception as e:
print("Could not create object from: " + line + '\n' + str(e) + '\n' + str(traceback.print_exc()))
item_lines.append(line)
elif not line.strip(): # add blank row as a comment item in self.value list
comment = Section()
comment.name = "Comment"
comment.value = ''
self.value.append(comment)
else:
item_lines.append(line)
found_non_comment = True
if found_non_comment: # Found a final one that has not been built yet, build it now
try:
make_one = self.list_type()
make_one.set_text('\n'.join(item_lines))
self.value.append(make_one)
except Exception as e:
print("Could not create object from: " + line + '\n' + str(e) + '\n' + str(traceback.print_exc()))