def test_adjust_labels(): assert "I_rub" == adjust_labels(testline1, test_curlabel, dict_headline, dict_support).labeltext assert "SOMETHING_usd" == adjust_labels(testline2, test_curlabel, dict_headline, dict_support).labeltext assert UnknownLabel() == adjust_labels(testline3, test_curlabel, dict_headline, dict_support)
def _run_label_adjuster(self): """Label rows using markup information from self.specs[i].header_dict and .unit_dict. Stores labels in self.labels[i]. """ cur_label = UnknownLabel() for i, head in self.row_heads: # change cur_label at text rows, not starting with year number if not is_year(head): cur_label = adjust_labels(textline=head, incoming_label=cur_label, dict_headline=self.specs[i].header_dict, dict_unit=self.specs[i].unit_dict) self.labels[i] = Label(cur_label.head, cur_label.unit)
def __init__(self): self.rows = get_rows() self.default_spec = get_definitions()['default'] self.segment_specs = get_definitions()['additional'] _ss = SegmentState(self.default_spec, self.segment_specs) heads = [head for i, head in self.enum_row_heads] self.specs = _ss.assign_segments(heads) """Label rows using markup information from self.specs[i].header_dict and .unit_dict. Stores labels in self.labels[i]. """ self.labels = [UnknownLabel() for _ in self.rows] cur_label = UnknownLabel() for i, head in self.enum_row_heads: if not is_year(head): cur_label = adjust_labels( textline=head, incoming_label=cur_label, dict_headline=self.specs[i]['table_headers'], dict_unit=self.specs[i]['units']) self.labels[i] = Label(cur_label.head, cur_label.unit)