', 1)[1].split('<', 1)[0])
title = title.replace('', '').replace('', '').replace('\r\n', '\n').strip()
return DR(section, issue, url, status, title)
def collect_tests():
status_re = re.compile(r'\bcwg([0-9]+): (.*)')
status_map = {}
for test_cpp in os.listdir(dr_test_dir):
if not test_cpp.endswith('.cpp'):
continue
test_cpp = os.path.join(dr_test_dir, test_cpp)
found_any = False;
for match in re.finditer(status_re, open(test_cpp, 'r', encoding="utf-8").read()):
dr_number = int(match.group(1))
if dr_number in status_map:
print("error: Comment for cwg{} encountered more than once. Duplicate found in {}".format(dr_number, test_cpp))
sys.exit(1)
status_map[dr_number] = match.group(2)
found_any = True
if not found_any:
print("warning:%s: no '// cwg123: foo' comments in this file" % test_cpp, file=sys.stderr)
return status_map
def get_issues(path):
buffer = None
if not path and os.path.exists(default_issue_list_path):
path = default_issue_list_path
try:
if path is None:
print('Fetching issue list from {}'.format(issue_list_url))
with urllib.request.urlopen(issue_list_url) as f:
buffer = f.read().decode('utf-8')
else:
print('Opening issue list from file {}'.format(path))
with open(path, 'r') as f:
buffer = f.read()
except Exception as ex:
print('Unable to read the core issue list', file=sys.stderr)
print(ex, file=sys.stderr)
sys.exit(1)
return sorted((parse(dr) for dr in buffer.split('
''')
if availability_error_occurred:
exit(1)
for status, num in sorted(count.items()):
print("%s: %s" % (status, num), file=sys.stderr)
out_html.append('''\
''')
# Make an effort to remain consistent with the existing file.
# We can't pick one newline style and use it on Windows,
# because we can't be compatible with all 'autocrlf' modes at once.
def detect_newline_style(file_path):
if not os.path.exists(file_path):
return '\n'
f = open(file_path)
f.readline()
if f.newlines is None:
return '\n'
if isinstance(f.newlines, str):
return f.newlines
newline = f.newlines[0]
print(f"Existing '{file_path}' has inconsistent newlines; picking '{newline.encode('unicode_escape').decode('utf-8')}'")
return newline
out_file = open(output, 'w', newline=detect_newline_style(output))
out_file.write(''.join(out_html))
out_file.close()