7.4. staticloader: addNation
staticloader
# - - - a d d N a t i o n
def addNation ( db, rawLine ):
'''Add one row to the nations table.
[ (db is a CBCData instance) and
(rawLine is a valid nations file line) ->
db.s +:= a new nations row made from rawLine ]
Line format:
0 1 2 3
0123456789012345678901234567890
CAN Canada
'''
#-- 1 --
# [ nation_code := the nation code field from rawLine
# nation_name := the nation name field from rawLine ]
nation_code = rawLine[:3]
nation_name = unicode(rawLine[4:].strip())
#-- 2 --
# [ db.s +:= a new Nation row added using nation_code and
# nation_name ]
db.s.add ( db.Nation ( nation_code, nation_name) )