inflab4/extra4.py
2023-07-21 01:08:19 +03:00

37 lines
955 B
Python

from enum import Enum
from main_task import XmlParser
class Markup(Enum):
CSV = 'csv'
TSV = 'tsv'
PROTO3 = 'proto3'
WML = 'wml'
def other_markups(parser: XmlParser, lang: Markup):
if lang == Markup.CSV:
parser.load_csv()
file = open('schedule.csv', 'w', encoding='utf8')
file.writelines(parser.get_csv())
print(parser.get_csv())
elif lang == Markup.TSV:
parser.load_tsv()
file = open('schedule.tsv', 'w', encoding='utf8')
file.writelines(parser.get_tsv())
print(parser.get_tsv())
elif lang == Markup.PROTO3:
pass
elif lang == Markup.WML:
pass
else:
raise ValueError('Unknown markup language ' + lang.value)
if __name__ == "__main__":
schedule = open('schedule.xml', encoding='utf8')
contents = schedule.read()
xml_parser = XmlParser()
xml_parser.parse_xml(contents)
other_markups(xml_parser, Markup.CSV)