1
0

fix bugs, start work on env vars

This commit is contained in:
Deven Blake 2021-05-31 23:18:42 -04:00
parent b03ff6813c
commit 39c3606255
3 changed files with 16 additions and 5 deletions

View File

@ -10,7 +10,7 @@ class Buffer: # all the information about the current file
# Rather than get the content as it's presented in the buffer object # Rather than get the content as it's presented in the buffer object
# (as one big string), get it as a list. # (as one big string), get it as a list.
def content_list(self): def content_list(self):
return self.content.split(self.delimiter) return self.content.rstrip(self.delimiter).split(self.delimiter)
# Build a string with the same format as the buffer.content and set the # Build a string with the same format as the buffer.content and set the
# buffer.content to that string, from the kind of list output by # buffer.content to that string, from the kind of list output by
@ -44,8 +44,9 @@ 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.env = {} # configuration dictionary
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

10
it/src/config.py Normal file
View File

@ -0,0 +1,10 @@
def main(buffer, command):
# hard-coded for consistency across multiple people's configs
config_delimiter = "\t"
for i in range(len(buffer.content_list())):
line = buffer.content_list()[i].split(config_delimiter)
if len(line) != 2:
print("%s: %d: Bad column quantity" % (command[0], i+buffer.index))
else:
buffer.env[line[0]] = line[1]
return buffer

View File

@ -11,7 +11,7 @@ def main(buffer, supplied_command):
if supplied_command != [] and len(supplied_command) > 1: if supplied_command != [] and len(supplied_command) > 1:
command = supplied_command[1:] command = supplied_command[1:]
else: else:
command = get_command() command = get_command("")
while True: while True:
# EOFError in get_command(); ^D # EOFError in get_command(); ^D
@ -26,7 +26,7 @@ def main(buffer, supplied_command):
if type(buffer) is int: if type(buffer) is int:
break break
command = get_command() command = get_command("")
return buffer return buffer