Changeset 599:2f719a01af01


Ignore:
Timestamp:
02/22/15 09:35:04 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The textual version of the delay codes is also sent to the website (re #243)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dcdatagen.py

    r443 r599  
    244244             ["Lack of and/or unserviceable ULD's or pallets",
    245245              "Üzemképes konténerek és raklapok hiánya"]]),
    246            (DELAYCODE, FOR_MODERN | FOR_OT,
     246           (DELAYCODE, FOR_MODERN,
    247247            [None, "39", "GT",
    248248             ["TECHNICAL EQUIPMENT", "BERENDEZÉSEK"],
     
    830830        print >> dcdata, "CAPTION = 1"
    831831        print >> dcdata, "DELAYCODE = 2"
     832        print >> dcdata
    832833
    833834        tableMask = 1
    834835        for i in range(0, len(tablePrefixes)):
     836            print >> dcdata, "_%s_code2meaning = {" % (tablePrefixes[i],)
     837
     838            columnIndexes = []
     839            for j in range(0, len(headings)):
     840                if ( (headingFlags[j]&tableMask)==tableMask ):
     841                    columnIndexes.append(j)
     842
     843            codeIndex = columnIndexes[0]
     844            meaningIndex = columnIndexes[2]
     845
     846            rowIndex = 0
     847            for (type, mask, columns) in rows:
     848                if (mask&tableMask)!=tableMask:
     849                    continue
     850
     851                if type==DELAYCODE:
     852                    print >> dcdata, "    \"%s\": \"%s\"," % \
     853                      (str(columns[codeIndex]).strip(), columns[meaningIndex][0].replace("\n", ""))
     854
     855            print >> dcdata, "}"
     856            print >> dcdata
     857
     858            tableMask <<= 1
     859
     860        print >> dcdata, "def _extract(table, row):"
     861        print >> dcdata, "    code = row[0].strip()"
     862        print >> dcdata, "    meaning = table[code] if code in table else None"
     863        print >> dcdata, "    return code + ((\" (\" + meaning + \")\") if meaning else \"\")"
     864        print >> dcdata
     865
     866        tableMask = 1
     867        for i in range(0, len(tablePrefixes)):
     868
    835869            print >> dcdata, "_%s_data = (" % (tablePrefixes[i],)
    836             print >> dcdata, "    %s," % (extractor,)
     870            print >> dcdata, "    lambda row: _extract(_%s_code2meaning, row)," % \
     871              (tablePrefixes[i],)
    837872            print >> dcdata, "    [",
    838873
Note: See TracChangeset for help on using the changeset viewer.