the following breadcrumb formatting script works (very crudely and with missing characters in the super_script string) in the Python Evaluation:
def breadcrumb_list(arr, reverse=True, single_row=None):
def small_caps(text):
small_caps_chars = str.maketrans("abcdefghijklmnopqrstuvwxyz", "ᴀʙᴄᴅᴇꜰɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ")
return text.translate(small_caps_chars)
def format_superscript(text):
normal = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
super_script = "⁰¹²³⁴⁵⁶⁷⁸⁹ᴬᴮ ᴰᴱ ᴳᴴᴵᴶᴷᴸᴹᴺᴼᴾ ᴿ ᵀᵁⱽᵂ ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖ ʳˢᵗᵘᵛʷˣʸᶻ"
superscript_chars = str.maketrans(normal, super_script)
return text.translate(superscript_chars)
def format_name_list(arr):
if single_row is not None:
row_count = len(arr)
if single_row == 0 or single_row == 1:
index = 0
elif single_row == -1 or single_row == row_count:
index = -1
elif 1 < single_row < row_count:
index = single_row - 1
else:
raise ValueError(f"Invalid single_row value. Must be between 0 and {row_count}, or -1.")
given_name, surname, superscript = arr[index]
return f"{given_name}{format_superscript(superscript)} {small_caps(surname)}"
prev_surname = ""
result = []
names = list(arr)
if reverse:
names.reverse()
for given_name, surname, superscript in names:
if surname != prev_surname:
result.append(f"{given_name}{format_superscript(superscript)} {small_caps(surname)}")
prev_surname = surname
else:
result.append(f"{given_name}{format_superscript(superscript)}")
return "; ".join(result)
return format_name_list(arr)
# Example usage
arr = [["Alice", "McCoy", "22"], ["Bob", "Jones", "199"], ["David", "Jones", "A"], ["Charlie", "Johnson", "B"]]
print("Full array (reverse order):")
print(breadcrumb_list(arr))
print("\nFull array (original order):")
print(breadcrumb_list(arr, reverse=False))
print("\nSingle row (first entry, using 0):")
print(breadcrumb_list(arr, single_row=0))
print("\nSingle row (first entry, using 1):")
print(breadcrumb_list(arr, single_row=1))
print("\nSingle row (last entry, using -1):")
print(breadcrumb_list(arr, single_row=-1))
print("\nSingle row (last entry, using row count):")
print(breadcrumb_list(arr, single_row=len(arr)))
print("\nSingle row (third entry):")
print(breadcrumb_list(arr, single_row=3))
# Test with a single-row array
arr_single = [["Eve", "Brown", "X"]]
print("\nSingle-row array:")
print(breadcrumb_list(arr_single))
print("\nSingle-row array (selecting first/only row):")
print(breadcrumb_list(arr_single, single_row=1))
it outputs:
Full array (reverse order):
Charlieᴮ Jᴏʜɴsᴏɴ; Davidᴬ Jᴏɴᴇs; Bob¹⁹⁹; Alice²² MᴄCᴏʏ
Full array (original order):
Alice²² MᴄCᴏʏ; Bob¹⁹⁹ Jᴏɴᴇs; Davidᴬ; Charlieᴮ Jᴏʜɴsᴏɴ
Single row (first entry, using 0):
Alice²² MᴄCᴏʏ
Single row (first entry, using 1):
Alice²² MᴄCᴏʏ
Single row (last entry, using -1):
Charlieᴮ Jᴏʜɴsᴏɴ
Single row (last entry, using row count):
Charlieᴮ Jᴏʜɴsᴏɴ
Single row (third entry):
Davidᴬ Jᴏɴᴇs
Single-row array:
Eve Bʀᴏᴡɴ
Single-row array (selecting first/only row):
Eve Bʀᴏᴡɴ
My next step is to start exploring how to use the Relationship Calculator library features to populate the Array being passed.
Then cleanup, optimization. Finally trying to fold it into a couple reports.