11import argparse , re , sys
22from os import path
33from types import SimpleNamespace as sn
4- import tomli , tomli_w
4+ from lib import toml
55
66sys .path .insert (0 , path .join (path .dirname (__file__ ), '../src' ))
77from translate_messages .lib import data , log # type: ignore
@@ -43,7 +43,7 @@ def bump_pyproject_vers(pyproject_path, pyproject, project, new_ver): # project.
4343
4444 # Bump project.version
4545 pyproject ['project' ]['version' ] = new_ver
46- with open (pyproject_path , 'wb' ) as file : tomli_w . dump ( pyproject , file )
46+ toml . write (pyproject_path , pyproject )
4747 log .success (msgs .log_BUMPED_PROJECT_VER .format (prev_ver = project .version , new_ver = new_ver ))
4848
4949 # Bump project.urls['Releases']
@@ -52,12 +52,12 @@ def bump_pyproject_vers(pyproject_path, pyproject, project, new_ver): # project.
5252 log .data (f"{ msgs .log_CREATED_CHANGELOG_URL } : { changelog_url } " )
5353 log .info (f'{ msgs .log_UPDATING_CHANGELOG_URL_IN } pyproject.toml...' )
5454 pyproject ['project' ]['urls' ]['Changelog' ] = changelog_url
55- with open (pyproject_path , 'wb' ) as file : tomli_w . dump ( pyproject , file )
55+ toml . write (pyproject_path , pyproject )
5656 log .success (msgs .log_BUMPED_CHANGELOG_URL_VER_TAG .format (ver_tag = ver_tag ))
5757
5858def update_readme_vers (new_ver ): # in URLs
5959 log .info (f'{ msgs .log_UPDATING_VERS_IN } README.md...' )
60- readme_path = path .join (path .dirname (__file__ ), '../README.md' )
60+ readme_path = path .join (path .dirname (__file__ ), '../docs/ README.md' )
6161 updated_readme_content = re .sub (r'\b(?>\d{1,3}\.\d{1,3}\.\d{1,3})\b' , new_ver , data .file .read (readme_path ))
6262 data .file .write (readme_path , updated_readme_content )
6363 log .success (msgs .log_UPDATED_README_VERS .format (new_ver = new_ver ))
@@ -72,7 +72,7 @@ def main():
7272 # Init project data
7373 pyproject_path = path .join (path .dirname (__file__ ), '../pyproject.toml' )
7474 log .info (f'{ msgs .log_LOADING_PYPROJECT .format (pyproject_path = pyproject_path )} ...' )
75- with open ( pyproject_path , 'rb' ) as file : pyproject = tomli . load ( file )
75+ pyproject = toml . read ( pyproject_path )
7676 project = sn (** pyproject ['project' ])
7777
7878 # Update files
0 commit comments