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

10.15. hist.cgi: updateSimpleAbbrs()

hist.cgi
# - - -   u p d a t e S i m p l e A b b r s

def updateSimpleAbbrs(c, txny):
    '''Modernize codes for a simple (non-compound) BirdId.

      [ (c is a pycbc.Census instance with rel==abbrMod.REL_SIMPLE) and
        (txny is an xnomo3.Txny instance) ->
          if c.form has an exact equivalent in txny ->
            return a new pycbc.Census instance with c.form replaced by
            that equivalent
          else -> return c ]
    '''

For the logic that replaces outdated codes, see hist-oldCode.

hist.cgi
    #-- 1
    # [ if c.form is not defined in txny ->
    #     raise KeyError
    #   else if c.form has an exact equivalent in txny ->
    #     newForm  :=  that equivalent in standard form
    #   else ->
    #     newForm  :=  None ]
    newForm = fixOldAbbr(c.form, txny)

If there is an equivalent code, we rebuild the census record, otherwise we just return the original.

hist.cgi
    if newForm is None:
        return c
    else:
        return lib.pycbc.CBCData.Census(c.lat, c.lon, c.year_no,
            c.year_key, c.seq_no, newForm, c.rel, c.alt_form,
            c.age, c.sex, c.plus, c.q, c.census)