mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
Merge remote-tracking branch 'tor-github/pr/1589'
This commit is contained in:
commit
5d4005abfd
3 changed files with 30 additions and 25 deletions
3
changes/ticket32704
Normal file
3
changes/ticket32704
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
o Minor features (release tools):
|
||||||
|
- Port our changelog formatting and sorting tools to Python 3.
|
||||||
|
Closes ticket 32704.
|
|
@ -9,6 +9,7 @@
|
||||||
# To run it, pipe a section of the changelog (starting with "Changes
|
# To run it, pipe a section of the changelog (starting with "Changes
|
||||||
# in Tor 0.x.y.z-alpha" through the script.)
|
# in Tor 0.x.y.z-alpha" through the script.)
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -190,7 +191,7 @@ def body_parser(line):
|
||||||
elif re.match(r'^\s+\S', line):
|
elif re.match(r'^\s+\S', line):
|
||||||
return TP_HEADTEXT
|
return TP_HEADTEXT
|
||||||
else:
|
else:
|
||||||
print "Weird line %r"%line
|
print("Weird line %r"%line, file=sys.stderr)
|
||||||
|
|
||||||
def clean_head(head):
|
def clean_head(head):
|
||||||
return head
|
return head
|
||||||
|
@ -198,7 +199,7 @@ def clean_head(head):
|
||||||
def head_score(s):
|
def head_score(s):
|
||||||
m = re.match(r'^ +o (.*)', s)
|
m = re.match(r'^ +o (.*)', s)
|
||||||
if not m:
|
if not m:
|
||||||
print >>sys.stderr, "Can't score %r"%s
|
print("Can't score %r"%s, file=sys.stderr)
|
||||||
return 99999
|
return 99999
|
||||||
lw = m.group(1).lower()
|
lw = m.group(1).lower()
|
||||||
if lw.startswith("security") and "feature" not in lw:
|
if lw.startswith("security") and "feature" not in lw:
|
||||||
|
@ -291,7 +292,7 @@ class ChangeLog(object):
|
||||||
def lint_head(self, line, head):
|
def lint_head(self, line, head):
|
||||||
m = re.match(r'^ *o ([^\(]+)((?:\([^\)]+\))?):', head)
|
m = re.match(r'^ *o ([^\(]+)((?:\([^\)]+\))?):', head)
|
||||||
if not m:
|
if not m:
|
||||||
print >>sys.stderr, "Weird header format on line %s"%line
|
print("Weird header format on line %s"%line, file=sys.stderr)
|
||||||
|
|
||||||
def lint_item(self, line, grafs, head_type):
|
def lint_item(self, line, grafs, head_type):
|
||||||
pass
|
pass
|
||||||
|
@ -306,7 +307,7 @@ class ChangeLog(object):
|
||||||
def dumpGraf(self,par,indent1,indent2=-1):
|
def dumpGraf(self,par,indent1,indent2=-1):
|
||||||
if not self.wrapText:
|
if not self.wrapText:
|
||||||
for line in par:
|
for line in par:
|
||||||
print line
|
print(line)
|
||||||
return
|
return
|
||||||
|
|
||||||
if indent2 == -1:
|
if indent2 == -1:
|
||||||
|
@ -320,17 +321,17 @@ class ChangeLog(object):
|
||||||
|
|
||||||
def dumpPreheader(self, graf):
|
def dumpPreheader(self, graf):
|
||||||
self.dumpGraf(graf, 0)
|
self.dumpGraf(graf, 0)
|
||||||
print
|
print()
|
||||||
|
|
||||||
def dumpMainhead(self, head):
|
def dumpMainhead(self, head):
|
||||||
print head
|
print(head)
|
||||||
|
|
||||||
def dumpHeadGraf(self, graf):
|
def dumpHeadGraf(self, graf):
|
||||||
self.dumpGraf(graf, 2)
|
self.dumpGraf(graf, 2)
|
||||||
print
|
print()
|
||||||
|
|
||||||
def dumpSectionHeader(self, header):
|
def dumpSectionHeader(self, header):
|
||||||
print header
|
print(header)
|
||||||
|
|
||||||
def dumpStartOfSections(self):
|
def dumpStartOfSections(self):
|
||||||
pass
|
pass
|
||||||
|
@ -339,10 +340,10 @@ class ChangeLog(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def dumpEndOfSection(self):
|
def dumpEndOfSection(self):
|
||||||
print
|
print()
|
||||||
|
|
||||||
def dumpEndOfChangelog(self):
|
def dumpEndOfChangelog(self):
|
||||||
print
|
print()
|
||||||
|
|
||||||
def dumpDrupalBreak(self):
|
def dumpDrupalBreak(self):
|
||||||
pass
|
pass
|
||||||
|
@ -350,7 +351,7 @@ class ChangeLog(object):
|
||||||
def dumpItem(self, grafs):
|
def dumpItem(self, grafs):
|
||||||
self.dumpGraf(grafs[0],4,6)
|
self.dumpGraf(grafs[0],4,6)
|
||||||
for par in grafs[1:]:
|
for par in grafs[1:]:
|
||||||
print
|
print()
|
||||||
self.dumpGraf(par,6,6)
|
self.dumpGraf(par,6,6)
|
||||||
|
|
||||||
def collateAndSortSections(self):
|
def collateAndSortSections(self):
|
||||||
|
@ -389,7 +390,7 @@ class ChangeLog(object):
|
||||||
self.dumpStartOfSections()
|
self.dumpStartOfSections()
|
||||||
for _,head,items in self.sections:
|
for _,head,items in self.sections:
|
||||||
if not head.endswith(':'):
|
if not head.endswith(':'):
|
||||||
print >>sys.stderr, "adding : to %r"%head
|
print("adding : to %r"%head, file=sys.stderr)
|
||||||
head = head + ":"
|
head = head + ":"
|
||||||
self.dumpSectionHeader(head)
|
self.dumpSectionHeader(head)
|
||||||
for _,grafs in items:
|
for _,grafs in items:
|
||||||
|
@ -445,16 +446,16 @@ class HTMLChangeLog(ChangeLog):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def dumpStartOfSections(self):
|
def dumpStartOfSections(self):
|
||||||
print "<ul>\n"
|
print("<ul>\n")
|
||||||
|
|
||||||
def dumpEndOfSections(self):
|
def dumpEndOfSections(self):
|
||||||
print "</ul>\n"
|
print("</ul>\n")
|
||||||
|
|
||||||
def dumpDrupalBreak(self):
|
def dumpDrupalBreak(self):
|
||||||
print "\n</ul>\n"
|
print("\n</ul>\n")
|
||||||
print "<p> </p>"
|
print("<p> </p>")
|
||||||
print "\n<!--break-->\n\n"
|
print("\n<!--break-->\n\n")
|
||||||
print "<ul>"
|
print("<ul>")
|
||||||
|
|
||||||
def dumpItem(self, grafs):
|
def dumpItem(self, grafs):
|
||||||
grafs[0][0] = grafs[0][0].replace(" - ", "", 1).lstrip()
|
grafs[0][0] = grafs[0][0].replace(" - ", "", 1).lstrip()
|
||||||
|
@ -464,7 +465,7 @@ class HTMLChangeLog(ChangeLog):
|
||||||
self.htmlPar(par)
|
self.htmlPar(par)
|
||||||
else:
|
else:
|
||||||
self.htmlText(grafs[0])
|
self.htmlText(grafs[0])
|
||||||
print
|
print()
|
||||||
|
|
||||||
op = optparse.OptionParser(usage="usage: %prog [options] [filename]")
|
op = optparse.OptionParser(usage="usage: %prog [options] [filename]")
|
||||||
op.add_option('-W', '--no-wrap', action='store_false',
|
op.add_option('-W', '--no-wrap', action='store_false',
|
||||||
|
@ -560,7 +561,7 @@ if options.firstOnly:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if nextline is not None:
|
if nextline is not None:
|
||||||
print nextline
|
print(nextline)
|
||||||
|
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
changelog.
|
changelog.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ REPLACEMENTS = {
|
||||||
def score(s,fname=None):
|
def score(s,fname=None):
|
||||||
m = re.match(r'^ +o ([^\n]*)\n(.*)', s, re.M|re.S)
|
m = re.match(r'^ +o ([^\n]*)\n(.*)', s, re.M|re.S)
|
||||||
if not m:
|
if not m:
|
||||||
print >>sys.stderr, "Can't score %r from %s"%(s,fname)
|
print("Can't score %r from %s"%(s,fname), file=sys.stderr)
|
||||||
heading = m.group(1)
|
heading = m.group(1)
|
||||||
heading = REPLACEMENTS.get(heading, heading)
|
heading = REPLACEMENTS.get(heading, heading)
|
||||||
lw = m.group(1).lower()
|
lw = m.group(1).lower()
|
||||||
|
@ -100,9 +101,9 @@ changes.sort()
|
||||||
last_lw = "this is not a header"
|
last_lw = "this is not a header"
|
||||||
for _, lw, header, rest in changes:
|
for _, lw, header, rest in changes:
|
||||||
if lw == last_lw:
|
if lw == last_lw:
|
||||||
print rest,
|
print(rest, end="")
|
||||||
else:
|
else:
|
||||||
print
|
print()
|
||||||
print " o",header
|
print(" o",header)
|
||||||
print rest,
|
print(rest, end="")
|
||||||
last_lw = lw
|
last_lw = lw
|
||||||
|
|
Loading…
Add table
Reference in a new issue