[pywin32-checkins] pywin32/com/win32com/server policy.py, 1.23, 1.24
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-11-26 02:16:53
|
Update of /cvsroot/pywin32/pywin32/com/win32com/server In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16564/com/win32com/server Modified Files: policy.py Log Message: Get rid of use of string module and other py3k friendly changes. Index: policy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/server/policy.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** policy.py 13 Feb 2008 22:18:08 -0000 1.23 --- policy.py 26 Nov 2008 01:48:48 -0000 1.24 *************** *** 71,77 **** import win32api import winerror - import string import sys import types import win32con, pythoncom --- 71,77 ---- import win32api import winerror import sys import types + import pywintypes import win32con, pythoncom *************** *** 85,92 **** # Few more globals to speed things. - from pywintypes import UnicodeType IDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] IUnknownType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown] - core_has_unicode = hasattr(__builtins__, "unicode") from exception import COMException --- 85,90 ---- *************** *** 98,104 **** regAddnPath = 'CLSID\\%s\\PythonCOMPath' - # exc_info doesnt appear 'till Python 1.5, but we now have other 1.5 deps! - from sys import exc_info - def CreateInstance(clsid, reqIID): """Create a new instance of the specified IID --- 96,99 ---- *************** *** 114,119 **** # First see is sys.path should have something on it. try: ! addnPaths = string.split(win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, ! regAddnPath % clsid),';') for newPath in addnPaths: if newPath not in sys.path: --- 109,114 ---- # First see is sys.path should have something on it. try: ! addnPaths = win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, ! regAddnPath % clsid).split(';') for newPath in addnPaths: if newPath not in sys.path: *************** *** 134,140 **** except win32api.error: dispatcher = None - - # clear exception information - sys.exc_type = sys.exc_value = sys.exc_traceback = None # sys.clearexc() appears in 1.5? if dispatcher: --- 129,132 ---- *************** *** 242,246 **** # Allow interfaces to be specified by name. for i in ob._com_interfaces_: ! if type(i) != pythoncom.PyIIDType: # Prolly a string! if i[0] != "{": --- 234,238 ---- # Allow interfaces to be specified by name. for i in ob._com_interfaces_: ! if type(i) != pywintypes.IIDType: # Prolly a string! if i[0] != "{": *************** *** 280,284 **** if type(dispid) == type(""): try: ! dispid = self._name_to_dispid_[string.lower(dispid)] except KeyError: raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND, desc="Member not found") --- 272,276 ---- if type(dispid) == type(""): try: ! dispid = self._name_to_dispid_[dispid.lower()] except KeyError: raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND, desc="Member not found") *************** *** 314,318 **** try: ### TODO - look at the fdex flags!!! ! return self._name_to_dispid_[string.lower(str(name))] except KeyError: raise COMException(scode = winerror.DISP_E_UNKNOWNNAME) --- 306,310 ---- try: ### TODO - look at the fdex flags!!! ! return self._name_to_dispid_[name.lower()] except KeyError: raise COMException(scode = winerror.DISP_E_UNKNOWNNAME) *************** *** 327,331 **** if type(dispid) == type(""): try: ! dispid = self._name_to_dispid_[string.lower(dispid)] except KeyError: raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND, desc="Member not found") --- 319,323 ---- if type(dispid) == type(""): try: ! dispid = self._name_to_dispid_[dispid.lower()] except KeyError: raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND, desc="Member not found") *************** *** 470,474 **** # Filter out all 'normal' IIDs (ie, IID objects and strings starting with { interfaces = [i for i in getattr(ob, '_com_interfaces_', []) ! if type(i) != pythoncom.PyIIDType and not i.startswith("{")] universal_data = universal.RegisterInterfaces(tlb_guid, tlb_lcid, tlb_major, tlb_minor, interfaces) --- 462,466 ---- # Filter out all 'normal' IIDs (ie, IID objects and strings starting with { interfaces = [i for i in getattr(ob, '_com_interfaces_', []) ! if type(i) != pywintypes.IIDType and not i.startswith("{")] universal_data = universal.RegisterInterfaces(tlb_guid, tlb_lcid, tlb_major, tlb_minor, interfaces) *************** *** 481,493 **** # Copy existing _dispid_to_func_ entries to _name_to_dispid_ for dispid, name in self._dispid_to_func_.items(): ! self._name_to_dispid_[string.lower(name)]=dispid for dispid, name in self._dispid_to_get_.items(): ! self._name_to_dispid_[string.lower(name)]=dispid for dispid, name in self._dispid_to_put_.items(): ! self._name_to_dispid_[string.lower(name)]=dispid # Patch up the universal stuff. for dispid, invkind, name in universal_data: ! self._name_to_dispid_[string.lower(name)]=dispid if invkind == DISPATCH_METHOD: self._dispid_to_func_[dispid] = name --- 473,485 ---- # Copy existing _dispid_to_func_ entries to _name_to_dispid_ for dispid, name in self._dispid_to_func_.items(): ! self._name_to_dispid_[name.lower()]=dispid for dispid, name in self._dispid_to_get_.items(): ! self._name_to_dispid_[name.lower()]=dispid for dispid, name in self._dispid_to_put_.items(): ! self._name_to_dispid_[name.lower()]=dispid # Patch up the universal stuff. for dispid, invkind, name in universal_data: ! self._name_to_dispid_[name.lower()]=dispid if invkind == DISPATCH_METHOD: self._dispid_to_func_[dispid] = name *************** *** 650,655 **** except pythoncom.error: pass # Keep it as IUnknown - elif not core_has_unicode and arg_type==UnicodeType: - arg = str(arg) ret.append(arg) return tuple(ret), kwArgs --- 642,645 ---- *************** *** 685,690 **** def _getdispid_(self, name, fdex): # TODO - Look at fdex flags. ! # TODO - Remove str() of Unicode name param. ! lname = string.lower(str(name)) try: return self._name_to_dispid_[lname] --- 675,679 ---- def _getdispid_(self, name, fdex): # TODO - Look at fdex flags. ! lname = name.lower() try: return self._name_to_dispid_[lname] *************** *** 703,709 **** ### note: serviceProvider is being ignored... ### there might be assigned DISPID values to properties, too... - ### TODO - Remove the str() of the Unicode argument try: ! name = str(self._dyn_dispid_to_name_[dispid]) except KeyError: raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND, desc="Member not found") --- 692,697 ---- ### note: serviceProvider is being ignored... ### there might be assigned DISPID values to properties, too... try: ! name = self._dyn_dispid_to_name_[dispid] except KeyError: raise COMException(scode = winerror.DISP_E_MEMBERNOTFOUND, desc="Member not found") *************** *** 720,724 **** """ try: ! idx = string.rindex(spec, ".") mname = spec[:idx] fname = spec[idx+1:] --- 708,712 ---- """ try: ! idx = spec.rindex(".") mname = spec[:idx] fname = spec[idx+1:] |