MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / __show_package_version

Function __show_package_version

PySimpleGUI/PySimpleGUI.py:24794–24826  ·  view source on GitHub ↗

Prints the version of a package to the Multiline element provided :param package: Package to get version of :type package: str :param print_function: Function to output to... will be a normal print or an mline print :type print_function: Multiline, Any :par

(package, print_function, interpreter)

Source from the content-addressed store, hash-verified

24792
24793
24794def __show_package_version(package, print_function, interpreter):
24795 """
24796 Prints the version of a package to the Multiline element provided
24797
24798 :param package: Package to get version of
24799 :type package: str
24800 :param print_function: Function to output to... will be a normal print or an mline print
24801 :type print_function: Multiline, Any
24802 :param interpreter: The interpreter to use
24803 :type interpreter: str
24804
24805 """
24806 # interpreter = execute_py_get_interpreter()
24807 if print_function == print:
24808 print_function(f'{package} upgraded to ', end='') # can't use c parm on a normal print
24809 else:
24810 print_function(f'{package} upgraded to ', end='', c='red')
24811
24812 if sys.version_info.major == 3 and sys.version_info.minor in (6,7): # if running Python version 3.6 or 3.7
24813 pstr = __code_that_prints_version_pre_38(package)
24814 else:
24815 pstr = __code_that_prints_version(package)
24816 temp_file = os.path.join(os.path.dirname(__file__), 'temp_py.py')
24817 with open(temp_file, 'w') as file:
24818 file.write(pstr)
24819 sp = execute_py_file(temp_file, interpreter_command=interpreter, pipe_output=True, wait=False)
24820 for line in sp.stdout:
24821 oline = line.decode().rstrip()
24822 if print_function == print:
24823 print_function(oline) # can't use font parm on a normal print
24824 else:
24825 print_function(oline, font='_ 10 bold')
24826 os.remove(temp_file)
24827
24828
24829

Callers 1

Calls 5

writeMethod · 0.80
removeMethod · 0.80
execute_py_fileFunction · 0.70

Tested by

no test coverage detected