Untitled
unknown
plain_text
a year ago
1.4 kB
5
Indexable
Never
def get_sections(self): line: str sections = {} section_name: str for line in self.__content: if line[0] != " ": marker = line.find(':') lines = [] if line[marker+1:].lstrip() != "": lines.append(line[marker+1:].lstrip()) section_name = line[0:marker] sections[section_name] = lines else: sections[section_name].append(line.lstrip()) # print(sections) return sections def get_section_data(self, sections: dict): for key in sections: print(key) if FileReader.is_table(sections[key]): print("table") #TODO parse table # else: # if line.find(':') != -1: def is_table(section: list): flag = False for line in section: if line.strip(" -") == "": # checking if section data is table flag = True return flag # if ':' present? # if first ':' part of time? # TODO return data in tuple # else # TODO return data in dictionary with ':' as separator # else # if '=' present? # TODO return data in dictionary with '=' as separator # else # if ',' present? # TODO return data in tuple with ',' as separator # else # TODO return data in tuple