@@ -194,9 +194,7 @@ def select_python(python_executable):
194194 either `python` or `pythonw`.
195195 """
196196 if PYTHON_DIRECTORY and os .path .exists (PYTHON_DIRECTORY ):
197- python_executables = (
198- [python_executable ] if python_executable else ["pythonw" , "python" ]
199- )
197+ python_executables = [python_executable ] if python_executable else ["pythonw" , "python" ]
200198
201199 for python_exe in python_executables :
202200 python = os .path .join (PYTHON_DIRECTORY , python_exe )
@@ -284,9 +282,7 @@ def _realpath_ipy_win(path):
284282 parent_path = os .path .join (path , ".." )
285283
286284 args = 'dir /c "{}" /Al' .format (parent_path )
287- process = subprocess .Popen (
288- args , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE
289- )
285+ process = subprocess .Popen (args , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
290286
291287 output , _error = process .communicate ()
292288 matches = SYMLINK_REGEX .finditer (output )
@@ -302,9 +298,7 @@ def _realpath_ipy_win(path):
302298
303299def _realpath_ipy_posix (path ):
304300 args = 'readlink -f "{}"' .format (path )
305- process = subprocess .Popen (
306- args , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE
307- )
301+ process = subprocess .Popen (args , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
308302 output , _error = process .communicate ()
309303 return output
310304
@@ -323,14 +317,8 @@ def _polyfill_symlinks(symlinks, raise_on_error):
323317 mklink_cmd .write ("ECHO ret=%symlink_result%\n " )
324318 for i , (source , link_name ) in enumerate (symlinks ):
325319 dir_symlink_arg = "/D" if os .path .isdir (source ) else ""
326- mklink_cmd .write (
327- "mklink {} {}\n " .format (
328- dir_symlink_arg , subprocess .list2cmdline ([link_name , source ])
329- )
330- )
331- mklink_cmd .write (
332- "IF %ERRORLEVEL% EQU 0 SET /A symlink_result += {} \n " .format (2 ** i )
333- )
320+ mklink_cmd .write ("mklink {} {}\n " .format (dir_symlink_arg , subprocess .list2cmdline ([link_name , source ])))
321+ mklink_cmd .write ("IF %ERRORLEVEL% EQU 0 SET /A symlink_result += {} \n " .format (2 ** i ))
334322
335323 mklink_cmd .write ("EXIT /B %symlink_result%\n " )
336324
@@ -547,9 +535,7 @@ def _run_command_as_admin(command, arguments):
547535
548536 with open (temp_path , "w" ) as remove_symlink_cmd :
549537 remove_symlink_cmd .write ("@echo off\n " )
550- remove_symlink_cmd .write (
551- "{} {}\n " .format (command , subprocess .list2cmdline (arguments ))
552- )
538+ remove_symlink_cmd .write ("{} {}\n " .format (command , subprocess .list2cmdline (arguments )))
553539
554540 _run_as_admin ([temp_path ])
555541
@@ -588,10 +574,7 @@ def _run_as_admin(command):
588574 ctypes .windll .kernel32 .WaitForSingleObject (process_handle , INFINITE )
589575
590576 ret = ctypes .wintypes .DWORD ()
591- if (
592- ctypes .windll .kernel32 .GetExitCodeProcess (process_handle , ctypes .byref (ret ))
593- == 0
594- ):
577+ if ctypes .windll .kernel32 .GetExitCodeProcess (process_handle , ctypes .byref (ret )) == 0 :
595578 raise RuntimeError ("Failed to retrieve exit code" )
596579
597580 return ret .value
0 commit comments