Пример #1
0
def index_from_str(s_ix, form):
    if s_ix is None:
        return None
    elif s_ix == '<':
        return FormIndex.createBeginningOfFormIndex()
    elif s_ix == '>':
        return FormIndex.createEndOfFormIndex()

    def step_from_str(step):
        if step.endswith('J'):
            i = int(step[:-1])
            mult = -10
        else:
            pieces = step.split(':')
            i = int(pieces[0])
            try:
                mult = int(pieces[1])
            except IndexError:
                mult = -1
        return (i, mult)

    ix = reduce(lambda cur, (i, mult): FormIndex(cur, i, mult, None),
                (step_from_str(step) for step in reversed(s_ix.split(','))),
                None)
    ix.assignRefs(form)
    return ix
Пример #2
0
def index_from_str(s_ix, form):
    if s_ix is None:
        return None
    elif s_ix == '<':
        return FormIndex.createBeginningOfFormIndex()
    elif s_ix == '>':
        return FormIndex.createEndOfFormIndex()

    def step_from_str(step):
        if step.endswith('J'):
            i = int(step[:-1])
            mult = -10
        else:
            pieces = step.split(':')
            i = int(pieces[0])
            try:
                mult = int(pieces[1])
            except IndexError:
                mult = -1
        return (i, mult)

    ix = reduce(lambda cur, (i, mult): FormIndex(cur, i, mult, None),
                (step_from_str(step) for step in reversed(s_ix.split(','))),
                None)
    ix.assignRefs(form)
    return ix
Пример #3
0
 def ix_in_scope(form_ix):
   if form_ix.isEndOfFormIndex():
     return False
   elif parent_ix.isBeginningOfFormIndex():
     return True
   else:
     return FormIndex.isSubElement(parent_ix, form_ix)
Пример #4
0
 def ix_in_scope(form_ix):
     if form_ix.isEndOfFormIndex():
         return False
     elif parent_ix.isBeginningOfFormIndex():
         return True
     else:
         return FormIndex.isSubElement(parent_ix, form_ix)
Пример #5
0
 def walk(self):
     form_ix = FormIndex.createBeginningOfFormIndex()
     tree = []
     self._walk(form_ix, tree)
     return tree
Пример #6
0
 def walk(self):
     form_ix = FormIndex.createBeginningOfFormIndex()
     tree = []
     self._walk(form_ix, tree)
     return tree