示例#1
0
def getmodules1(lines):
    i=0
    modules=[]
    while i<len(lines):
        line=lines[i]
        i+=1
        parts=normalize1(line)
        if len(parts)<3:
            continue
        if not ischapter(parts[1]):
            continue
        assert len(parts)==3,line

        module=parts[0].upper()

        if module in ('OVERLAY PLANE','MULTI-FRAME OVERLAY','OVERLAY ACTIVATION'):
            continue

        reference=parts[1]
        if module+' MODULE' in modulemacros:
            module=module+' MODULE'
        elif reference in modulesbychapter:
            matches=modulesbychapter[reference]
            assert len(matches)==1,line
            module=matches[0]
        else:
            matches=[]
            for chapter in modulesbychapter:
                if chapter.startswith(reference+'.'):
                    matches.append(chapter)
            assert len(matches)==1,line
            matches=modulesbychapter[matches[0]]
            assert len(matches)==1,line
            module=matches[0]
        modules.append((module,'M'))
    return modules
示例#2
0
def getmodules(lines):
    i=0
    modules={}
    currentie=None
    ignorenextie=False
    while i<len(lines):
        line=lines[i]
        i+=1
        parts=normalize(line)
        if len(parts)<4:
            continue
        if not ischapter(parts[2]):
            continue
        usage=getusage(parts[3])
        assert usage
        assert len(parts)==4,line

        if line.startswith('   '):
            assert currentie,line
            module=parts[1]
            reference=parts[2]
        else:
            ienew=parts[0]
            if ienew not in valid_ies:

                line1=lines[i]
                parts1=normalize(line1)
                ienew=ienew+' '+parts1[0]

                line2=lines[i+1]
                parts2=normalize(line2)

                if ienew+' '+parts2[0] in valid_ies:
                    ienew=ienew+' '+parts2[0]
                    lines[i]='  '.join(parts1[1:])
                    lines[i+1]='  '.join(parts2[1:])
                elif ienew in valid_ies:
                    lines[i]='  '.join(parts1[1:])
                else:
                    assert False,line+'\n'+line1+'\n'+line2
            currentie=ienew
            module=parts[1]
            reference=parts[2]

        if module.upper() in ('OVERLAY PLANE','MULTI-FRAME OVERLAY','OVERLAY ACTIVATION'):
            continue

        if module.upper()+' MODULE' in modulemacros:
            module=module.upper()+' MODULE'
        elif reference in modulesbychapter:
            matches=modulesbychapter[reference]
            assert len(matches)==1,line
            module=matches[0]
        else:
            matches=[]
            for chapter in modulesbychapter:
                if chapter.startswith(reference+'.'):
                    matches.append(chapter)
            assert len(matches)==1,line
            matches=modulesbychapter[matches[0]]
            assert len(matches)==1,line
            module=matches[0]
        if currentie in modules:
            modules[currentie].append((module,usage))
        else:
            modules[currentie]=[(module,usage)]
    return modules