import data def count_have_location(l): ans = 0 for d in l: if data.have_location(d): ans += 1 return ans def list_have_continue_maybe_indoor(l): last_indoor = False for d in l: indoor = data.maybe_indoor(d) if indoor and last_indoor: return True last_indoor = indoor return False def recognize_entries(l): print(l) ret = [] j = 0 for i in range(len(l)): while j < len(l) and l[j].timestamp - l[i].timestamp < 60: j += 1 if j - i < 12: continue if count_have_location(l[i:j]) < j - i: continue if j >= len(l) or not data.maybe_entry(l[j]): continue if data.maybe_entry(l[j-1]): continue if not list_have_continue_maybe_indoor(l[j+1:j+13]): continue ret.append(l[j-1]) return ret