def parse(self, content): root = RootNode() lines = [l.strip() for l in content.splitlines() if l] comment = None for line in lines: if line.startswith('#'): comment = '\n'.join([comment, line]) if comment else line[1:] continue elif line.startswith('@'): special, command = line.split(' ', 1) node = Node('special_task', comment=comment) node.append(PropertyNode('special', special)) node.append(PropertyNode('command', command)) else: split_line = line.split(' ', 5) if len(split_line) <= 3 and '=' in line: name, value = [n.strip() for n in line.split('=')] if not name: continue node = Node('env_setting', comment=comment) node.append(PropertyNode('name', name)) node.append(PropertyNode('value', value)) elif len(split_line) == 6: node = Node('normal_task', comment=comment) node.append(PropertyNode('minute', split_line[0])) node.append(PropertyNode('hour', split_line[1])) node.append(PropertyNode('day_of_month', split_line[2])) node.append(PropertyNode('month', split_line[3])) node.append(PropertyNode('day_of_week', split_line[4])) node.append(PropertyNode('command', split_line[5])) else: continue root.append(node) comment = None root.comment = comment return root