|
1 | | -import os, logging |
| 1 | +import logging as log, os |
2 | 2 | import tomli, tomli_w |
3 | 3 |
|
4 | | -logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') |
| 4 | +log.basicConfig(level=log.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') |
5 | 5 |
|
6 | 6 | pyproject_path = os.path.join(os.path.dirname(__file__), '../pyproject.toml') |
7 | 7 | with open(pyproject_path, 'rb') as file: |
8 | 8 | pkg_name = tomli.load(file)['project']['name'] |
9 | 9 |
|
10 | 10 | def update_changelog_url(): |
11 | 11 |
|
12 | | - logging.debug(f'Loading {pyproject_path}...') |
| 12 | + log.debug(f'Loading {pyproject_path}...') |
13 | 13 | with open(pyproject_path, 'rb') as file : pyproject = tomli.load(file) |
14 | 14 |
|
15 | 15 | ver_tag = f"{pkg_name}-{pyproject['project']['version']}" |
16 | 16 | changelog_url = f'https://github.com/adamlui/python-utils/releases/tag/{ver_tag}' |
17 | | - logging.debug(f'Generated changelog URL: {changelog_url}') |
18 | | - |
| 17 | + log.debug(f'Generated changelog URL: {changelog_url}') |
| 18 | + |
19 | 19 | if 'urls' not in pyproject['project']: |
20 | | - logging.debug('Creating [project.urls] section...') |
| 20 | + log.debug('Creating [project.urls] section...') |
21 | 21 | pyproject['project']['urls'] = {} |
22 | 22 |
|
23 | | - logging.debug(f"{ 'Updating' if 'Changelog' in pyproject['project']['urls'] else 'Adding new' } Changelog URL...") |
| 23 | + log.debug(f"{ 'Updating' if 'Changelog' in pyproject['project']['urls'] else 'Adding new' } Changelog URL...") |
24 | 24 | pyproject['project']['urls']['Changelog'] = changelog_url |
25 | 25 | with open(pyproject_path, 'wb') as file : tomli_w.dump(pyproject, file) |
26 | 26 |
|
27 | | - logging.info(f"Bumped changelog URL ver tag to [{ver_tag}]!") |
| 27 | + log.info(f"Bumped changelog URL ver tag to [{ver_tag}]!") |
28 | 28 |
|
29 | 29 | update_changelog_url() |
0 commit comments