/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FWCore/PythonUtilities/scripts/interactivePythonTest.py
40 строк
1 KB
Shahzad Malik Muzaffar
[CORE] py2/3 compatibility:drop use of __future__
22 ноя 2024, 20:16
22 ноя 2024, 20:16
4759e53
Код
Авторство
О чём код?
#!/usr/bin/env python3 import sys import os import readline import atexit import ctypes def interactive_inspect_mode(): # http://stackoverflow.com/questions/640389/tell-whether-python-is-in-i-mode flagPtr = ctypes.cast(ctypes.pythonapi.Py_InteractiveFlag, ctypes.POINTER(ctypes.c_int)) return flagPtr.contents.value > 0 or bool(os.environ.get("PYTHONINSPECT",False)) if __name__ == '__main__': ############################################# ## Load and save command line history when ## ## running interactively. ## ############################################# historyPath = os.path.expanduser("~/.pyhistory") def save_history(historyPath=historyPath): import readline readline.write_history_file(historyPath) if os.path.exists(historyPath): readline.read_history_file(historyPath) atexit.register(save_history) readline.parse_and_bind("set show-all-if-ambiguous on") readline.parse_and_bind("tab: complete") if os.path.exists (historyPath) : readline.read_history_file(historyPath) readline.set_history_length(-1) if not interactive_inspect_mode(): print("python -i `which interactivePythonTest.py` ")