-
Notifications
You must be signed in to change notification settings - Fork 3
/
core.py
41 lines (34 loc) · 964 Bytes
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from rst_parser import RstChangelog
__all__ = ['load', 'loads']
def load(filename, format='rst'):
"""
Parse a changelog file.
Parameters
----------
filename : str
The changelog file
format : { 'rst' }
The format of the changelog file (only rst is supported at this time)
"""
if format == 'rst':
changelog = RstChangelog()
changelog.parse_file(filename)
return changelog
else:
raise ValueError(f'Format not recognized: {format}')
def loads(text, format='rst'):
"""
Parse a changelog string.
Parameters
----------
text : str
The changelog string
format : { 'rst' }
The format of the changelog file (only rst is supported at this time)
"""
if format == 'rst':
changelog = RstChangelog()
changelog.parse_string(text)
return changelog
else:
raise ValueError(f'Format not recognized: {format}')