def transform(self, new_index, surround=True): #returns a transposed index if in the table, otherwise returns the value new_index = str(new_index) if self.using_database: if self.db_contains(index_from=new_index): return '<<' * surround + index_reduce( self.db_get_to(new_index)) + '>>' * surround return new_index if new_index in self.table: return '<<' * surround + index_reduce( self.table[new_index]) + '>>' * surround return new_index
def dict_format(x_temp): """formats output of the list of search results""" if self.for_indexes: shown_indexes = rangelist.range_find( [Index(a_temp) for a_temp in x_temp[1]], reduce=True) else: shown_indexes = formkeys({ abridge(index_reduce(x_temp), maxlength=20) for x_temp in x_temp[1] }) if len(shown_indexes) < 20: return (abridge(x_temp[0], maxlength=20) + VERTLINE + shown_indexes) returnlist = [] sp_temp = split_up_range(shown_indexes, seg_length=3) returnlist.append( abridge(x_temp[0], maxlength=20) + VERTLINE + sp_temp[0]) for s_temp in sp_temp[1:]: returnlist.append(VERTLINE + s_temp) return returnlist
def format_keys(keyset,maxlegnth=0): """returns a string with a formatted list of keys""" returntext = EMPTYCHAR for k_temp in sorted(list(keyset)): if maxlegnth > 0 and len(k_temp) > maxlegnth: k_temp = k_temp[0:maxlegnth]+PERIOD*3 returntext += index_reduce(str(k_temp)) + COMMA + BLANK return returntext[:-2]
def short(self): return index_reduce(str(self.self))
def redux(x): if reduce: return index_reduce(x) else: return x