10% work
complete most xml relax ng work. work on real interface xml work on python scripts for parsing interface xml
This commit is contained in:
44
python/mine/ri_seq.py
Normal file
44
python/mine/ri_seq.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
current_sequence=""
|
||||
previous_sequences=[]
|
||||
dict={}
|
||||
|
||||
class Sequence:
|
||||
''' implement sequence in interface xml'''
|
||||
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 construct(xml_root):
|
||||
''' construct Sequence's static members'''
|
||||
global current_sequence
|
||||
current_sequence = xml_root.attributes["sequence"].value
|
||||
for s in xml_root.childNodes:
|
||||
if s.nodeType == s.ELEMENT_NODE and s.nodeName == "sequence":
|
||||
dict[s.attributes["name"].value] = Sequence(s)
|
||||
|
||||
def previous():
|
||||
global current_sequence
|
||||
cur_seq = dict[current_sequence]
|
||||
if cur_seq.current_step:
|
||||
cur_seq.current_step -= 1
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
# current sequence already in first step
|
||||
elif previous_sequences:
|
||||
current_sequence = previous_sequences.pop()
|
||||
cur_seq = dict[current_sequence]
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
|
||||
def next():
|
||||
global current_sequence
|
||||
cur_seq = dict[current_sequence]
|
||||
if cur_seq.current_step < len(cur_seq.steps)-1:
|
||||
cur_seq.current_step += 1
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
# current sequence already in last step
|
||||
elif previous_sequences:
|
||||
current_sequence = previous_sequences.pop()
|
||||
cur_seq = dict[current_sequence]
|
||||
return cur_seq.steps[cur_seq.current_step]
|
||||
Reference in New Issue
Block a user