def process_file(filename, source):
    '''process one file'''
    print("Processing %s" % filename)
    mlog = mavutil.mavlink_connection(filename, notimestamps=args.notimestamps)
    
    position_field_type = sniff_field_spelling(mlog, source)
    
    # init fields and field_types lists
    fields = [args.source + "." + s for s in position_field_type]
    fields.append(mainstate_field)
    field_types = []

    msg_types = set()
    re_caps = re.compile('[A-Z_][A-Z0-9_]+')

    for f in fields:
        caps = set(re.findall(re_caps, f))
        msg_types = msg_types.union(caps)
        field_types.append(caps)
    
    add_data.new_linestring = True
    add_data.mainstate_current = -1
    add_data.current_kml_linestring = None
    add_data.position_data = [None for n in position_field_type]
    add_data.last_time = 0

    while True:
        msg = mlog.recv_match(args.condition)
        if msg is None:
            break
        tdays = (msg._timestamp - time.timezone) / (24 * 60 * 60)
        tdays += 719163  # pylab wants it since 0001-01-01
        add_data(tdays, msg, msg_types, mlog.messages, fields, field_types, position_field_type)
def process_file ( filename , source ) : print ( "Processing %s" % filename ) mlog = mavutil . mavlink_connection ( filename , notimestamps = args . notimestamps ) position_field_type = sniff_field_spelling ( mlog , source ) fields = [ args . source + "." + s for s in position_field_type ] fields . append ( mainstate_field ) field_types = [ ] msg_types = set ( ) re_caps = re . compile ( '[A-Z_][A-Z0-9_]+' ) for f in fields : caps = set ( re . findall ( re_caps , f ) ) msg_types = msg_types . union ( caps ) field_types . append ( caps ) add_data . new_linestring = True add_data . mainstate_current = - 1 add_data . current_kml_linestring = None add_data . position_data = [ None for n in position_field_type ] add_data . last_time = 0 while True : msg = mlog . recv_match ( args . condition ) if msg is None : break tdays = ( msg . _timestamp - time . timezone ) / ( 24 * 60 * 60 ) tdays += 719163 add_data ( tdays , msg , msg_types , mlog . messages , fields , field_types , position_field_type )
process one file