我正在尝试使用 ConfigObj 创建一个 python .py 文件。
我面临的问题如下 -
- 如何使用 configObj 附加起始参数(类名、初始化语句)、导入语句等?
- 在 ConfigObj 中,我们可以使用节分隔符。如何使用注释作为部分名称?显然,.py 文件中的任何错误代码都不会运行。所以,我想使用注释作为部分标题来分隔事物。
以下是我尝试使用的 configspec 文件的代码 - (是的,我正在使用 OpenFlow) -
from mininet.topo import Topo, Node
class MyTopo( Topo ):
"Simple topology example."
def __init__( self, enable_all = True ):
"Create custom topo."
# Add default members to class.
super( MyTopo, self ).__init__()
[["Define_Nodes"]]
[[__many__]]
[["Add_nodes"]]
[[__many__]]
[["Add_edges"]]
[[__many__]]
# Consider all switches and hosts 'on'
self.enable_all()
topos = { 'mytopo': ( lambda: MyTopo() ) }
最后,当我运行此规范时,我的代码返回以下错误 -
in _handle_configspec
raise ConfigspecError('Parsing configspec failed: %s' % e)
ConfigspecError: Parsing configspec failed: Invalid line at line "1".
显然,这意味着我无法创建正确的 configspec 来与 ConfigObj 一起运行。
我的 2 点问题的任何答案都会很棒!