MCPcopy Index your code
hub / github.com/lincolnloop/python-qrcode / update_manpage

Function update_manpage

qrcode/release.py:11–42  ·  view source on GitHub ↗

Update the version in the manpage document.

(data)

Source from the content-addressed store, hash-verified

9
10
11def update_manpage(data):
12 """
13 Update the version in the manpage document.
14 """
15 if data["name"] != "qrcode":
16 return
17
18 base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
19 filename = os.path.join(base_dir, "doc", "qr.1")
20 with open(filename) as f:
21 lines = f.readlines()
22
23 changed = False
24 for i, line in enumerate(lines):
25 if not line.startswith(".TH "):
26 continue
27 parts = re.split(r'"([^"]*)"', line)
28 if len(parts) < 5:
29 continue
30 changed = parts[3] != data["new_version"]
31 if changed:
32 # Update version
33 parts[3] = data["new_version"]
34 # Update date
35 parts[1] = datetime.datetime.now().strftime("%-d %b %Y")
36 lines[i] = '"'.join(parts)
37 break
38
39 if changed:
40 with open(filename, "w") as f:
41 for line in lines:
42 f.write(line)

Callers 4

test_invalid_dataFunction · 0.90
test_not_qrcodeFunction · 0.90
test_no_changeFunction · 0.90
test_changeFunction · 0.90

Calls 1

writeMethod · 0.80

Tested by 4

test_invalid_dataFunction · 0.72
test_not_qrcodeFunction · 0.72
test_no_changeFunction · 0.72
test_changeFunction · 0.72