You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

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