Esempio n. 1
0
def addsequence(element):
    tag, elements = element
    tag = hextag(tag)
    for element in elements:
        if type(element) == long:
            addtosba(tag, element)
        elif type(element) == str:
            if element == mm:
                print >> sys.stderr, "macro", mm, "includes itself"
                continue
            for element in expand(element):
                addtosba(tag, element)
        else:
            addtosba(tag, element[0])
            addsequence(element)
def addsequence(element):
    tag,elements=element
    tag=hextag(tag)
    for element in elements:
        if type(element)==long:
            addtosba(tag,element)
        elif type(element)==str:
            if element==mm:
                print >> sys.stderr, "macro",mm,"includes itself"
                continue
            for element in expand(element):
                addtosba(tag,element)
        else:
            addtosba(tag,element[0])
            addsequence(element)
            if element==mm:
                print >> sys.stderr, "macro",mm,"includes itself"
                continue
            for element in expand(element):
                addtosba(tag,element)
        else:
            addtosba(tag,element[0])
            addsequence(element)

sequencesbyattribute={}

for chapter,table,elements in modulemacros.values():
    for element in elements:
        if type(element) in (long,str):
            continue
        addsequence(element)

print "# list of possible sequences an attribute can occur within by attribute"
print "sequencesbyattribute={"

for tag,sqlist in sequencesbyattribute.items():
    reprlist='['
    for item in sqlist:
        reprlist+=item+', '
    reprlist=reprlist[:-2]+']'

    print '# '+keyword_for_tag(tag)
    print hextag(tag)+': ',reprlist+','

print "}"
Esempio n. 4
0
                print >> sys.stderr, "macro", mm, "includes itself"
                continue
            for element in expand(element):
                addtosba(tag, element)
        else:
            addtosba(tag, element[0])
            addsequence(element)


sequencesbyattribute = {}

for chapter, table, elements in modulemacros.values():
    for element in elements:
        if type(element) in (long, str):
            continue
        addsequence(element)

print "# list of possible sequences an attribute can occur within by attribute"
print "sequencesbyattribute={"

for tag, sqlist in sequencesbyattribute.items():
    reprlist = '['
    for item in sqlist:
        reprlist += item + ', '
    reprlist = reprlist[:-2] + ']'

    print '# ' + keyword_for_tag(tag)
    print hextag(tag) + ': ', reprlist + ','

print "}"
Esempio n. 5
0
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither name of Mathieu Malaterre, or CREATIS, nor the names of any
# contributors (CNRS, INSERM, UCB, Universite Lyon I), may be used to
# endorse or promote products derived from this software without specific
# prior written permission.
#
"""

print "datadict={"

for tag,value in datadict.items():
    tag=hextag(tag)
    print tag+": "+repr(value)+","

print """}

def keyword_for_tag(tag):
    tag=long(tag)
    if tag in datadict:
        return datadict[tag][4]
    return ''
"""
Esempio n. 6
0
        for module, usage in modules:
            for attribute in expand(module):
                if attribute in iesbyattribute:
                    if ie not in iesbyattribute[attribute][None]:
                        iesbyattribute[attribute][None].append(ie)
                    if iod in iesbyattribute[attribute]:
                        if ie not in iesbyattribute[attribute][iod]:
                            iesbyattribute[attribute][iod].append(ie)
                    else:
                        iesbyattribute[attribute][iod] = [ie]
                else:
                    iesbyattribute[attribute] = {None: [ie], iod: [ie]}

print "# list of possible IEs for an attribute by attribute and IOD name"
print "# (2-dimensional dictionary)"
print "# The key None for the IOD yields all possible IEs for the attribute"
print "# regardless of IOD context"
print "iesbyattribute={"

for tag, iedict in iesbyattribute.items():
    print '# ' + keyword_for_tag(tag)
    print hextag(tag) + ': {'

    for key, value in iedict.items():
        print ' ' + repr(key) + ': ' + repr(value) + ','
        if key != None and len(value) > 1:
            print >> sys.stderr, "tag", hextag(
                tag), "not unique in", key, ":", value
    print '},'
print "}"
Esempio n. 7
0
    for ie,modules in ioddict.items():
        for module,usage in modules:
            for attribute in expand(module):
                if attribute in iesbyattribute:
                    if ie not in iesbyattribute[attribute][None]:
                        iesbyattribute[attribute][None].append(ie)
                    if iod in iesbyattribute[attribute]:
                        if ie not in iesbyattribute[attribute][iod]:
                            iesbyattribute[attribute][iod].append(ie)
                    else:
                        iesbyattribute[attribute][iod]=[ie]
                else:
                    iesbyattribute[attribute]={None:[ie],iod:[ie]}

print "# list of possible IEs for an attribute by attribute and IOD name"
print "# (2-dimensional dictionary)"
print "# The key None for the IOD yields all possible IEs for the attribute"
print "# regardless of IOD context"
print "iesbyattribute={"

for tag,iedict in iesbyattribute.items():
    print '# '+keyword_for_tag(tag)
    print hextag(tag)+': {'
    
    for key,value in iedict.items():
        print ' '+repr(key)+': '+repr(value)+','
        if key!=None and len(value) > 1:
            print >> sys.stderr,"tag",hextag(tag),"not unique in",key,":",value
    print '},'
print "}"