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
- import sys
11
+ from pathlib import Path
13
12
14
13
def comp (version_string ):
15
14
return [int (c ) for c in version_string .split ('.' )]
16
15
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 )
16
+ root_path = Path ( __file__ ). resolve (). parent . parent
17
+
18
+ bugs = json . loads (( root_path / 'docs/ bugs. json' ). read_text ( encoding = 'utf8' ) )
20
19
21
20
versions = {}
22
- with open ( path + '/../ Changelog.md', encoding = 'utf8' ) as changelog :
21
+ with ( root_path / ' Changelog.md'). open ( encoding = 'utf8' ) as changelog :
23
22
for line in changelog :
24
23
m = re .search (r'^### (\S+) \((\d+-\d+-\d+)\)$' , line )
25
24
if m :
@@ -35,9 +34,9 @@ def comp(version_string):
35
34
continue
36
35
value ['bugs' ] += [bug ['name' ]]
37
36
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 )
43
- sys . exit ( old_contents != new_contents )
37
+ ( root_path / 'docs/bugs_by_version.json' ). write_text ( json . dumps (
38
+ versions ,
39
+ sort_keys = True ,
40
+ indent = 4 ,
41
+ separators = ( ',' , ': ' )
42
+ ), encoding = 'utf8' )
0 commit comments