Files
new_install/interface/ri_seq.py
lizhi-rocky 220e6bfe40 add Qin Bo's operating shell scripts in
rename directory 'python' to 'interface', for I think it is a better name for its included python scripts function.
2010-09-03 15:59:49 +08:00

43 lines
1.4 KiB
Python

#!/usr/bin/python
class Sequence:
''' implement sequence in interface xml'''
dict={}
def __init__(self, xml_node):
self.steps = [ s.attributes["name"].value for s in xml_node.childNodes
if s.nodeType == s.ELEMENT_NODE and s.nodeName == "widget" ]
self.current_step = 0
def set_current_step(self, st):
''' set current step based on input step name'''
self.current_step = self.steps.index(st)
@staticmethod
def set_current_sequence(name):
Sequence.current_sequence = Sequence.dict[name]
@staticmethod
def current():
return (Sequence.current_sequence, Sequence.current_sequence.steps[Sequence.current_sequence.current_step])
@staticmethod
def previous():
if Sequence.current_sequence.current_step:
Sequence.current_sequence.current_step -= 1
return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
@staticmethod
def next():
if Sequence.current_sequence.current_step < len(Sequence.current_sequence.steps)-1:
Sequence.current_sequence.current_step += 1
return Sequence.current_sequence.steps[Sequence.current_sequence.current_step]
def construct(xml_root):
''' construct Sequence's static members'''
for s in xml_root.childNodes:
if s.nodeType == s.ELEMENT_NODE and s.nodeName == "sequence":
Sequence.dict[s.attributes["name"].value] = Sequence(s)