Next / Previous / Contents / Shipman's homepage

7.6. indexer: findGroup()

The purpose of this function is to locate the UniGroup instance for ISO-9573, and return a Python set of all the entity set names in that group.

indexer
# - - -   f i n d G r o u p

def findGroup(uniData):
    '''Find the entity group and its component entity sets.

      [ uniData is a unidata.UniData instance ->
          if GROUP_9573 is a group name in uniData ->
            sys.stdout  +:=  report on that group and its component
                entity sets from uniData
            return a set of the names of those component entity sets
          else ->
            sys.stderr  +:=  error message
            stop execution ]
    '''
    #-- 1
    # [ if GROUP_9573 is a group name in uniData ->
    #     uniGroup  :=  the corresponding UniGroup from uniData
    #     entSetNames  :=  a new, empty set
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        uniGroup = uniData.findGroup(GROUP_9573)
        entSetNames = set()
    except KeyError:
        fatal("No such group: '{0}'.".format(GROUP_9573))

    #-- 2
    # [ entSetNames  +:=  entity set names from uniGroup ]
    for uniEntSet in uniGroup.genEntSets():
        entSetNames.add(uniEntSet.name)

    #-- 3
    return entSetNames