Next / Previous / Contents / TCC Help System / NM Tech homepage

10.1. addArchive(): Process one archive's worth of catalog entries

This function reads the contents of one archive index file, and adds all its catalog information to the rootTaxon object.

catweb
# - - -   a d d A r c h i v e

def addArchive(txny, catalog, rootTaxon, archFileName):
    '''Add one archive's worth of catalog entries.

      [ (txny is a taxonomy as a txnyModule.Txny) and
        (catalog is a birdimages.ImageCatalog) and
        (rootTaxon is a TaxonPhotoset) and
        (archFileName is a string) ->
          if archFileName names a readable file valid against
          archx.rnc ->
            rootTaxon  :=  rootTaxon with photos from that
                archive, placed into taxa from txny, using
                forms from catalog ]
    '''

The ArchiveIndex.readFile() static method takes care of reading the file and building an ArchiveIndex object to represent it.

catweb
    #-- 1
    # [ if archFileName names a file that is readable and valid
    #   against archx.rnc ->
    #     archIndex  :=  an ArchiveIndex instance representing
    #                    that file, with cataloging from catalog
    #   else -> raise IOError ]
    archIndex = ArchiveIndex.readFile(catalog, archFileName)

We extract each catalog entry in turn and add it to rootTaxon.

catweb
    #-- 2
    # [ rootTaxon  :=  rootTaxon with photos added from
    #       archIndex, placed into taxa from txny ]
    for archImage in archIndex.genArchImages():
        addArchImage(txny, archImage, rootTaxon)