Example #1
0
def find_local_notes(search_request):
    """Searches notes file for given request"""
    results = []

    reading_file = open(get_notes_file_location(), "r+", encoding="utf8")
    for line in reading_file:
        matching_line = True

        for term in search_request.inclusion_terms:
            if not re.search(r'\b(%s)\b' % term, line):
                matching_line = False
                break

        if not matching_line:
            continue

        for term in search_request.exclusion_terms:
            if re.search(r'\b(%s)\b' % term, line):
                matching_line = False
                break

        if not matching_line:
            continue

        timestamp, note = parse_note_line(line)

        if note:
            epoch = datestring_to_timestamp(timestamp)
            results.append((epoch, note))
    return results
Example #2
0
 def test_datestring_to_timestamp(self, string, expectation):
     """Verifies string can be converted into a timstamp"""
     self.assertEqual(search.datestring_to_timestamp(string), expectation)