1
0

improve printing

This commit is contained in:
Deven Blake 2021-05-30 20:15:17 -04:00
parent e1c2f01256
commit fc390b3a14

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import importlib import importlib
import sys
from parse_command import parse_command
class Buffer: # all the information about the current file class Buffer: # all the information about the current file
def carat(self): def carat(self):
@ -46,20 +44,30 @@ class Buffer: # all the information about the current file
return self.content.count(self.delimiter) return self.content.count(self.delimiter)
def __init__(self): def __init__(self):
self.content = '' # content of the file self.content = '' # content of the file
self.delimiter = '\n' # line delimiter self.delimiter = '\n' # line delimiter
self.filename = "" # name of where we'll save the file self.filename = "" # name of where we'll save the file
self.index = 0 # indexing of dot self.index = 0 # indexing of dot
self.dot = self.index - 1 # invalid position to start self.dot = self.index - 1 # invalid position to start
self.modules = {} self.modules = {} # see it.py
self.saved = 1 # bool that says whether or not we have saved the file self.saved = 1 # is buffer saved?
def main(buffer, command): def main(buffer, command):
if len(command) == 1: if len(command) == 1:
command = command + list(vars(buffer)) command += list(vars(buffer))
for attrib in command[1:]: for attrib in command[1:]:
if attrib in list(vars(buffer)): if attrib in list(vars(buffer)):
print("%s:\t%s" % (attrib, vars(buffer)[attrib])) val = vars(buffer)[attrib]
# so self.modules shows as <class 'dict'>
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 = "<newline>"
# only affects it if type(val) is int
else:
val = str(val)
print("%s:\t%s" % (attrib, val))
else: else:
print("No attribute: %s" % attrib) print("No attribute: %s\n" % attrib, end='')
return buffer return buffer