Beispiel #1
0
def set_rs_distance_into_project_notes(rs_distance):
    assert isinstance(rs_distance, float)
    assert SUPPORT_PROJECT_NOTES is True
    notes = tde4.getProjectNotes()
    label = RS_DISTANCE_PROJECT_NOTES_LABEL.format(number=rs_distance)
    existing_value = _get_rs_distance_from_project_notes()
    if existing_value is None:
        # Add to top of the project notes, in case someone is using
        # the bottom of the notes to embed JSON data or something like
        # that.
        new_notes = label + '\n' + notes
    else:
        lines = notes.split('\n')
        new_lines = []
        for line in lines:
            line_to_parse = _filter_project_notes_line(line)
            if RS_DISTANCE_KEY in line_to_parse:
                line = label
            new_lines.append(line)
        new_notes = '\n'.join(new_lines)
    tde4.setProjectNotes(new_notes)
    return
Beispiel #2
0
def _get_rs_distance_from_project_notes():
    rs_distance = None
    if SUPPORT_PROJECT_NOTES is True:
        notes = tde4.getProjectNotes()
        rs_distance = _parse_rs_distance_from_project_notes(notes)
    return rs_distance