mirror of https://gitlab.com/aitzol76/macBank
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from io import open
|
|
import json
|
|
|
|
def file_parser(format, file):
|
|
|
|
string = ""
|
|
if format=="md":
|
|
|
|
with open(file, 'r') as myfile:
|
|
#data = myfile.read()
|
|
line=myfile.readlines()
|
|
myfile.close()
|
|
for i in range(len(line)):
|
|
if (line[i][0] == "*") and (line[i][-2] == "*"):
|
|
titleLine = "\n<span size='x-large'>"+line[i][2:][:-3]+"</span>\n"
|
|
string=string+titleLine
|
|
|
|
elif (line[i][0]!="\n") and (line[i][0]!=" "):
|
|
regularLine = line[i]
|
|
string = string + regularLine
|
|
|
|
return string
|
|
|
|
elif format=="json":
|
|
|
|
with open(file) as f:
|
|
jsonData = json.load(f)
|
|
|
|
string = "<span foreground='blue' size='x-large'>" + jsonData['name'] + \
|
|
"</span>\n\nver: " + jsonData['version'] + \
|
|
"\nLicense: " + jsonData['license'] + "\n" + jsonData['author']
|
|
|
|
return string
|
|
|
|
def manifest(key):
|
|
|
|
with open("manifest.json") as f:
|
|
jsonData = json.load(f)
|
|
|
|
value = jsonData[key]
|
|
return value
|