@@ -36,7 +36,7 @@ def get_current_version():
3636 current = (
3737 io .open (os .path .join (os .path .dirname ('__file__' ), 'appium' , 'version.py' ), encoding = 'utf-8' ).read ().rstrip ()
3838 )
39- print ('The current version is {}, type a new one' . format ( MESSAGE_YELLOW . format ( current )) )
39+ print (f 'The current version is { MESSAGE_YELLOW . format ( current ) } , type a new one' )
4040 return current
4141
4242
@@ -51,72 +51,72 @@ def get_new_version():
5151
5252def update_version_file (version ):
5353 new_version = VERSION_FORMAT .format (version )
54- with open (VERSION_FILE_PATH , 'w' ) as f :
54+ with open (VERSION_FILE_PATH , 'w' , encoding = "utf-8" ) as f :
5555 f .write (new_version )
5656
5757
5858def call_bash_script (cmd ):
5959 if os .environ .get ('DRY_RUN' ) is not None :
60- print ('{} Calls: {}' . format ( MESSAGE_RED .format ('[DRY_RUN]' ), cmd ) )
60+ print (f" { MESSAGE_RED .format ('[DRY_RUN]' )} Calls: { cmd } " )
6161 else :
6262 os .system (cmd )
6363
6464
6565def commit_version_code (new_version_num ):
66- call_bash_script ('git commit {} -m "Bump {}"' . format ( VERSION_FILE_PATH , new_version_num ) )
66+ call_bash_script (f 'git commit { VERSION_FILE_PATH } -m "Bump { new_version_num } "' )
6767
6868
6969def tag_and_generate_changelog (new_version_num ):
70- call_bash_script ('git tag "v{}"' . format ( new_version_num ) )
71- call_bash_script ('gitchangelog > {}' . format ( CHANGELOG_PATH ) )
72- call_bash_script ('git commit {} -m "Update changelog for {}"' . format ( CHANGELOG_PATH , new_version_num ) )
70+ call_bash_script (f 'git tag "v{ new_version_num } "' )
71+ call_bash_script (f 'gitchangelog > { CHANGELOG_PATH } ' )
72+ call_bash_script (f 'git commit { CHANGELOG_PATH } -m "Update changelog for { new_version_num } "' )
7373
7474
7575def upload_sdist (new_version_num ):
76- push_file = 'dist/Appium-Python-Client-{}.tar.gz' . format ( new_version_num )
76+ push_file = f 'dist/Appium-Python-Client-{ new_version_num } .tar.gz'
7777 try :
78- call_bash_script ('twine upload "{}"' . format ( push_file ) )
78+ call_bash_script (f 'twine upload "{ push_file } "' )
7979 except Exception as e :
8080 print (
81- 'Failed to upload {} to pypi. '
82- 'Please fix the original error and push it again later. Original error: {}' . format ( push_file , e )
81+ f 'Failed to upload { push_file } to pypi. '
82+ f 'Please fix the original error and push it again later. Original error: { e } '
8383 )
8484
8585
8686def push_changes_to_master (new_version_num ):
8787 call_bash_script ('git push origin master' )
88- call_bash_script ('git push origin "v{}"' . format ( new_version_num ) )
88+ call_bash_script (f 'git push origin "v{ new_version_num } "' )
8989
9090
9191def ensure_publication (new_version_num ):
9292 if os .environ .get ('DRY_RUN' ) is not None :
93- print (' Run with {} mode.' . format ( MESSAGE_RED .format ('[DRY_RUN]' )) )
93+ print (f" Run with { MESSAGE_RED .format ('[DRY_RUN]' )} mode." )
9494
95- print ('Are you sure to release as {}?[y/n]' . format ( MESSAGE_YELLOW . format ( new_version_num )) )
95+ print (f 'Are you sure to release as { MESSAGE_YELLOW . format ( new_version_num ) } ?[y/n]' )
9696 for line in sys .stdin :
9797 if line .rstrip ().lower () == 'y' :
9898 return
99- exit ('Canceled release process.' )
99+ sys . exit ('Canceled release process.' )
100100
101101
102102def build_sdist ():
103- call_bash_script ('{ } setup.py sdist'. format ( sys . executable ) )
103+ call_bash_script (f' { sys . executable } setup.py sdist' )
104104
105105
106106def validate_release_env ():
107107 if os .system ('which twine' ) != 0 :
108- exit ("Please get twine via 'pip install twine'" )
108+ sys . exit ("Please get twine via 'pip install twine'" )
109109 if os .system ('which gitchangelog' ) != 0 :
110- exit (
110+ sys . exit (
111111 "Please get twine via 'pip install gitchangelog' or 'pip install git+git://github.com/vaab/gitchangelog.git' for Python 3.7"
112112 )
113113
114114
115115def build () -> None :
116116 shutil .rmtree (BUILT_APPIUM_DIR_PATH , ignore_errors = True )
117- status , output = subprocess .getstatusoutput ('{} setup.py install' . format ( os .getenv ('PYTHON_BIN_PATH' )) )
117+ status , output = subprocess .getstatusoutput (f" { os .getenv ('PYTHON_BIN_PATH' )} setup.py install" )
118118 if status != 0 :
119- exit (f'Failed to build the package:\n { output } ' )
119+ sys . exit (f'Failed to build the package:\n { output } ' )
120120
121121
122122def get_py_files_in_dir (root_dir : str ) -> List [str ]:
@@ -144,7 +144,7 @@ def assert_files_count_in_package() -> None:
144144 if diff :
145145 print (f"{ BUILT_APPIUM_DIR_PATH } has { diff } files than { APPIUM_DIR_PATH } " )
146146
147- exit (
147+ sys . exit (
148148 f"Python files in '{ BUILT_APPIUM_DIR_PATH } ' may differ from '{ APPIUM_DIR_PATH } '. "
149149 "Please make sure setup.py is configured properly."
150150 )
0 commit comments