12345678910111213141516171819202122232425262728293031323334353637 |
- import data
- def list_have_location(l):
- for d in l:
- if not data.have_location(d):
- return False
- return True
- 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 check_entry(before, curr, after):
- if not list_have_location(before):
- return None
- if not data.have_location(curr):
- return None
- if not data.maybe_entry(curr):
- return None
- if data.maybe_entry(before[-1]):
- return None
- if not list_have_continue_maybe_indoor(after):
- return None
- return before[-1]
- def recognize_entries(l):
- ret = []
- for i in range(60, len(l) - 12):
- x = check_entry(l[i-60:i], l[i], l[i+1:i+13])
- if not x is None:
- ret.append(x)
- return ret
|