[pywin32-checkins] pywin32/Pythonwin/pywin/framework scriptutils.py, 1.25, 1.26
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2010-08-25 07:49:02
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv28794/pythonwin/pywin/framework Modified Files: scriptutils.py Log Message: fix reload of package modules;support for 'pyw' and 'pyx' (kxroberto) Index: scriptutils.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/scriptutils.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** scriptutils.py 6 Feb 2009 16:29:06 -0000 1.25 --- scriptutils.py 25 Aug 2010 07:48:54 -0000 1.26 *************** *** 102,108 **** # If on path, _and_ existing package of that name loaded. if IsOnPythonPath(path) and modBit in sys.modules and \ ! ( os.path.exists(os.path.join(path, '__init__.py')) or \ ! os.path.exists(os.path.join(path, '__init__.pyc')) or \ ! os.path.exists(os.path.join(path, '__init__.pyo')) \ ): modBits.reverse() --- 102,108 ---- # If on path, _and_ existing package of that name loaded. if IsOnPythonPath(path) and modBit in sys.modules and \ ! (os.path.exists(os.path.join(path, modBit, '__init__.py')) or \ ! os.path.exists(os.path.join(path, modBit, '__init__.pyc')) or \ ! os.path.exists(os.path.join(path, modBit, '__init__.pyo')) \ ): modBits.reverse() *************** *** 376,385 **** if pathName is not None: ! if os.path.splitext(pathName)[1].lower() != ".py": pathName = None if pathName is None: openFlags = win32con.OFN_OVERWRITEPROMPT|win32con.OFN_FILEMUSTEXIST ! dlg = win32ui.CreateFileDialog(1,None,None,openFlags, "Python Scripts (*.py)|*.py||") dlg.SetOFNTitle("Import Script") if dlg.DoModal()!=win32con.IDOK: --- 376,385 ---- if pathName is not None: ! if os.path.splitext(pathName)[1].lower() not in ('.py','.pyw','.pyx'): pathName = None if pathName is None: openFlags = win32con.OFN_OVERWRITEPROMPT|win32con.OFN_FILEMUSTEXIST ! dlg = win32ui.CreateFileDialog(1,None,None,openFlags, "Python Scripts (*.py;*.pyw)|*.py;*.pyw;*.pyx||") dlg.SetOFNTitle("Import Script") if dlg.DoModal()!=win32con.IDOK: *************** *** 426,429 **** --- 426,430 ---- try: exec codeObj in __main__.__dict__ + mod = sys.modules.get(modName) if bNeedReload: try: *************** *** 434,439 **** except ImportError: my_reload = reload # reload a builtin in py2k ! my_reload(sys.modules[modName]) ! win32ui.SetStatusText('Successfully ' + what + "ed module '"+modName+"'") except: _HandlePythonFailure(what) --- 435,440 ---- except ImportError: my_reload = reload # reload a builtin in py2k ! mod = my_reload(sys.modules[modName]) ! win32ui.SetStatusText('Successfully ' + what + "ed module '"+modName+"': %s" % getattr(mod,'__file__',"<unkown file>")) except: _HandlePythonFailure(what) *************** *** 515,520 **** # (eg, bScrollToTop should be false when jumping to an error line to retain the # context, but true when jumping to a method defn, where we want the full body. doc = win32ui.GetApp().OpenDocumentFile(fileName) ! if doc is None: return 0 frame = doc.GetFirstView().GetParentFrame() try: --- 516,522 ---- # (eg, bScrollToTop should be false when jumping to an error line to retain the # context, but true when jumping to a method defn, where we want the full body. + # Return the view which is editing the file, or None on error. doc = win32ui.GetApp().OpenDocumentFile(fileName) ! if doc is None: return None frame = doc.GetFirstView().GetParentFrame() try: *************** *** 539,543 **** view.LineScroll(nScroll, 0) view.SetFocus() ! return 1 def _HandlePythonFailure(what, syntaxErrorPathName = None): --- 541,545 ---- view.LineScroll(nScroll, 0) view.SetFocus() ! return view def _HandlePythonFailure(what, syntaxErrorPathName = None): |