File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -73,3 +73,5 @@ This release introduces the use of our centralized [API service](https://github.
73
73
- Dynamic command aliases and snippets (#86 )
74
74
- Optional support for using a seperate guild as the operations center (#81 )
75
75
- NSFW Command to change channels to NSFW (#77 )
76
+
77
+ # v0.0.0
Original file line number Diff line number Diff line change
1
+ from collections import defaultdict
2
+ import re
3
+
4
+ class Version :
5
+ def __init__ (self , version , lines ):
6
+ self .version = version
7
+ self .lines = [x for x in lines .splitlines () if x ]
8
+ self .fields = defaultdict (str )
9
+ self .description = ''
10
+ self .parse ()
11
+
12
+ def __repr__ (self ):
13
+ return f'Version({ self .version } , description="{ self .description } ")'
14
+
15
+ def parse (self ):
16
+ curr_action = None
17
+ for line in self .lines :
18
+ if line .startswith ('### ' ):
19
+ curr_action = line .split ('### ' )[1 ]
20
+ elif curr_action is None :
21
+ self .description += line + '\n '
22
+ else :
23
+ self .fields [curr_action ] += line + '\n '
24
+
25
+ class ChangeLogParser :
26
+ regex = re .compile (r'# (v\d\.\d\.\d)([\S\s]*?(?=# v))' )
27
+
28
+ def __init__ (self , text ):
29
+ self .text = text
30
+ self .versions = [Version (* m ) for m in self .regex .findall (text )]
31
+
32
+ @property
33
+ def latest_version (self ):
34
+ return self .versions [0 ]
35
+
36
+
37
+ if __name__ == '__main__' :
38
+ with open ('../CHANGELOG.md' ) as f :
39
+ changelog = ChangeLogParser (f .read ())
40
+ print (changelog .latest_version )
You can’t perform that action at this time.
0 commit comments