From fc390b3a146dd30aa6634c410964b4c1fc3bd902 Mon Sep 17 00:00:00 2001 From: Deven Blake Date: Sun, 30 May 2021 20:15:17 -0400 Subject: [PATCH] improve printing --- it/src/buffer.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/it/src/buffer.py b/it/src/buffer.py index 11533e8..72da5f2 100755 --- a/it/src/buffer.py +++ b/it/src/buffer.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 import importlib -import sys -from parse_command import parse_command class Buffer: # all the information about the current file def carat(self): @@ -46,20 +44,30 @@ class Buffer: # all the information about the current file return self.content.count(self.delimiter) def __init__(self): - self.content = '' # content of the file - self.delimiter = '\n' # line delimiter - self.filename = "" # name of where we'll save the file - self.index = 0 # indexing of dot + self.content = '' # content of the file + self.delimiter = '\n' # line delimiter + self.filename = "" # name of where we'll save the file + self.index = 0 # indexing of dot self.dot = self.index - 1 # invalid position to start - self.modules = {} - self.saved = 1 # bool that says whether or not we have saved the file + self.modules = {} # see it.py + self.saved = 1 # is buffer saved? def main(buffer, command): if len(command) == 1: - command = command + list(vars(buffer)) + command += list(vars(buffer)) for attrib in command[1:]: if attrib in list(vars(buffer)): - print("%s:\t%s" % (attrib, vars(buffer)[attrib])) + val = vars(buffer)[attrib] + # so self.modules shows as + if not(type(val) is int or type(val) is str): + val = str(type(val)) + # special case usually for self.delimiter + elif val == "\n": + val = "" + # only affects it if type(val) is int + else: + val = str(val) + print("%s:\t%s" % (attrib, val)) else: - print("No attribute: %s" % attrib) + print("No attribute: %s\n" % attrib, end='') return buffer