Add start of config parser
This commit is contained in:
parent
d87b1ff110
commit
3072753159
29
main.py
29
main.py
|
@ -20,12 +20,28 @@ currentDirectory = initDirectory
|
||||||
argList = ["", ""]
|
argList = ["", ""]
|
||||||
|
|
||||||
# Start work on checking whether a config file exists
|
# Start work on checking whether a config file exists
|
||||||
if os.path.isfile(expanduser("~") + "/.config/mash/mash.conf") == True:
|
if os.path.isfile(expanduser("~") + "/.config/mash/mash.conf") == False:
|
||||||
configFile = open(expanduser("~") + "/.config/mash/mash.conf")
|
|
||||||
else:
|
|
||||||
print("Config file does not exist. Copying default file to ~/.config/mash/mash.conf")
|
print("Config file does not exist. Copying default file to ~/.config/mash/mash.conf")
|
||||||
shutil.copyfile("/etc/mash/mash.conf", (expanduser("~") + "/.config/mash/mash.conf"))
|
shutil.copyfile("/etc/mash/mash.conf", (expanduser("~") + "/.config/mash/mash.conf"))
|
||||||
|
|
||||||
|
# Parse config file, adding variables
|
||||||
|
configFileFile = open((expanduser("~") + "/.config/mash/mash.conf"))
|
||||||
|
configFile = configFileFile.read()
|
||||||
|
|
||||||
|
confArgNumber = 0
|
||||||
|
confArgList = ["", ""]
|
||||||
|
|
||||||
|
for line in configFile:
|
||||||
|
for letter in line:
|
||||||
|
if letter == ' ':
|
||||||
|
confArgNumber = confArgNumber + 1
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
confArgList[confArgNumber] = confArgList[confArgNumber] + letter
|
||||||
|
except Exception:
|
||||||
|
confArgList.append(letter)
|
||||||
|
print(confArgList)
|
||||||
|
|
||||||
# Write the time to the history file
|
# Write the time to the history file
|
||||||
historyFile = open((expanduser("~") + "/.history.mash"), "a")
|
historyFile = open((expanduser("~") + "/.history.mash"), "a")
|
||||||
historyFile.write("\n")
|
historyFile.write("\n")
|
||||||
|
@ -60,6 +76,10 @@ try:
|
||||||
for word in argList:
|
for word in argList:
|
||||||
if word == "&&":
|
if word == "&&":
|
||||||
print("This hasnt been implemented yet hahahahah")
|
print("This hasnt been implemented yet hahahahah")
|
||||||
|
elif word == "&":
|
||||||
|
print("This hasnt been implemented yet heheheheh")
|
||||||
|
elif word == "|":
|
||||||
|
print("What are you? A pipe master? We dont like those people here")
|
||||||
|
|
||||||
# Built in commands section
|
# Built in commands section
|
||||||
if argList[0] == "help":
|
if argList[0] == "help":
|
||||||
|
@ -109,7 +129,8 @@ try:
|
||||||
print(historyReadFile.read())
|
print(historyReadFile.read())
|
||||||
elif argList[0] == "mtime":
|
elif argList[0] == "mtime":
|
||||||
print(datetime.now())
|
print(datetime.now())
|
||||||
|
elif argList[0] == "printconf":
|
||||||
|
print(configFile)
|
||||||
# If a built in command isn't what you wanted, run a new subprocess.
|
# If a built in command isn't what you wanted, run a new subprocess.
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user