Next / Previous / Contents / Shipman's homepage

5.5. entmarch: extractSet()

entmarch
# - - -   e x t r a c t S e t

def extractSet(uniData, entSet):
    '''Write the declarations for one entity.

      [ (uniData is a unidata.UniData instance) and
        (entSet is a UniEntSet instance in uniData) ->
          sys.stdout  +:=  entity definitions for entities in uniGroup ]
    '''

For each entity set, we first write a separator comment, then a comment containing the set name, and its public ID, if there is one.

entmarch
    #-- 1
    # [ sys.stdout  +:=  heading for this entity set ]
    print("\n  <!--{0}-->".format(DOUBLE_BAR))
    print("  <!--{0}".format(entSet.name))
    if entSet.fpi is not None:
        print("   !  {0}".format(entSet.fpi))
    print("   !-->")

The entity definitions are child elements of the character definitions, and each entity definition contains the name of the related entity set. Hence, to find all the entities in this set, we have to look at each character definition. The generation of the entities for one code point set is handled in Section 5.6, “entmarch: extractData().

entmarch
    #-- 2
    # [ sys.stdout  +:=  definitions for entities in entSet ]
    for uniChar in uniData.genChars():
        extractData(uniData, uniChar, entSet.name)