Skip to content

Commit

Permalink
update_bugs_by_version: Use pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Aug 8, 2022
1 parent abe869a commit c1cbffc
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions scripts/update_bugs_by_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
# This makes it possible to use this script as part of CI to check
# that the list is up to date.

import os
import json
import re
import sys
from pathlib import Path

def comp(version_string):
return [int(c) for c in version_string.split('.')]

path = os.path.dirname(os.path.realpath(__file__))
with open(path + '/../docs/bugs.json', encoding='utf8') as bugsFile:
bugs = json.load(bugsFile)
root_path = Path(__file__).resolve().parent.parent

bugs = json.loads((root_path / 'docs/bugs.json').read_text(encoding='utf8'))

versions = {}
with open(path + '/../Changelog.md', encoding='utf8') as changelog:
with (root_path / 'Changelog.md').open(encoding='utf8') as changelog:
for line in changelog:
m = re.search(r'^### (\S+) \((\d+-\d+-\d+)\)$', line)
if m:
Expand All @@ -36,8 +36,6 @@ def comp(version_string):
value['bugs'] += [bug['name']]

new_contents = json.dumps(versions, sort_keys=True, indent=4, separators=(',', ': '))
with open(path + '/../docs/bugs_by_version.json', 'r', encoding='utf8') as bugs_by_version:
old_contents = bugs_by_version.read()
with open(path + '/../docs/bugs_by_version.json', 'w', encoding='utf8') as bugs_by_version:
bugs_by_version.write(new_contents)
old_contents = (root_path / 'docs/bugs_by_version.json').read_text(encoding='utf8')
(root_path / 'docs/bugs_by_version.json').write_text(new_contents, encoding='utf8')
sys.exit(old_contents != new_contents)

0 comments on commit c1cbffc

Please sign in to comment.