Removed extra whitespace from ascii_bicorder.py script
This commit is contained in:
@@ -8,7 +8,7 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def center_text(text, width=80):
|
def center_text(text, width):
|
||||||
"""Center text within a given width"""
|
"""Center text within a given width"""
|
||||||
return text.center(width)
|
return text.center(width)
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ def format_gradient_bar(value):
|
|||||||
return "[" + "".join(bars) + "]"
|
return "[" + "".join(bars) + "]"
|
||||||
|
|
||||||
|
|
||||||
def format_gradient_line(term_left, term_right, value, left_width=18, right_width=18):
|
def format_gradient_line(term_left, term_right, value, left_width, right_width, center_width):
|
||||||
"""
|
"""
|
||||||
Format a gradient line with proper spacing.
|
Format a gradient line with proper spacing.
|
||||||
Example: " explicit < [|||||||||] > implicit "
|
Example: " explicit < [|||||||||] > implicit "
|
||||||
@@ -39,7 +39,7 @@ def format_gradient_line(term_left, term_right, value, left_width=18, right_widt
|
|||||||
bar = format_gradient_bar(value)
|
bar = format_gradient_bar(value)
|
||||||
# Right-align the left term, add the bar, then left-align the right term
|
# Right-align the left term, add the bar, then left-align the right term
|
||||||
line = f"{term_left.rjust(left_width)} < {bar} > {term_right.ljust(right_width)}"
|
line = f"{term_left.rjust(left_width)} < {bar} > {term_right.ljust(right_width)}"
|
||||||
return center_text(line)
|
return center_text(line, center_width)
|
||||||
|
|
||||||
|
|
||||||
def format_metadata_field(field_value, field_name):
|
def format_metadata_field(field_value, field_name):
|
||||||
@@ -74,41 +74,65 @@ def generate_bicorder_text(json_data):
|
|||||||
max_left_width = max(max_left_width, len(term_left))
|
max_left_width = max(max_left_width, len(term_left))
|
||||||
max_right_width = max(max_right_width, len(term_right))
|
max_right_width = max(max_right_width, len(term_right))
|
||||||
|
|
||||||
|
# Calculate the width needed for centering
|
||||||
|
# Gradient line format: "{left_term} < [|||||||||] > {right_term}"
|
||||||
|
# That's: max_left_width + 3 + 11 + 3 + max_right_width
|
||||||
|
gradient_line_width = max_left_width + max_right_width + 17
|
||||||
|
|
||||||
|
# Also check metadata and headers
|
||||||
|
metadata = json_data.get("metadata", {})
|
||||||
|
max_text_width = max(
|
||||||
|
len("Protocol"),
|
||||||
|
len("BICORDER"),
|
||||||
|
len(format_metadata_field(metadata.get("protocol"), "Protocol")),
|
||||||
|
len(format_metadata_field(metadata.get("analyst"), "Analyst")),
|
||||||
|
len(format_metadata_field(metadata.get("standpoint"), "Standpoint")),
|
||||||
|
len(format_metadata_field(metadata.get("timestamp"), "Timestamp")),
|
||||||
|
len("ANALYSIS")
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check diagnostic set names
|
||||||
|
for diagnostic_set in json_data.get("diagnostic", []):
|
||||||
|
set_name = diagnostic_set.get("set_name", "").upper()
|
||||||
|
max_text_width = max(max_text_width, len(set_name))
|
||||||
|
|
||||||
|
# Use the maximum of gradient line width and text width
|
||||||
|
center_width = max(gradient_line_width, max_text_width)
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
lines.append(center_text("Protocol"))
|
lines.append(center_text("Protocol", center_width))
|
||||||
lines.append(center_text("BICORDER"))
|
lines.append(center_text("BICORDER", center_width))
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
# Metadata section
|
# Metadata section
|
||||||
metadata = json_data.get("metadata", {})
|
lines.append(center_text(format_metadata_field(metadata.get("protocol"), "Protocol"), center_width))
|
||||||
lines.append(center_text(format_metadata_field(metadata.get("protocol"), "Protocol")))
|
lines.append(center_text(format_metadata_field(metadata.get("analyst"), "Analyst"), center_width))
|
||||||
lines.append(center_text(format_metadata_field(metadata.get("analyst"), "Analyst")))
|
lines.append(center_text(format_metadata_field(metadata.get("standpoint"), "Standpoint"), center_width))
|
||||||
lines.append(center_text(format_metadata_field(metadata.get("standpoint"), "Standpoint")))
|
lines.append(center_text(format_metadata_field(metadata.get("timestamp"), "Timestamp"), center_width))
|
||||||
lines.append(center_text(format_metadata_field(metadata.get("timestamp"), "Timestamp")))
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
# Diagnostic sections
|
# Diagnostic sections
|
||||||
for diagnostic_set in json_data.get("diagnostic", []):
|
for diagnostic_set in json_data.get("diagnostic", []):
|
||||||
set_name = diagnostic_set.get("set_name", "").upper()
|
set_name = diagnostic_set.get("set_name", "").upper()
|
||||||
lines.append(center_text(set_name))
|
lines.append(center_text(set_name, center_width))
|
||||||
|
|
||||||
for gradient in diagnostic_set.get("gradients", []):
|
for gradient in diagnostic_set.get("gradients", []):
|
||||||
term_left = gradient.get("term_left", "")
|
term_left = gradient.get("term_left", "")
|
||||||
term_right = gradient.get("term_right", "")
|
term_right = gradient.get("term_right", "")
|
||||||
value = gradient.get("value")
|
value = gradient.get("value")
|
||||||
|
|
||||||
lines.append(format_gradient_line(term_left, term_right, value, max_left_width, max_right_width))
|
lines.append(format_gradient_line(term_left, term_right, value, max_left_width, max_right_width, center_width))
|
||||||
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
# Analysis section
|
# Analysis section
|
||||||
lines.append(center_text("ANALYSIS"))
|
lines.append(center_text("ANALYSIS", center_width))
|
||||||
for analysis_item in json_data.get("analysis", []):
|
for analysis_item in json_data.get("analysis", []):
|
||||||
term_left = analysis_item.get("term_left", "")
|
term_left = analysis_item.get("term_left", "")
|
||||||
term_right = analysis_item.get("term_right", "")
|
term_right = analysis_item.get("term_right", "")
|
||||||
value = analysis_item.get("value")
|
value = analysis_item.get("value")
|
||||||
|
|
||||||
lines.append(format_gradient_line(term_left, term_right, value, max_left_width, max_right_width))
|
lines.append(format_gradient_line(term_left, term_right, value, max_left_width, max_right_width, center_width))
|
||||||
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
|
|||||||
69
bicorder.txt
69
bicorder.txt
@@ -1,39 +1,40 @@
|
|||||||
Protocol
|
Protocol
|
||||||
BICORDER
|
BICORDER
|
||||||
|
|
||||||
[Protocol]
|
[Protocol]
|
||||||
[Analyst]
|
[Analyst]
|
||||||
[Standpoint]
|
[Standpoint]
|
||||||
[Timestamp]
|
[Timestamp]
|
||||||
|
|
||||||
DESIGN
|
DESIGN
|
||||||
explicit < [|||||||||] > implicit
|
explicit < [|||||||||] > implicit
|
||||||
precise < [|||||||||] > interpretive
|
precise < [|||||||||] > interpretive
|
||||||
elite < [|||||||||] > vernacular
|
elite < [|||||||||] > vernacular
|
||||||
documenting < [|||||||||] > enabling
|
documenting < [|||||||||] > enabling
|
||||||
static < [|||||||||] > malleable
|
static < [|||||||||] > malleable
|
||||||
technical < [|||||||||] > social
|
technical < [|||||||||] > social
|
||||||
universal < [|||||||||] > particular
|
universal < [|||||||||] > particular
|
||||||
durable < [|||||||||] > ephemeral
|
durable < [|||||||||] > ephemeral
|
||||||
|
|
||||||
ENTANGLEMENT
|
ENTANGLEMENT
|
||||||
macro < [|||||||||] > micro
|
macro < [|||||||||] > micro
|
||||||
sovereign < [|||||||||] > subsidiary
|
sovereign < [|||||||||] > subsidiary
|
||||||
self-enforcing < [|||||||||] > enforced
|
self-enforcing < [|||||||||] > enforced
|
||||||
analyzed < [|||||||||] > embodied
|
abstract < [|||||||||] > embodied
|
||||||
obligatory < [|||||||||] > voluntary
|
obligatory < [|||||||||] > voluntary
|
||||||
flocking < [|||||||||] > swarming
|
flocking < [|||||||||] > swarming
|
||||||
defensible < [|||||||||] > exposed
|
defensible < [|||||||||] > exposed
|
||||||
|
exclusive < [|||||||||] > non-exclusive
|
||||||
|
|
||||||
EXPERIENCE
|
EXPERIENCE
|
||||||
sufficient < [|||||||||] > insufficient
|
sufficient < [|||||||||] > insufficient
|
||||||
crystallized < [|||||||||] > contested
|
crystallized < [|||||||||] > contested
|
||||||
trust-evading < [|||||||||] > trust-inducing
|
trust-evading < [|||||||||] > trust-inducing
|
||||||
predictable < [|||||||||] > emergent
|
predictable < [|||||||||] > emergent
|
||||||
exclusion < [|||||||||] > inclusion
|
exclusion < [|||||||||] > inclusion
|
||||||
Kafka < [|||||||||] > Whitehead
|
Kafka < [|||||||||] > Whitehead
|
||||||
dead < [|||||||||] > alive
|
dead < [|||||||||] > alive
|
||||||
|
|
||||||
ANALYSIS
|
ANALYSIS
|
||||||
hardness < [|||||||||] > softness
|
hardness < [|||||||||] > softness
|
||||||
polarized < [|||||||||] > centrist
|
polarized < [|||||||||] > centrist
|
||||||
|
|||||||
Reference in New Issue
Block a user