-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare.py
More file actions
33 lines (22 loc) · 758 Bytes
/
prepare.py
File metadata and controls
33 lines (22 loc) · 758 Bytes
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
import sys
import subprocess
version = None
with open('changelog.txt', 'r') as f:
for line in f.readlines():
if line.startswith('202'):
version = line.split(':', 1)[-1].strip()
if version == None:
print('No version found in changelog.txt')
sys.exit(1)
print(f'Using version: {version}')
date = subprocess.check_output(['date', '-R'], text=True).strip()
print(f'Using date: {date}')
def specialize(path):
with open(f'{path}.template', 'r') as f:
template = f.read()
content = template.replace('{{{version}}}', version).replace('{{{date}}}', date)
with open(path, 'w') as f:
f.write(content)
specialize('setup.py')
specialize('tinkerforge_util/__init__.py')
specialize('debian/changelog')