diff options
author | Dmitry Shachnev <mitya57@gmail.com> | 2016-11-13 19:11:28 +0300 |
---|---|---|
committer | Dmitry Shachnev <mitya57@gmail.com> | 2016-11-13 19:15:41 +0300 |
commit | 2d622533120528bacde66e46b806ca79da769797 (patch) | |
tree | 99af418b7ce58de557c69af030a73363df406156 | |
parent | 148a6eab2128ad884e65f7cdb0fdd9230fbad2cf (diff) | |
parent | ef45e94516b043e7c0b28ef4792af8535c32fc68 (diff) |
Merge upstream release 0.3.5
-rw-r--r-- | PKG-INFO | 2 | ||||
-rw-r--r-- | changelog.egg-info/PKG-INFO | 2 | ||||
-rw-r--r-- | changelog.egg-info/SOURCES.txt | 4 | ||||
-rw-r--r-- | changelog/__init__.py | 2 | ||||
-rw-r--r-- | changelog/changelog.py | 3 | ||||
-rw-r--r-- | debian/.git-dpm | 14 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | util/changelog_to_rst.py | 195 | ||||
-rw-r--r-- | util/trac_to_rst.py | 261 |
9 files changed, 19 insertions, 470 deletions
@@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: changelog -Version: 0.3.4 +Version: 0.3.5 Summary: Provides simple Sphinx markup to render changelog displays. Home-page: http://bitbucket.org/zzzeek/changelog Author: Mike Bayer diff --git a/changelog.egg-info/PKG-INFO b/changelog.egg-info/PKG-INFO index 6a23200..c9dda62 100644 --- a/changelog.egg-info/PKG-INFO +++ b/changelog.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: changelog -Version: 0.3.4 +Version: 0.3.5 Summary: Provides simple Sphinx markup to render changelog displays. Home-page: http://bitbucket.org/zzzeek/changelog Author: Mike Bayer diff --git a/changelog.egg-info/SOURCES.txt b/changelog.egg-info/SOURCES.txt index 88b0f1e..1d986d2 100644 --- a/changelog.egg-info/SOURCES.txt +++ b/changelog.egg-info/SOURCES.txt @@ -9,6 +9,4 @@ changelog.egg-info/PKG-INFO changelog.egg-info/SOURCES.txt changelog.egg-info/dependency_links.txt changelog.egg-info/not-zip-safe -changelog.egg-info/top_level.txt -util/changelog_to_rst.py -util/trac_to_rst.py
\ No newline at end of file +changelog.egg-info/top_level.txt
\ No newline at end of file diff --git a/changelog/__init__.py b/changelog/__init__.py index 274f9c7..e85da83 100644 --- a/changelog/__init__.py +++ b/changelog/__init__.py @@ -1,3 +1,3 @@ -__version__ = '0.3.4' +__version__ = '0.3.5' from .changelog import setup
\ No newline at end of file diff --git a/changelog/changelog.py b/changelog/changelog.py index b1b7018..d153571 100644 --- a/changelog/changelog.py +++ b/changelog/changelog.py @@ -35,6 +35,9 @@ def _parse_content(content): if m: attrname, value = m.group(1, 2) d[attrname] = value or '' + elif idx == 1 and line: + # accomodate a unique value on the edge of .. change:: + continue else: break d["text"] = content[idx:] diff --git a/debian/.git-dpm b/debian/.git-dpm index ae1bc69..22ef58f 100644 --- a/debian/.git-dpm +++ b/debian/.git-dpm @@ -1,11 +1,11 @@ # see git-dpm(1) from git-dpm package -ecffefa7a5a214543a109a1b888e32e090bcc58d -ecffefa7a5a214543a109a1b888e32e090bcc58d -ecffefa7a5a214543a109a1b888e32e090bcc58d -ecffefa7a5a214543a109a1b888e32e090bcc58d -python-changelog_0.3.4.orig.tar.gz -ed8192b12fdc7b1649467cd652b913136a979104 -9985 +ef45e94516b043e7c0b28ef4792af8535c32fc68 +ef45e94516b043e7c0b28ef4792af8535c32fc68 +ef45e94516b043e7c0b28ef4792af8535c32fc68 +ef45e94516b043e7c0b28ef4792af8535c32fc68 +python-changelog_0.3.5.orig.tar.gz +c1026379bd5af884013aece00f749c50d2ac5f56 +7003 debianTag="debian/%e%v" patchedTag="patched/%e%v" upstreamTag="upstream/%e%u" diff --git a/debian/changelog b/debian/changelog index cc0cdf4..c975006 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,11 @@ -python-changelog (0.3.4-3) UNRELEASED; urgency=medium +python-changelog (0.3.5-1) UNRELEASED; urgency=medium + [ Ondřej Nový ] * Fixed VCS URL (https) + [ Dmitry Shachnev ] + * New upstream bugfix release. + -- Ondřej Nový <novy@ondrej.org> Tue, 29 Mar 2016 22:08:40 +0200 python-changelog (0.3.4-2) unstable; urgency=medium diff --git a/util/changelog_to_rst.py b/util/changelog_to_rst.py deleted file mode 100644 index 1bc0d7c..0000000 --- a/util/changelog_to_rst.py +++ /dev/null @@ -1,195 +0,0 @@ -"""Parses a SQLAlchemy-style CHANGES file into changelog format. - -This is pretty specific to the files changelog was created for. - -""" -import sys -import re -import textwrap - -# this is a history file generated from "hg log". -# it's parsed for "tag: <sometag>" in order to get the dates -# for releases. It relates a tag to a release in CHANGELOG -# using the form tag_X_Y_Z -> X.Y.Z. -TAGFILE = "all_my_tags.txt" - -def read_dates(): - lines = open(TAGFILE).readlines() - tags = {} - for line in lines: - if line.startswith("changeset:"): - tag = None - elif line.startswith("tag:"): - tag = re.match(r'tag:\s+(.+)', line).group(1) - elif line.startswith("date:") and tag is not None: - date, year = re.match(r'date:\s+(\w+ \w+ \d+) \d+:\d+:\d+ (\d+)', line).group(1, 2) - - digits = re.findall(r"(?:^|_)(\d+)", tag) - extra = re.match(".*?(beta\d|rc\d|[a-z]\d)$", tag) - if extra: - extra = extra.group(1) - else: - extra = "" - - if len(digits) == 2 and extra: - versions = ".".join(digits) + extra, \ - ".".join(digits + ["0"]) + extra - else: - versions = (".".join(digits) + extra,) - - for version in versions: - tags[version] = "%s %s" % (date, year) - return tags - -def raw_blocks(fname): - lines = open(fname).readlines() - - version_re = re.compile(r''' - ( - ^\d+\.\d+ (?: \.\d+ )? - - (?:beta\d|rc\d|[a-z]\d?)? - ) - - \s*(\(.*\))?$''', re.X) - - bullet_re = re.compile(r''' - (\s{0,5})-\s(.*) - ''', re.X) - - normal = 0 - in_bullet = 1 - state = normal - - while lines: - line = lines.pop(0) - if state == normal: - m = version_re.match(line) - if m: - yield "version", m.group(1) - continue - - m = bullet_re.match(line) - if m: - state = in_bullet - bullet_indent = len(m.group(1)) - bullet_lines = [(" " * (bullet_indent + 2)) + m.group(2) + "\n"] - continue - - yield "ignored", line - - elif state == in_bullet: - another_bullet = bullet_re.match(line) - version_number = version_re.match(line) - - if \ - line == "\n" or \ - ( - not another_bullet and not version_number \ - and ( - ( - bullet_indent and line.startswith(" " * bullet_indent) - ) or not bullet_indent - ) - ): - bullet_lines.append(line) - else: - yield "bullet", textwrap.dedent("".join(bullet_lines)) - - state = normal - if another_bullet or version_number: - lines.insert(0, line) - continue - -def tagged(elements): - current_version = None - current_tags = set() - for type_, content in elements: - if type_ == 'version': - current_tags = set() - current_version = content - elif type_ == 'bullet': - if len(content.split(' ')) < 3 and "ticket" not in content: - current_tags = set([re.sub(r'[\s\:]', '', c.lower()) for c in content.split(' ')]) - else: - in_content_tags = set() - tickets = set() - def tag(m): - tag_content = m.group(1) - t_r = re.match(r'(?:ticket:|#)(\d+)', tag_content) - if t_r: - tickets.add(t_r.group(1)) - else: - in_content_tags.add(tag_content) - - content = re.sub(r'(?:^|\s)\[(.+?)\]', tag, content) - - content = re.sub(r'\s(#\d+)', tag, content) - - yield { - 'version': current_version, - 'tags': ", ".join(current_tags.union(in_content_tags)), - 'tickets': ", ".join(tickets), - 'content': content - } - -def emit_rst(records): - current_version = None - versions = read_dates() - - current_major_version = None - current_output_file = None - - for rec in records: - indented_content = re.compile(r'^', re.M).sub(' ', rec['content'].strip()) - - if indented_content.endswith(","): - indented_content = indented_content[0:-1] + "." - - if rec['version'] != current_version: - current_version = rec['version'] - released = versions.get(current_version, '') - - major_version = current_version[0:3] - if major_version != current_major_version: - if current_output_file: - current_output_file.close() - current_major_version = major_version - cfile = "changelog_%s.rst" % major_version.replace(".", "") - print "writing %s" % cfile - current_output_file = open(cfile, 'w') - current_output_file.write(""" -============== -%s Changelog -============== - - """ % major_version) - - - - current_output_file.write( -""" -.. changelog:: - :version: %s - :released: %s -""" % (current_version, released) -) - current_output_file.write( -""" - .. change:: - :tags: %s - :tickets: %s - -%s -""" % ( - rec['tags'], - rec['tickets'], - indented_content - ) -) - - -if __name__ == '__main__': - fname = sys.argv[1] - - emit_rst(tagged(raw_blocks(fname)))
\ No newline at end of file diff --git a/util/trac_to_rst.py b/util/trac_to_rst.py deleted file mode 100644 index 05c90ca..0000000 --- a/util/trac_to_rst.py +++ /dev/null @@ -1,261 +0,0 @@ -"""Parses a trac wiki page into rst.""" - -import sys -import re -import textwrap - - -def structure(fname): - lines = open(fname).readlines() - - plain = 0 - bullet = 1 - state = plain - - current_chunk = [] - current_indent = "" - - while lines: - line = lines.pop(0).rstrip() - - line_indent = re.match(r'^(\s*)', line) - line_indent = len(line_indent.group(1)) - - bullet_m = re.match(r'^(\s*)\* (.*)', line) - if bullet_m: - if current_chunk: - yield { - "bullet": state == bullet, - "indent": len(current_indent) if state == bullet else 0, - "lines": current_chunk - } - current_chunk = [] - - current_indent = bullet_m.group(1) - line = bullet_m.group(2) - state = bullet - current_chunk.append(line) - elif state == bullet: - if not line: - current_chunk.append(line) - elif ( - line - and ( - # line indent is less - line_indent < len(current_indent) - or - - # or no indent and previous line was blank - (not line_indent and len(current_indent) == 0 and current_chunk and not current_chunk[-1]) - ) - ): - yield { - "bullet": True, - "indent": len(current_indent), - "lines": current_chunk - } - current_chunk = [] - state = plain - current_chunk.append(line) - else: - current_chunk.append(line[len(current_indent):]) - #elif not line: - # if current_chunk: - # yield { - # "bullet": state == bullet, - # "indent": len(current_indent) if state == bullet else 0, - # "lines": current_chunk - # } - # current_chunk = [] - else: - current_chunk.append(line) - - yield { - "bullet": state == bullet, - "indent": len(current_indent) if state == bullet else 0, - "lines": current_chunk - } - -def bullet_depth(recs): - bullet_indent = 0 - rec_indent = 0 - for rec in recs: - - if rec['bullet']: - if bullet_indent: - if rec['indent'] > rec_indent: - bullet_indent += 1 - elif rec['indent'] < rec_indent: - bullet_indent -= 1 - else: - bullet_indent = 1 - else: - bullet_indent = 0 - - rec_indent = rec['indent'] - - rec['bullet_depth'] = bullet_indent - yield rec - -def code(recs): - for rec in recs: - code = False - current_chunk = [] - - asterisk = rec['bullet'] - - for line in rec["lines"]: - - if re.match(r'^\s*{{{', line): - code = True - - if current_chunk: - yield { - 'bullet_depth': rec['bullet_depth'], - 'lines': current_chunk, - 'code': False, - 'asterisk': asterisk - } - asterisk = False - current_chunk = [] - - - elif re.match(r'^\s*}}}', line): - code = False - if current_chunk: - yield { - 'bullet_depth': rec['bullet_depth'], - 'lines': current_chunk, - 'code': True - } - current_chunk = [] - - elif code: - if not re.match(r'^\s*#!', line): - current_chunk.append(line) - elif not line: - if current_chunk: - yield { - 'bullet_depth': rec['bullet_depth'], - 'lines': current_chunk, - 'code': False, - 'asterisk': asterisk - } - asterisk = False - current_chunk = [] - else: - if line == "----" or \ - line.startswith("[[PageOutline"): - continue - line = re.sub(r'(\*\*?\w+)(?!\*)\b', lambda m: "\\%s" % m.group(1), line) - line = re.sub(r'\!(\w+)\b', lambda m: m.group(1), line) - line = re.sub(r"`(.+?)`", lambda m: "``%s``" % m.group(1), line) - line = re.sub(r"'''(.+?)'''", lambda m: "**%s**" % m.group(1).replace("``", ""), line) - line = re.sub(r"''(.+?)'", lambda m: "*%s*" % m.group(1).replace("``", ""), line) - line = re.sub(r'\[(http://\S+) (.*)\]', - lambda m: "`%s <%s>`_" % (m.group(2), m.group(1)), - line - ) - line = re.sub(r'#(\d+)', lambda m: ":ticket:`%s`" % m.group(1), line) - - if line.startswith("=") and line.endswith("="): - if current_chunk: - yield { - 'bullet_depth': rec['bullet_depth'], - 'lines': current_chunk, - 'code': False, - 'asterisk': asterisk, - } - asterisk = False - current_chunk = [] - - header_lines = output_header(line) - yield { - 'bullet_depth': 0, - 'lines': header_lines, - 'code': False, - 'asterisk': False, - 'header': True - } - else: - if line or current_chunk: - current_chunk.append(line) - - if current_chunk: - yield { - 'bullet_depth': rec['bullet_depth'], - 'lines': current_chunk, - 'code': False, - 'asterisk': asterisk - } - - -def render(recs): - for rec in recs: - bullet_depth = rec['bullet_depth'] - - bullet_indent = " " * bullet_depth - - if rec.get('header', False): - print "\n".join(rec['lines']) - print "" - elif rec['code']: - text = "\n".join( - bullet_indent + " " + line - for line in rec['lines'] - ) - print bullet_indent + "::\n" - print text - - print "" - else: - text = textwrap.dedent("\n".join(rec['lines'])) - lines = textwrap.wrap(text, 60 - (2 * bullet_depth)) - - if rec['asterisk']: - line = lines.pop(0) - print (" " * (bullet_depth - 1)) + "* " + line - - print "\n".join( - [bullet_indent + line for line in lines] - ) - - print "" - -def remove_double_blanks(lines): - blank = 0 - for line in lines: - for subline in line.split("\n"): - if not subline: - blank += 1 - else: - blank = 0 - if blank < 2: - yield subline - -def output_header(line): - line = line.strip() - m = re.match(r'^(=+) (.*?) =+$', line) - depth = len(m.group(1)) - if depth == 1: - return [ - "=" * len(m.group(2)), - m.group(2), - "=" * len(m.group(2)) - ] - char = { - 2: "=", - 3: "-", - 4: "^" - }[depth] - return [ - m.group(2), - char * len(m.group(2)) - ] - -if __name__ == '__main__': - fname = sys.argv[1] - -# for rec in structure(fname): -# print rec - render(code(bullet_depth(structure(fname)))) |