Removed extra whitespace from ascii_bicorder.py script
This commit is contained in:
@@ -8,7 +8,7 @@ import argparse
|
||||
import sys
|
||||
|
||||
|
||||
def center_text(text, width=80):
|
||||
def center_text(text, width):
|
||||
"""Center text within a given width"""
|
||||
return text.center(width)
|
||||
|
||||
@@ -31,7 +31,7 @@ def format_gradient_bar(value):
|
||||
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.
|
||||
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)
|
||||
# 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)}"
|
||||
return center_text(line)
|
||||
return center_text(line, center_width)
|
||||
|
||||
|
||||
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_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
|
||||
lines.append(center_text("Protocol"))
|
||||
lines.append(center_text("BICORDER"))
|
||||
lines.append(center_text("Protocol", center_width))
|
||||
lines.append(center_text("BICORDER", center_width))
|
||||
lines.append("")
|
||||
|
||||
# Metadata section
|
||||
metadata = json_data.get("metadata", {})
|
||||
lines.append(center_text(format_metadata_field(metadata.get("protocol"), "Protocol")))
|
||||
lines.append(center_text(format_metadata_field(metadata.get("analyst"), "Analyst")))
|
||||
lines.append(center_text(format_metadata_field(metadata.get("standpoint"), "Standpoint")))
|
||||
lines.append(center_text(format_metadata_field(metadata.get("timestamp"), "Timestamp")))
|
||||
lines.append(center_text(format_metadata_field(metadata.get("protocol"), "Protocol"), center_width))
|
||||
lines.append(center_text(format_metadata_field(metadata.get("analyst"), "Analyst"), center_width))
|
||||
lines.append(center_text(format_metadata_field(metadata.get("standpoint"), "Standpoint"), center_width))
|
||||
lines.append(center_text(format_metadata_field(metadata.get("timestamp"), "Timestamp"), center_width))
|
||||
lines.append("")
|
||||
|
||||
# Diagnostic sections
|
||||
for diagnostic_set in json_data.get("diagnostic", []):
|
||||
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", []):
|
||||
term_left = gradient.get("term_left", "")
|
||||
term_right = gradient.get("term_right", "")
|
||||
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("")
|
||||
|
||||
# Analysis section
|
||||
lines.append(center_text("ANALYSIS"))
|
||||
lines.append(center_text("ANALYSIS", center_width))
|
||||
for analysis_item in json_data.get("analysis", []):
|
||||
term_left = analysis_item.get("term_left", "")
|
||||
term_right = analysis_item.get("term_right", "")
|
||||
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("")
|
||||
|
||||
|
||||
69
bicorder.txt
69
bicorder.txt
@@ -1,39 +1,40 @@
|
||||
Protocol
|
||||
BICORDER
|
||||
Protocol
|
||||
BICORDER
|
||||
|
||||
[Protocol]
|
||||
[Analyst]
|
||||
[Standpoint]
|
||||
[Timestamp]
|
||||
[Protocol]
|
||||
[Analyst]
|
||||
[Standpoint]
|
||||
[Timestamp]
|
||||
|
||||
DESIGN
|
||||
explicit < [|||||||||] > implicit
|
||||
precise < [|||||||||] > interpretive
|
||||
elite < [|||||||||] > vernacular
|
||||
documenting < [|||||||||] > enabling
|
||||
static < [|||||||||] > malleable
|
||||
technical < [|||||||||] > social
|
||||
universal < [|||||||||] > particular
|
||||
durable < [|||||||||] > ephemeral
|
||||
DESIGN
|
||||
explicit < [|||||||||] > implicit
|
||||
precise < [|||||||||] > interpretive
|
||||
elite < [|||||||||] > vernacular
|
||||
documenting < [|||||||||] > enabling
|
||||
static < [|||||||||] > malleable
|
||||
technical < [|||||||||] > social
|
||||
universal < [|||||||||] > particular
|
||||
durable < [|||||||||] > ephemeral
|
||||
|
||||
ENTANGLEMENT
|
||||
macro < [|||||||||] > micro
|
||||
sovereign < [|||||||||] > subsidiary
|
||||
self-enforcing < [|||||||||] > enforced
|
||||
analyzed < [|||||||||] > embodied
|
||||
obligatory < [|||||||||] > voluntary
|
||||
flocking < [|||||||||] > swarming
|
||||
defensible < [|||||||||] > exposed
|
||||
ENTANGLEMENT
|
||||
macro < [|||||||||] > micro
|
||||
sovereign < [|||||||||] > subsidiary
|
||||
self-enforcing < [|||||||||] > enforced
|
||||
abstract < [|||||||||] > embodied
|
||||
obligatory < [|||||||||] > voluntary
|
||||
flocking < [|||||||||] > swarming
|
||||
defensible < [|||||||||] > exposed
|
||||
exclusive < [|||||||||] > non-exclusive
|
||||
|
||||
EXPERIENCE
|
||||
sufficient < [|||||||||] > insufficient
|
||||
crystallized < [|||||||||] > contested
|
||||
trust-evading < [|||||||||] > trust-inducing
|
||||
predictable < [|||||||||] > emergent
|
||||
exclusion < [|||||||||] > inclusion
|
||||
Kafka < [|||||||||] > Whitehead
|
||||
dead < [|||||||||] > alive
|
||||
EXPERIENCE
|
||||
sufficient < [|||||||||] > insufficient
|
||||
crystallized < [|||||||||] > contested
|
||||
trust-evading < [|||||||||] > trust-inducing
|
||||
predictable < [|||||||||] > emergent
|
||||
exclusion < [|||||||||] > inclusion
|
||||
Kafka < [|||||||||] > Whitehead
|
||||
dead < [|||||||||] > alive
|
||||
|
||||
ANALYSIS
|
||||
hardness < [|||||||||] > softness
|
||||
polarized < [|||||||||] > centrist
|
||||
ANALYSIS
|
||||
hardness < [|||||||||] > softness
|
||||
polarized < [|||||||||] > centrist
|
||||
|
||||
Reference in New Issue
Block a user