Example #1
0
def quoted_chars_inline(start, end):
    return quoted(start, many_chars(none_of(end+'\n')), end)
Example #2
0
def quoted_chars_inline(start, end):
    return quoted(start, many_chars(none_of(end + '\n')), end)
Example #3
0

class Copyright(Record('years', 'authors')):
    def __str__(self):
        years = ','.join(str(span) for span in Span.from_set(self.years))
        authors = ', '.join(str(author) for author in self.authors)
        return 'Copyright (C) %s %s' % (years, authors)


COPYRIGHT_LINE = (COPYRIGHT_SIGN & inline_spaces &
                  pair(YEARS, inline_spaces & AUTHORS))
COPYRIGHT_LINE = skip_before(inline_spaces, COPYRIGHT_LINE)
COPYRIGHT_LINE = skip_tailspace_of_line(COPYRIGHT_LINE)
COPYRIGHT_LINE = COPYRIGHT_LINE >> lift(lambda seq: Copyright(*seq))

GENERIC_LINE = skip_after(many_chars(none_of('\n')), match('\n'))


class License(Record('prolog', 'project', 'copyright', 'epilog')):

    def __str__(self):
        return '\n'.join(self.prolog +
                         ['#   ' + str(self.project),
                          '#   ' + str(self.copyright)] +
                         self.epilog + [''])


PROLOG = until_not_but(py_comment(PROJECT_LINE), GENERIC_LINE)
EPILOG = many(GENERIC_LINE)
LICENSE = (group([PROLOG,
                  py_comment(PROJECT_LINE),
Example #4
0

class Copyright(Record('years', 'authors')):
    def __str__(self):
        years = ','.join(str(span) for span in Span.from_set(self.years))
        authors = ', '.join(str(author) for author in self.authors)
        return 'Copyright (C) %s %s' % (years, authors)


COPYRIGHT_LINE = (COPYRIGHT_SIGN & inline_spaces
                  & pair(YEARS, inline_spaces & AUTHORS))
COPYRIGHT_LINE = skip_before(inline_spaces, COPYRIGHT_LINE)
COPYRIGHT_LINE = skip_tailspace_of_line(COPYRIGHT_LINE)
COPYRIGHT_LINE = COPYRIGHT_LINE >> lift(lambda seq: Copyright(*seq))

GENERIC_LINE = skip_after(many_chars(none_of('\n')), match('\n'))


class License(Record('prolog', 'project', 'copyright', 'epilog')):
    def __str__(self):
        return '\n'.join(
            self.prolog +
            ['#   ' + str(self.project), '#   ' + str(self.copyright)] +
            self.epilog + [''])


PROLOG = until_not_but(py_comment(PROJECT_LINE), GENERIC_LINE)
EPILOG = many(GENERIC_LINE)
LICENSE = (group(
    [PROLOG,
     py_comment(PROJECT_LINE),