6
6
# This makes it possible to use this script as part of CI to check
7
7
# that the list is up to date.
8
8
9
- import os
10
9
import json
11
10
import re
12
11
import sys
12
+ from pathlib import Path
13
13
14
14
def comp (version_string ):
15
15
return [int (c ) for c in version_string .split ('.' )]
16
16
17
- path = os . path . dirname ( os . path . realpath ( __file__ ))
18
- with open ( path + '/../docs/bugs.json' , encoding = 'utf8' ) as bugsFile :
19
- bugs = json . load ( bugsFile )
17
+ root_path = Path ( __file__ ). resolve (). parent . parent
18
+
19
+ bugs = json . loads (( root_path / 'docs/ bugs. json' ). read_text ( encoding = 'utf8' ) )
20
20
21
21
versions = {}
22
- with open ( path + '/../ Changelog.md', encoding = 'utf8' ) as changelog :
22
+ with ( root_path / ' Changelog.md'). open ( encoding = 'utf8' ) as changelog :
23
23
for line in changelog :
24
24
m = re .search (r'^### (\S+) \((\d+-\d+-\d+)\)$' , line )
25
25
if m :
@@ -36,8 +36,6 @@ def comp(version_string):
36
36
value ['bugs' ] += [bug ['name' ]]
37
37
38
38
new_contents = json .dumps (versions , sort_keys = True , indent = 4 , separators = (',' , ': ' ))
39
- with open (path + '/../docs/bugs_by_version.json' , 'r' , encoding = 'utf8' ) as bugs_by_version :
40
- old_contents = bugs_by_version .read ()
41
- with open (path + '/../docs/bugs_by_version.json' , 'w' , encoding = 'utf8' ) as bugs_by_version :
42
- bugs_by_version .write (new_contents )
39
+ old_contents = (root_path / 'docs/bugs_by_version.json' ).read_text (encoding = 'utf8' )
40
+ (root_path / 'docs/bugs_by_version.json' ).write_text (new_contents , encoding = 'utf8' )
43
41
sys .exit (old_contents != new_contents )
0 commit comments