Skip to content

Commit

Permalink
Update snet_gate.py
Browse files Browse the repository at this point in the history
current_len and threshold into function
  • Loading branch information
DaddyWesker authored Oct 25, 2024
1 parent 1f0633d commit 290125d
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions python/hyperon/exts/snet_io/snet_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,28 @@ def __call__(self, command_a, *args_a):
return [E(S('Error'), E(S('snet-sdk'), command_a, *args_a),
ValueAtom(f'unknown command {repr(command_a)}'))]

len_threshold = 50
current_len = 0
def pretty_print_atoms(input_atoms):

global len_threshold
global current_len
len_threshold = 50
current_len = 0
def process_svg_atom(atom):
global len_threshold
global current_len
nonlocal len_threshold
nonlocal current_len
repr_atom = repr(atom)
current_len += len(repr_atom)
return repr_atom

def check_len(depth):
global len_threshold
global current_len
nonlocal len_threshold
nonlocal current_len
if current_len > len_threshold:
current_len = 0
return "\n" + "\t" * (depth - 1)
else:
return ""

def process_atom(atom, depth):
global len_threshold
global current_len
nonlocal len_threshold
nonlocal current_len
process_res = ""
metatype = atom.get_metatype()
if metatype == AtomKind.EXPR:
Expand Down

0 comments on commit 290125d

Please sign in to comment.