def skip_tailspace_of_line(parser): return skip_after(parser, inline_spaces & option(None, match('\n')))
name = name.strip() if description is not None: description = description.strip() return name, description def __str__(self): return self.name + (' : ' + self.description if self.description else '') alphabet = char_range('a', 'z') + char_range('A', 'Z') PROJECT_NAME = (group_chars([one_of(alphabet), many_chars(one_of(alphabet + char_range('0', '9') + '-_'), 1)]) >> lift(str.strip)) PROJECT_NAME = skip_after(PROJECT_NAME, option(None, inline_spaces)) PROJECT_DESC = until_one_of('\n') >> lift(str.strip) PROJECT_LINE = pair(PROJECT_NAME, option(None, match(':') & PROJECT_DESC)) PROJECT_LINE = PROJECT_LINE >> lift(lambda seq: Project(*seq)) PROJECT_LINE = skip_before(inline_spaces, PROJECT_LINE) PROJECT_LINE = skip_tailspace_of_line(PROJECT_LINE) COPYRIGHT_SIGN = match('Copyright (C)') class Span(Record('start', 'end')): @classmethod def prepare(cls, start, end=None): if end is None:
name = name.strip() if description is not None: description = description.strip() return name, description def __str__(self): return self.name + (' : ' + self.description if self.description else '') alphabet = char_range('a', 'z') + char_range('A', 'Z') PROJECT_NAME = (group_chars([ one_of(alphabet), many_chars(one_of(alphabet + char_range('0', '9') + '-_'), 1) ]) >> lift(str.strip)) PROJECT_NAME = skip_after(PROJECT_NAME, option(None, inline_spaces)) PROJECT_DESC = until_one_of('\n') >> lift(str.strip) PROJECT_LINE = pair(PROJECT_NAME, option(None, match(':') & PROJECT_DESC)) PROJECT_LINE = PROJECT_LINE >> lift(lambda seq: Project(*seq)) PROJECT_LINE = skip_before(inline_spaces, PROJECT_LINE) PROJECT_LINE = skip_tailspace_of_line(PROJECT_LINE) COPYRIGHT_SIGN = match('Copyright (C)') class Span(Record('start', 'end')): @classmethod def prepare(cls, start, end=None): if end is None: end = start assert start <= end