rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
result = testRunner.run(test) if not result.wasSuccessful(): print "*" * 50 print "Unittest tests failed" | suite.addTest(test) suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(PyCOMTest)) result = testRunner.run(suite) | def _test_with_import(capture, module_name, fn_name, desc): try: mod = __import__(module_name) except (ImportError, pythoncom.com_error): print "The '%s' test can not be run - failed to import test module" % desc return capture.capture() try: func = getattr(mod, fn_name) func() capture.release() print "%s generated %d ... |
_test_with_import(capture, "testStreams", "test", "Streams") _test_with_import(capture, "testWMI", "test", "WMI") import win32pipe data = win32pipe.popen(sys.executable + " testPyComTest.py -q").read() data = string.strip(data) print string.join(string.split(data, "\n"), "\r\n") | def _test_with_import(capture, module_name, fn_name, desc): try: mod = __import__(module_name) except (ImportError, pythoncom.com_error): print "The '%s' test can not be run - failed to import test module" % desc return capture.capture() try: func = getattr(mod, fn_name) func() capture.release() print "%s generated %d ... | |
import policySemantics policySemantics.TestAll() | def _test_with_import(capture, module_name, fn_name, desc): try: mod = __import__(module_name) except (ImportError, pythoncom.com_error): print "The '%s' test can not be run - failed to import test module" % desc return capture.capture() try: func = getattr(mod, fn_name) func() capture.release() print "%s generated %d ... | |
extra = os.path.join(sys.exec_prefix, 'lib') | extra = os.path.join(sdk_dir, 'lib') | def finalize_options(self): build_ext.finalize_options(self) self.windows_h_version = None # The pywintypes library is created in the build_temp # directory, so we need to add this to library_dirs self.library_dirs.append(self.build_temp) self.mingw32 = (self.compiler == "mingw32") if self.mingw32: self.libraries.appen... |
build_order = ".i .mc .rc .cpp".split() decorated = [(build_order.index(ext.lower()), obj, (src, ext)) for obj, (src, ext) in build.items()] decorated.sort() items = [item[1:] for item in decorated] class OnlyItems: def __init__(self, items): self._items = items def items(self): return self._items build = OnlyItems(i... | if sys.hexversion < 0x02040000: build_order = ".i .mc .rc .cpp".split() decorated = [(build_order.index(ext.lower()), obj, (src, ext)) for obj, (src, ext) in build.items()] decorated.sort() items = [item[1:] for item in decorated] class OnlyItems: def __init__(self, items): self._items = items def items(self): return... | def _setup_compile(self, *args): macros, objects, extra, pp_opts, build = \ msvccompiler.MSVCCompiler._setup_compile(self, *args) build_order = ".i .mc .rc .cpp".split() decorated = [(build_order.index(ext.lower()), obj, (src, ext)) for obj, (src, ext) in build.items()] decorated.sort() items = [item[1:] for item in de... |
key2 = win32api.RegOpenKey(key, str(iid)) | try: key2 = win32api.RegOpenKey(key, str(iid)) except win32api.error: continue | def EnumTlbs(excludeFlags = 0): """Return a list of TypelibSpec objects, one for each registered library. """ key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "Typelib") iids = EnumKeys(key) results = [] for iid, crap in iids: key2 = win32api.RegOpenKey(key, str(iid)) for version, tlbdesc in EnumKeys(key2): major_... |
print SelectTlb() | print SelectTlb().__dict__ | def SelectTlb(title="Select Library", excludeFlags = 0): """Display a list of all the type libraries, and select one. Returns None if cancelled """ import pywin.dialogs.list items = EnumTlbs(excludeFlags) items.sort() rc = pywin.dialogs.list.SelectFromLists(title, items, ["Type Library"]) if rc is None: return None r... |
define_macros = define_macros or [] define_macros.append(("DISTUTILS_BUILD", None)) | def __init__ (self, name, sources=None, include_dirs=[], define_macros=None, undef_macros=None, library_dirs=[], libraries="", runtime_library_dirs=None, extra_objects=None, extra_compile_args=None, extra_link_args=None, export_symbols=None, export_symbol_file=None, dsp_file=None, pch_header=None, windows_h_version=Non... | |
print "OD is", output_dir | for undef in ext.undef_macros: macros.append((undef,)) | |
swig_targets[source] = base + 'module_win32' + target_ext | new_target = base + 'module_win32' + target_ext swig_targets[source] = new_target new_sources.append(new_target) | def swig_sources (self, sources): new_sources = [] swig_sources = [] swig_targets = {} # XXX this drops generated C/C++ files into the source tree, which # is fine for developers who want to distribute the generated # source -- but there should be an option to put SWIG output in # the temp dir. # XXX - further, the way... |
("win32process", "advapi32 user32", False), | ("win32process", "advapi32 user32", False, 0x0500), | def finalize_options(self): if self.install_dir is None: installobj = self.distribution.get_command_obj('install') self.install_dir = installobj.install_lib print 'Installing data files to %s' % self.install_dir install_data.finalize_options(self) |
import win32api, imp, sys, os suffix = "" if win32api.__file__.endswith("_d.pyd")>0: suffix = "_d" | import imp, sys, os for suffix_item in imp.get_suffixes(): if suffix_item[0]=='_d.pyd': suffix = '_d' break else: suffix = "" | def __import(modname): import win32api, imp, sys, os suffix = "" if win32api.__file__.endswith("_d.pyd")>0: suffix = "_d" filename = "%s%d%d%s.dll" % (modname, sys.version_info[0], sys.version_info[1], suffix) if hasattr(sys, "frozen"): # If we are running from a frozen program (py2exe, McMillan, freeze) # then we try ... |
h = win32api.LoadLibrary(filename) found = win32api.GetModuleFileName(h) | if os.path.isfile(os.path.join(sys.prefix, filename)): found = os.path.join(sys.prefix, filename) else: import win32api h = win32api.LoadLibrary(filename) found = win32api.GetModuleFileName(h) | def __import(modname): import win32api, imp, sys, os suffix = "" if win32api.__file__.endswith("_d.pyd")>0: suffix = "_d" filename = "%s%d%d%s.dll" % (modname, sys.version_info[0], sys.version_info[1], suffix) if hasattr(sys, "frozen"): # If we are running from a frozen program (py2exe, McMillan, freeze) # then we try ... |
if h is not None: win32api.FreeLibrary(h) | def __import(modname): import win32api, imp, sys, os suffix = "" if win32api.__file__.endswith("_d.pyd")>0: suffix = "_d" filename = "%s%d%d%s.dll" % (modname, sys.version_info[0], sys.version_info[1], suffix) if hasattr(sys, "frozen"): # If we are running from a frozen program (py2exe, McMillan, freeze) # then we try ... | |
v.ensure_value('verbose','1') | v.ensure_value('verbose','-v' in sys.argv) | def run(self): build.run(self) # write a pywin32.version.txt. ver_fname = os.path.join(os.environ['temp'], "pywin32.version.txt") try: f = open(ver_fname, "wU") f.write("%s\n" % build_id) f.close() except EnvironmentError, why: print "Failed to open '%s': %s" % (ver_fname, why) |
libraries="axscript ad1", | libraries="axscript", | def finalize_options(self): if self.install_dir is None: installobj = self.distribution.get_command_obj('install') self.install_dir = installobj.install_lib print 'Installing data files to %s' % self.install_dir install_data.finalize_options(self) |
def TestVTable(): | def TestVTable(clsctx=pythoncom.CLSCTX_ALL): | def TestVTable(): tester = win32com.client.Dispatch("PyCOMTest.PyCOMTest") testee = pythoncom.CoCreateInstance("Python.Test.PyCOMTest", None, pythoncom.CLSCTX_ALL, pythoncom.IID_IUnknown) tester.TestMyInterface(testee) # We once crashed creating our object with the native interface as # the first IID specified. We mu... |
testee = pythoncom.CoCreateInstance("Python.Test.PyCOMTest", None, pythoncom.CLSCTX_ALL, pythoncom.IID_IUnknown) | testee = pythoncom.CoCreateInstance("Python.Test.PyCOMTest", None, clsctx, pythoncom.IID_IUnknown) | def TestVTable(): tester = win32com.client.Dispatch("PyCOMTest.PyCOMTest") testee = pythoncom.CoCreateInstance("Python.Test.PyCOMTest", None, pythoncom.CLSCTX_ALL, pythoncom.IID_IUnknown) tester.TestMyInterface(testee) # We once crashed creating our object with the native interface as # the first IID specified. We mu... |
print "Testing VTables..." TestVTable() | print "Testing Universal Gateway..." TestMultiVTable() TestMultiQueryInterface() | def TestAll(): try: # Make sure server installed import win32com.client.dynamic win32com.client.dynamic.DumbDispatch("PyCOMTest.PyCOMTest") except pythoncom.com_error: print importMsg return print "Testing VTables..." TestVTable() print "Testing Python COM Test Horse..." TestDynamic() TestGenerated() |
for catid, lcid, desc in enum: ret.append(HLICategory((catid, lcid, desc))) | try: for catid, lcid, desc in enum: ret.append(HLICategory((catid, lcid, desc))) except pythoncom.com_error: pass | def GetSubList(self): catinf=pythoncom.CoCreateInstance(pythoncom.CLSID_StdComponentCategoriesMgr,None,pythoncom.CLSCTX_INPROC,pythoncom.IID_ICatInformation) enum=util.Enumerator(catinf.EnumCategories()) ret = [] for catid, lcid, desc in enum: ret.append(HLICategory((catid, lcid, desc))) return ret |
ret.append(HLIRegisteredTypeLibrary((keyName, versionStr), name)) | if name is not None: ret.append(HLIRegisteredTypeLibrary((keyName, versionStr), name)) | def GetSubList(self): # Explicit lookup in the registry. ret = [] key = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "TypeLib") win32ui.DoWaitCursor(1) try: num = 0 while 1: try: keyName = win32api.RegEnumKey(key, num) except win32api.error: break # Enumerate all version info subKey = win32api.RegOpenKey(key, keyNam... |
return CLSIDToClass.GetClass(iid) | return CLSIDToClass.GetClass(str(iid)) | def GetClassForProgID(progid): """Get a Python class for a Program ID Given a Program ID, return a Python class which wraps the COM object Returns the Python class, or None if no module is available. Params progid -- A COM ProgramID or IID (eg, "Word.Application") """ iid = pywintypes.IID(progid) mod = GetModuleForC... |
UnicodeToString = NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER): | UnicodeToString = NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER, WrapperClass = None): | def __WrapDispatch(dispatch, userName = None, resultCLSID = None, typeinfo = None, \ UnicodeToString = NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER): """ Helper function to return a makepy generated class for a CLSID if it exists, otherwise cope by using CDispatch. """ if resultCLSID is None: try: typeinfo ... |
return dynamic.Dispatch(dispatch, userName, CDispatch, typeinfo, UnicodeToString=UnicodeToString,clsctx=clsctx) | if WrapperClass is None: WrapperClass = CDispatch return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, UnicodeToString=UnicodeToString,clsctx=clsctx) | def __WrapDispatch(dispatch, userName = None, resultCLSID = None, typeinfo = None, \ UnicodeToString = NeedUnicodeConversions, clsctx = pythoncom.CLSCTX_SERVER): """ Helper function to return a makepy generated class for a CLSID if it exists, otherwise cope by using CDispatch. """ if resultCLSID is None: try: typeinfo ... |
if FileExists(os.path.join(path, "parser%s.dll" % suffix)) or \ FileExists(os.path.join(path, "parser%s.pyd" % suffix)): | if FileExists(os.path.join(path, "parser%s.pyd" % suffix)): | def LocatePythonCore(searchPaths): """Locate and validate the core Python directories. Returns a list of paths that should be used as the core (ie, un-named) portion of the Python path. """ import win32api, win32con, string, os, regutil currentPath = regutil.GetRegisteredNamedPath(None) if currentPath: presearchPaths ... |
corePath = LocatePath("parser%s.dll" % suffix, searchPaths) | corePath = LocatePath("parser%s.pyd" % suffix, searchPaths) | def LocatePythonCore(searchPaths): """Locate and validate the core Python directories. Returns a list of paths that should be used as the core (ie, un-named) portion of the Python path. """ import win32api, win32con, string, os, regutil currentPath = regutil.GetRegisteredNamedPath(None) if currentPath: presearchPaths ... |
def FindRegisterPackage(packageName, knownFile, searchPaths): | def FindRegisterPackage(packageName, knownFile, searchPaths, registryAppName = None): | def FindRegisterPackage(packageName, knownFile, searchPaths): """Find and Register a package. Assumes the core registry setup correctly. In addition, if the location located by the package is already in the **core** path, then an entry is registered, but no path. (no other paths are checked, as the application whose ... |
regutil.RegisterNamedPath(packageName, pathAdd) | regutil.RegisterNamedPath(registryAppName, pathAdd) | def FindRegisterPackage(packageName, knownFile, searchPaths): """Find and Register a package. Assumes the core registry setup correctly. In addition, if the location located by the package is already in the **core** path, then an entry is registered, but no path. (no other paths are checked, as the application whose ... |
suffix = IsDebug() FindRegisterApp("Pythonwin", "docview.py", searchPaths) | suffix = IsDebug() | def RegisterPythonwin(searchPaths): """Knows how to register Pythonwin components """ import regutil suffix = IsDebug() FindRegisterApp("Pythonwin", "docview.py", searchPaths) FindRegisterHelpFile("Pythonwin.hlp", searchPaths, "Pythonwin Reference") FindRegisterPythonExe("pythonwin%s.exe" % suffix, searchPaths, "Pytho... |
FindRegisterModule("win32ui", "win32ui%s.pyd" % suffix, searchPaths) FindRegisterModule("win32uiole", "win32uiole%s.pyd" % suffix, searchPaths) | FindRegisterPackage("pywin", "__init__.py", searchPaths, "Pythonwin") | def RegisterPythonwin(searchPaths): """Knows how to register Pythonwin components """ import regutil suffix = IsDebug() FindRegisterApp("Pythonwin", "docview.py", searchPaths) FindRegisterHelpFile("Pythonwin.hlp", searchPaths, "Pythonwin Reference") FindRegisterPythonExe("pythonwin%s.exe" % suffix, searchPaths, "Pytho... |
def __init__(self, coInstance = None, eventInstance = None, eventCLSID = None): | def __init__(self, coInstance = None, eventInstance = None, eventCLSID = None, debug = 0): | def __init__(self, coInstance = None, eventInstance = None, eventCLSID = None): self.cp = None self.cookie = None if not coInstance is None: self.Connect(coInstance , eventInstance, eventCLSID) |
return win32com.server.util.wrap(obj) | useDispatcher = None if self.debug: from win32com.server import dispatcher useDispatcher = dispatcher.DefaultDebugDispatcher return win32com.server.util.wrap(obj, useDispatcher=useDispatcher) | def _wrap(self, obj): return win32com.server.util.wrap(obj) |
if doc[1]: print '\t' + build._safeQQQ(doc[1]) | if doc[1]: print '\t' + build._safeQuotedString(doc[1]) | def WriteClassHeader(self, generator): generator.checkWriteDispatchBaseClass() doc = self.doc print 'class ' + self.python_name + '(DispatchBaseClass):' if doc[1]: print '\t' + build._safeQQQ(doc[1]) try: progId = pythoncom.ProgIDFromCLSID(self.clsid) print "\t# This class is creatable by the name '%s'" % (progId) exce... |
if doc[1]: print '\t' + build._safeQQQ(doc[1]) | if doc[1]: print '\t' + build._safeQuotedString(doc[1]) | def WriteEventSinkClassHeader(self, generator): generator.checkWriteEventBaseClass() doc = self.doc print 'class ' + self.python_name + ':' if doc[1]: print '\t' + build._safeQQQ(doc[1]) try: progId = pythoncom.ProgIDFromCLSID(self.clsid) print "\t# This class is creatable by the name '%s'" % (progId) except pythoncom.... |
raise win32api.error, (code, fn, desc) | raise win32api.error, (code, fn, details) | def _ListAllHelpFilesInRoot(root): """Returns a list of (helpDesc, helpFname) for all registered help files """ import regutil retList = [] try: key = win32api.RegOpenKey(root, regutil.BuildDefaultPythonKey() + "\\Help", 0, win32con.KEY_READ) except win32api.error, (code, fn, details): import winerror if code!=winerror... |
return "\tSysFreeString(%s);\n" % self.arg.name | return "\tSysFreeString(%s); % (self.arg.name,) + \ ArgFormatterPythonCOM.GetBuildForInterfacePostCode(self) | def GetBuildForInterfacePostCode(self): return "\tSysFreeString(%s);\n" % self.arg.name |
return "\tCoTaskMemFree(%s);\n" % self.arg.name | return "\tCoTaskMemFree(%s);\n" % (self.arg.name,) + \ ArgFormatterPythonCOM.GetBuildForInterfacePostCode(self) | def GetBuildForInterfacePostCode(self): # memory returned into an OLECHAR should be freed return "\tCoTaskMemFree(%s);\n" % self.arg.name |
return "\tCoTaskMemFree(%s);\n" % self.arg.name return '' | ret = "\tCoTaskMemFree(%s);\n" % self.arg.name return ret + ArgFormatterPythonCOM.GetBuildForInterfacePostCode(self) | def GetBuildForInterfacePostCode(self): ### hack to determine if we need to free stuff if self.builtinIndirection + self.arg.indirectionLevel > 1: # memory returned into an OLECHAR should be freed return "\tCoTaskMemFree(%s);\n" % self.arg.name return '' |
self.SCIMarkerDefine(MARKER_BOOKMARK, SC_MARK_ROUNDRECT) self.SCIMarkerSetBack(MARKER_BOOKMARK, win32api.RGB(0, 0xff, 0xff)) self.SCIMarkerSetFore(MARKER_BOOKMARK, win32api.RGB(0x0, 0x0, 0x0)) | self.SCIMarkerDefineAll(MARKER_BOOKMARK, SC_MARK_ROUNDRECT, win32api.RGB(0x0, 0x0, 0x0), win32api.RGB(0, 0xff, 0xff)) | def OnInitialUpdate(self): SyntEditViewParent.OnInitialUpdate(self) |
self.SCIMarkerDefine(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS) self.SCIMarkerSetFore(SC_MARKNUM_FOLDEROPEN, win32api.RGB(0xff, 0xff, 0xff)) self.SCIMarkerSetBack(SC_MARKNUM_FOLDEROPEN, win32api.RGB(0, 0, 0)) self.SCIMarkerDefine(SC_MARKNUM_FOLDER, SC_MARK_PLUS) self.SCIMarkerSetFore(SC_MARKNUM_FOLDER, win32api.RGB(0xff, 0x... | if 1: self.SCIMarkerDefineAll(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS, win32api.RGB(0xff, 0xff, 0xff), win32api.RGB(0, 0, 0)) self.SCIMarkerDefineAll(SC_MARKNUM_FOLDER, SC_MARK_PLUS, win32api.RGB(0xff, 0xff, 0xff), win32api.RGB(0, 0, 0)) self.SCIMarkerDefineAll(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, win32api.RGB(0xff, 0xff,... | def OnInitialUpdate(self): SyntEditViewParent.OnInitialUpdate(self) |
interface_names = mod.VTablesNamesToCLSIDMap.keys() | interface_names = mod.VTablesNamesToIIDMap.keys() | def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names = None): # First see if we have makepy support. If so, we can probably satisfy the request without loading the typelib. try: mod = gencache.GetModuleForTypelib(typelibGUID, lcid, major, minor) except ImportError: mod = None if mod is None: import ... |
iid = mod.VTablesNamesToCLSIDMap[name] | iid = mod.VTablesNamesToIIDMap[name] | def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names = None): # First see if we have makepy support. If so, we can probably satisfy the request without loading the typelib. try: mod = gencache.GetModuleForTypelib(typelibGUID, lcid, major, minor) except ImportError: mod = None if mod is None: import ... |
if t & pythoncom.VT_BYREF: | if t & (pythoncom.VT_BYREF | pythoncom.VT_ARRAY): | def _CalcTypeSize(typeTuple): t = typeTuple[0] if t & pythoncom.VT_BYREF: # Its a pointer. cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1] elif t == pythoncom.VT_RECORD: try: import warnings warnings.warn("assuming records always pass pointers (they wont work for other reasons anyway!") except ImportError: print "warning: a... |
warnings.warn("assuming records always pass pointers (they wont work for other reasons anyway!") | warnings.warn("warning: records are known to not work for vtable interfaces") | def _CalcTypeSize(typeTuple): t = typeTuple[0] if t & pythoncom.VT_BYREF: # Its a pointer. cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1] elif t == pythoncom.VT_RECORD: try: import warnings warnings.warn("assuming records always pass pointers (they wont work for other reasons anyway!") except ImportError: print "warning: a... |
print "warning: assuming records always pass pointers (they wont work for other reasons anyway!" | print "warning: records are known to not work for vtable interfaces" | def _CalcTypeSize(typeTuple): t = typeTuple[0] if t & pythoncom.VT_BYREF: # Its a pointer. cb = _univgw.SizeOfVT(pythoncom.VT_PTR)[1] elif t == pythoncom.VT_RECORD: try: import warnings warnings.warn("assuming records always pass pointers (they wont work for other reasons anyway!") except ImportError: print "warning: a... |
try: key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"Software\Microsoft\MicrosoftSDK\Directories") sdk_dir, ignore = _winreg.QueryValueEx(key, "Install Dir") except OSError: sdk_dir = None | sdk_dir = find_platform_sdk_dir() | def finalize_options(self): build_ext.finalize_options(self) self.windows_h_version = None # The pywintypes library is created in the build_temp # directory, so we need to add this to library_dirs self.library_dirs.append(self.build_temp) self.mingw32 = (self.compiler == "mingw32") if self.mingw32: self.libraries.appen... |
svcArgs = string.join(args[1:]) exeName = LocateSpecificServiceExe(serviceName) try: os.system("%s -debug %s %s" % (exeName, serviceName, svcArgs)) except KeyboardInterrupt: pass if len(args)<>1: usage() | if not hasattr(sys, "frozen"): svcArgs = string.join(args[1:]) exeName = LocateSpecificServiceExe(serviceName) try: os.system("%s -debug %s %s" % (exeName, serviceName, svcArgs)) except KeyboardInterrupt: pass else: DebugService(cls, args) if not knownArg and len(args)<>1: usage() | def HandleCommandLine(cls, serviceClassString = None, argv = None, customInstallOptions = "", customOptionHandler = None): """Utility function allowing services to process the command line. Allows standard commands such as 'start', 'stop', 'debug', 'install' etc. Install supports 'standard' command line options prefi... |
print "Installing service %s to Python class %s" % (serviceName,serviceClassString) | print "Installing service %s" % (serviceName,) | def HandleCommandLine(cls, serviceClassString = None, argv = None, customInstallOptions = "", customOptionHandler = None): """Utility function allowing services to process the command line. Allows standard commands such as 'start', 'stop', 'debug', 'install' etc. Install supports 'standard' command line options prefi... |
return win32com.client.dynamic.Dispatch(ob, "ADSI_object", ADSIDispatch) | name = "Dispatch wrapper around %r" % ob return win32com.client.dynamic.Dispatch(ob, name, ADSIDispatch) | def _get_good_ret(ob, # Named arguments used internally resultCLSID = None): assert resultCLSID is None, "Now have type info for ADSI objects - fix me!" # See if the object supports IDispatch if hasattr(ob, "Invoke"): import win32com.client.dynamic return win32com.client.dynamic.Dispatch(ob, "ADSI_object", ADSIDispatch... |
ret = getattr(self._oleobj_, attr, None) if ret is None: ret = win32com.client.CDispatch.__getattr__(self, attr) return ret | try: return getattr(self._oleobj_, attr) except AttributeError: return win32com.client.CDispatch.__getattr__(self, attr) | def __getattr__(self, attr): ret = getattr(self._oleobj_, attr, None) if ret is None: ret = win32com.client.CDispatch.__getattr__(self, attr) return ret |
global htmlhelp_handle | def FinalizeHelp(): if htmlhelp_handle is not None: import win32help global htmlhelp_handle try: #frame = win32ui.GetMainFrame().GetSafeHwnd() frame = 0 win32help.HtmlHelp(frame, None, win32help.HH_UNINITIALIZE, htmlhelp_handle) except win32help.error: print "Failed to finalize htmlhelp!" htmlhelp_handle = None | |
global helpIDMap | def SetHelpMenuOtherHelp(mainMenu): """Modifies the main Help Menu to handle all registered help files. mainMenu -- The main menu to modify - usually from docTemplate.GetSharedMenu() """ # Load all help files from the registry. if helpIDMap is None: global helpIDMap helpIDMap = {} cmdID = win32ui.ID_HELP_OTHER exclude... | |
control.SCIEnsureVisible(control.LineFromChar(foundSel)) | control.SCIEnsureVisible(control.LineFromChar(foundSel[0])) | def _FindIt(control, searchParams): global lastSearch control = _GetControl(control) # Move to the next char, so we find the next one. flags = 0 if searchParams.matchWords: flags = flags | win32con.FR_WHOLEWORD if searchParams.matchCase: flags = flags | win32con.FR_MATCHCASE if searchParams.sel == (-1,-1): sel = contr... |
event_commands.append(event, val) | event_commands.append((event, val)) | def _CreateEvents(): for name in _event_commands: val = eval(name) name_parts = string.split(name, "_")[1:] name_parts = map(string.capitalize, name_parts) event =string.join(name_parts,'') event_commands.append(event, val) for name, id in _extra_event_commands: event_commands.append(name, id) |
event_commands.append(name, id) | event_commands.append((name, id)) | def _CreateEvents(): for name in _event_commands: val = eval(name) name_parts = string.split(name, "_")[1:] name_parts = map(string.capitalize, name_parts) event =string.join(name_parts,'') event_commands.append(event, val) for name, id in _extra_event_commands: event_commands.append(name, id) |
if not pInfo.GetPreview() and self.starts is not None and self.starts[pInfo.GetCurPage()] >= self.GetTextLength(): pInfo.SetContinuePrinting(0) return | if not pInfo.GetPreview() and self.starts is not None: prevPage = pInfo.GetCurPage() - 1 if prevPage > 0 and self.starts[prevPage] >= self.GetTextLength(): pInfo.SetContinuePrinting(0) return | def OnPrepareDC (self, dc, pInfo): |
self.HookMessage(self.OnLDoubleClick,win32con.WM_LBUTTONDBLCLK) | def HookHandlers(self): # Hook for finding and locating error messages self.HookMessage(self.OnLDoubleClick,win32con.WM_LBUTTONDBLCLK) # Hook for the right-click menu. self.HookMessage(self.OnRClick,win32con.WM_RBUTTONDOWN) | |
def OnLDoubleClick(self,params): if self.HandleSpecialLine(): return 0 return 1 | def OnLDoubleClick(self,params): if self.HandleSpecialLine(): return 0 # dont pass on return 1 # pass it on by default. | |
if line[:11]=="com_error: ": try: import win32api, win32con det = eval(string.strip(line[string.find(line,":")+1:])) win32ui.SetStatusText("Opening help file on OLE error..."); win32api.WinHelp(win32ui.GetMainFrame().GetSafeHwnd(),det[2][3],win32con.HELP_CONTEXT, det[2][4]) return 1 except win32api.error, details: tr... | def HandleSpecialLine(self): import scriptutils line = self.GetLine() matchResult = self.patErrorMessage.match(line) if matchResult<=0: # No match - try the next line lineNo = self.LineFromChar() if lineNo > 0: line = self.GetLine(lineNo-1) matchResult = self.patErrorMessage.match(line) if matchResult>0: # we have an e... | |
raise TypeError, "Expected %s return values, got: %s" % (len(outTup), len(retVal)) | raise TypeError, "Expected %s return values, got: %s" % (len(meth._gw_out_args) + 1, len(retVal)) | def dispatch(self, ob, index, argPtr, ReadFromInTuple=_univgw.ReadFromInTuple, WriteFromOutTuple=_univgw.WriteFromOutTuple): "Dispatch a call to an interface method." |
except win32api.error: | except (AttributeError,win32api.error): | def _find_localserver_exe(mustfind): if pythoncom.__file__.find("_d") < 0: exeBaseName = "pythonw.exe" else: exeBaseName = "pythonw_d.exe" # First see if in the same directory as this .EXE exeName = os.path.join( os.path.split(sys.executable)[0], exeBaseName ) if not os.path.exists(exeName): # See if in our sys.prefix ... |
dispatcherSpec = "win32com.server.dispatcher.DispatcherWin32trace" | dispatcherSpec = "win32com.server.dispatcher.DefaultDebugDispatcher" | def RegisterClasses(*classes, **flags): quiet = flags.has_key('quiet') and flags['quiet'] debugging = flags.has_key('debug') and flags['debug'] for cls in classes: clsid = cls._reg_clsid_ progID = _get(cls, '_reg_progid_') desc = _get(cls, '_reg_desc_', progID) spec = _get(cls, '_reg_class_spec_') verProgID = _get(cls,... |
return pos | return max(pos, 0) | def TkIndexToOffset(bm, edit, marks): base, nextTokPos = _NextTok(bm, 0) if base is None: raise ValueError, "Empty bookmark ID!" if string.find(base,".")>0: try: line, col = string.split(base, ".", 2) if col=="first" or col=="last": # Tag name if line != "sel": raise ValueError, "Tags arent here!" sel = edit.GetSel() i... |
clib_files = (['win32', 'pywintypes.lib'], ['win32com', 'pythoncom.lib']) | clib_files = (['win32', 'pywintypes%s.lib'], ['win32com', 'pythoncom%s.lib']) | def build_extensions(self): # Is there a better way than this? # Just one GUIDS.CPP and it gives trouble on mainwin too # Maybe I should just rename the file, but a case-only rename is likely to be # worse! if ".CPP" not in self.compiler.src_extensions: self.compiler._cpp_extensions.append(".CPP") self.compiler.src_ext... |
os.path.join(self.build_temp, clib_file[1]), target_dir) | os.path.join(self.build_temp, fname), target_dir) | def build_extensions(self): # Is there a better way than this? # Just one GUIDS.CPP and it gives trouble on mainwin too # Maybe I should just rename the file, but a case-only rename is likely to be # worse! if ".CPP" not in self.compiler.src_extensions: self.compiler._cpp_extensions.append(".CPP") self.compiler.src_ext... |
result = _wrap(DebugProperty(self.code, self.hresult, self.result), axdebug.IID_IDebugProperty) | result = _wrap(DebugProperty(self.code, self.result, None, self.hresult), axdebug.IID_IDebugProperty) | def GetResultAsDebugProperty(self): result = _wrap(DebugProperty(self.code, self.hresult, self.result), axdebug.IID_IDebugProperty) return self.hresult, result |
DBGPROP_INFO_NAME = 0x1 DBGPROP_INFO_TYPE = 0x2 DBGPROP_INFO_VALUE = 0x4 DBGPROP_INFO_FULLNAME = 0x20 DBGPROP_INFO_ATTRIBUTES = 0x8 DBGPROP_INFO_DEBUGPROP = 0x10 DBGPROP_INFO_AUTOEXPAND = 0x8000000 | def MakeEnumDebugProperty(object, dwFieldSpec, nRadix, iid): name_vals = [] if hasattr(object, "has_key"): name_vals = object.items() infos = [] for name, val in name_vals: infos.append(GetPropertyInfo(name, val, dwFieldSpec, nRadix, 0)) return _wrap(EnumDebugPropertyInfo(infos), axdebug.IID_IEnumDebugPropertyInfo) de... | def GetResultAsDebugProperty(self): result = _wrap(DebugProperty(self.code, self.hresult, self.result), axdebug.IID_IDebugProperty) return self.hresult, result |
def __init__(self, code, hresult, result): self.code = code | def __init__(self, name, value, parent = None, hresult = 0): self.name = name self.value = value self.parent = parent | def __init__(self, code, hresult, result): self.code = code self.hresult = hresult self.result = result |
self.result = result | def __init__(self, code, hresult, result): self.code = code self.hresult = hresult self.result = result | |
name = typ = value = fullname = None if dwFieldSpec & DBGPROP_INFO_VALUE: value = MakeNiceString(self.result) if dwFieldSpec & DBGPROP_INFO_NAME: name = self.code if dwFieldSpec & DBGPROP_INFO_TYPE: if self.hresult: typ = "Error" else: try: typ = type(self.result).__name__ except AttributeError: typ = str(type(self.res... | return GetPropertyInfo(self.name, self.value, dwFieldSpec, nRadix, hresult=self.hresult) | def GetPropertyInfo(self, dwFieldSpec, nRadix): # returns a tuple name = typ = value = fullname = None if dwFieldSpec & DBGPROP_INFO_VALUE: value = MakeNiceString(self.result) if dwFieldSpec & DBGPROP_INFO_NAME: name = self.code if dwFieldSpec & DBGPROP_INFO_TYPE: if self.hresult: typ = "Error" else: try: typ = type(se... |
RaiseNotImpl("DebugProperty::EnumMembers") | return MakeEnumDebugProperty(self.value, dwFieldSpec, nRadix, iid) | def EnumMembers(self, dwFieldSpec, nRadix, iid): # Returns IEnumDebugPropertyInfo RaiseNotImpl("DebugProperty::EnumMembers") |
self.SCIMarkerDeleteAll() | def OnInitialUpdate(self): SyntEditViewParent.OnInitialUpdate(self) | |
self.Colorize() | def OnMarginClick(self, std, extra): notify = self.SCIUnpackNotifyMessage(extra) if notify.margin==2: # Our fold margin line_click = self.LineFromChar(notify.position) | |
self.FoldExpandAllEvent(None) | def OnUpdateViewFold(self, cmdui): # Update the tick on the UI. if not self.bFolding: cmdui.Enable(0) return | |
def OnCmdViewFoldTopLevel(self, cid, code): self.FoldTopLevelEvent(None) | def OnUpdateViewFold(self, cmdui): # Update the tick on the UI. if not self.bFolding: cmdui.Enable(0) return | |
self.Colorize() | def FoldCollapseEvent(self, event): if not self.bFolding: win32api.MessageBeep() return win32ui.DoWaitCursor(1) self.Colorize() lineno = self.LineFromChar(self.GetSel()[0]) if self.SCIGetFoldLevel(lineno) & SC_FOLDLEVELHEADERFLAG and \ self.SCIGetFoldExpanded(lineno): self.SCIToggleFold(lineno) win32ui.DoWaitCursor(-1) | |
Requires the win32dbg package. | Requires Pythonwin. | def _trace_(self, *args): for arg in args[:-1]: win32api.OutputDebugString(str(arg)+" ") win32api.OutputDebugString(str(args[-1])+"\n") |
import win32dbg win32dbg.brk() | import pywin.debugger pywin.debugger.brk() | def __init__(self, policyClass, ob): import win32dbg win32dbg.brk() # DEBUGGER Note - You can either: # * Hit Run and wait for a (non Exception class) exception to occur! # * Set a breakpoint and hit run. # * Step into the object creation (a few steps away!) DispatcherBase.__init__(self, policyClass, ob) |
import win32dbg, win32dbg.dbgcon | import pywin.debugger, pywin.debugger.dbgcon | def _HandleException_(self): """ Invoke the win32dbg post mortem capability """ # Save details away. typ, val, tb = exc_info() import win32dbg, win32dbg.dbgcon debug = 0 try: raise typ, val except Exception: # AARG - What is this Exception??? # Use some inside knowledge to borrow a Debugger option which dictates if we ... |
debug = win32dbg.GetDebugger().get_option(win32dbg.dbgcon.OPT_STOP_EXCEPTIONS) | debug = pywin.debugger.GetDebugger().get_option(pywin.debugger.dbgcon.OPT_STOP_EXCEPTIONS) | def _HandleException_(self): """ Invoke the win32dbg post mortem capability """ # Save details away. typ, val, tb = exc_info() import win32dbg, win32dbg.dbgcon debug = 0 try: raise typ, val except Exception: # AARG - What is this Exception??? # Use some inside knowledge to borrow a Debugger option which dictates if we ... |
win32dbg.post_mortem(tb, typ, val) | pywin.debugger.post_mortem(tb, typ, val) | def _HandleException_(self): """ Invoke the win32dbg post mortem capability """ # Save details away. typ, val, tb = exc_info() import win32dbg, win32dbg.dbgcon debug = 0 try: raise typ, val except Exception: # AARG - What is this Exception??? # Use some inside knowledge to borrow a Debugger option which dictates if we ... |
self.vt, self.inOut, self.GUID = arg_info | self.vt, self.inOut, self.default, self.clsid = arg_info | def __init__(self, arg_info, name = None): self.name = name self.vt, self.inOut, self.GUID = arg_info self.size = _CalcTypeSize(arg_info) # Offset from the beginning of the arguments of the stack. self.offset = 0 |
l.append((arg.vt, arg.offset, arg.size)) | l.append((arg.vt, arg.offset, arg.size, arg.clsid)) | def _GenerateOutArgTuple(self): # Given a method, generate the out argument tuple l = [] for arg in self.args: if arg.inOut & pythoncom.PARAMFLAG_FOUT or \ arg.inOut & pythoncom.PARAMFLAG_FRETVAL or \ arg.inOut == 0: l.append((arg.vt, arg.offset, arg.size)) return tuple(l) |
def ScpDelete(service_class_name, container_name = None, dn = None): container_name = container_name or service_class_name | def ScpDelete(container_name, dn = None): | def ScpDelete(service_class_name, container_name = None, dn = None): container_name = container_name or service_class_name if dn is None: dn = win32api.GetComputerObjectName(win32con.NameFullyQualifiedDN) logger.debug("Removing connection point from %s", dn) # Compose the ADSpath and bind to the computer object for th... |
logger.debug("Removing connection point from %s", dn) | logger.debug("Removing connection point '%s' from %s", container_name, dn) | def ScpDelete(service_class_name, container_name = None, dn = None): container_name = container_name or service_class_name if dn is None: dn = win32api.GetComputerObjectName(win32con.NameFullyQualifiedDN) logger.debug("Removing connection point from %s", dn) # Compose the ADSpath and bind to the computer object for th... |
else: dlg=win32ui.CreatePrintDialog(dlgID, printSetupOnly, flags, parent, self.dll) | dlg=win32ui.CreatePrintDialog(dlgID, printSetupOnly, flags, parent, self.dll) | def __init__(self, pInfo, dlgID, printSetupOnly = 0, flags=(win32ui.PD_ALLPAGES| win32ui.PD_USEDEVMODECOPIES| win32ui.PD_NOPAGENUMS| win32ui.PD_HIDEPRINTTOFILE| win32ui.PD_NOSELECTION), parent=None, dllid=None): self.dll=dllFromDll(dllid) if type(dlgID)==type([]): # a template raise TypeError, "dlgID parameter must be ... |
self.pInfo.SetHDC(self.pInfo.CreatePrinterDC()) | self.pInfo.CreatePrinterDC() return self._obj_.OnInitDialog() | def OnInitDialog(self): self.pInfo.SetHDC(self.pInfo.CreatePrinterDC()) |
return tuple(map(lambda o, s=self, oun=obUserName, rc=resultCLSID: s._get_good_single_object_(o, oun, rc), obj)) | obUserNameTuple = (obUserName,) * len(obj) resultCLSIDTuple = (resultCLSID,) * len(obj) return tuple(map(self._get_good_object_, obj, obUserNameTuple, resultCLSIDTuple)) | def _get_good_object_(self, obj, obUserName=None, resultCLSID=None): if obj is None: return None elif type(obj)==TupleType: return tuple(map(lambda o, s=self, oun=obUserName, rc=resultCLSID: s._get_good_single_object_(o, oun, rc), obj)) else: return self._get_good_single_object_(obj, obUserName, resultCLSID) |
cmd = '%s "%s" > nul' % (win32api.GetModuleFileName(0), filename) | cmd = '%s "%s" > nul 2>&1' % (win32api.GetModuleFileName(0), filename) | def RegisterPythonServer(filename, verbose=0): cmd = '%s "%s" > nul' % (win32api.GetModuleFileName(0), filename) if verbose: print "Registering engine", filename |
class TestCaseMixin: def _preTest(self): self.ni = _GetInterfaceCount() self.ng = _GetGatewayCount() def _postTest(self, result): | class LeakTestCase(unittest.TestCase): def __init__(self, real_test): unittest.TestCase.__init__(self) self.real_test = real_test self.num_test_cases = 1 self.num_leak_iters = 2 if hasattr(sys, "gettotalrefcount"): self.num_test_cases = self.num_test_cases + self.num_leak_iters def countTestCases(self): return self.num... | def get_num_lines_captured(self): return len("".join(self.captured).split("\n")) |
lost_i = _GetInterfaceCount() - self.ni lost_g = _GetGatewayCount() - self.ng | ni = _GetInterfaceCount() ng = _GetGatewayCount() self.real_test(result) if result.shouldStop or not result.wasSuccessful(): return self._do_leak_tests(result) gc.collect() lost_i = _GetInterfaceCount() - ni lost_g = _GetGatewayCount() - ng | def _postTest(self, result): gc.collect() lost_i = _GetInterfaceCount() - self.ni lost_g = _GetGatewayCount() - self.ng if lost_i or lost_g: msg = "%d interface objects and %d gateway objects leaked" \ % (lost_i, lost_g) result.addFailure(self, (AssertionError, msg, None)) |
result.addFailure(self, (AssertionError, msg, None)) def assertRaisesCOM_HRESULT(self, hresult, func, *args, **kw): | result.addFailure(self.real_test, (AssertionError, msg, None)) def _do_leak_tests(self, result = None): | def _postTest(self, result): gc.collect() lost_i = _GetInterfaceCount() - self.ni lost_g = _GetGatewayCount() - self.ng if lost_i or lost_g: msg = "%d interface objects and %d gateway objects leaked" \ % (lost_i, lost_g) result.addFailure(self, (AssertionError, msg, None)) |
func(*args, **kw) except pythoncom.com_error, details: if details[0]==hresult: return self.fail("Excepected COM exception with HRESULT 0x%x" % hresult) class TestCase(unittest.TestCase, TestCaseMixin): def __call__(self, result=None): if result is None: result = self.defaultTestResult() self._preTest() try: unittest.T... | gtrc = sys.gettotalrefcount except AttributeError: return def gtrc(): return 0 trc = gtrc() for i in range(self.num_leak_iters): self.real_test(result) if result.shouldStop: break del i lost = (gtrc() - trc) // self.num_leak_iters if lost < 0: msg = "LeakTest: %s appeared to gain %d references!!" % (self.real_test, ... | def assertRaisesCOM_HRESULT(self, hresult, func, *args, **kw): try: func(*args, **kw) except pythoncom.com_error, details: if details[0]==hresult: return self.fail("Excepected COM exception with HRESULT 0x%x" % hresult) |
self._preTest() | def __call__(self, result=None): if result is None: result = self.defaultTestResult() writer = CaptureWriter() self._preTest() writer.capture() try: unittest.FunctionTestCase.__call__(self, result) finally: writer.release() self._postTest(result) self.checkOutput(writer.get_captured(), result) | |
self._postTest(result) self.checkOutput(writer.get_captured(), result) | output = writer.get_captured() self.checkOutput(output, result) if result.showAll: print output | def __call__(self, result=None): if result is None: result = self.defaultTestResult() writer = CaptureWriter() self._preTest() writer.capture() try: unittest.FunctionTestCase.__call__(self, result) finally: writer.release() self._postTest(result) self.checkOutput(writer.get_captured(), result) |
if not isinstance(type, UnicodeType): | if not isinstance(item, UnicodeType): | def QueueFlush(self, max = sys.maxint): # Returns true if the queue is empty after the flush |
if isinstance(type, UnicodeType): | if isinstance(item, UnicodeType): | def QueueFlush(self, max = sys.maxint): # Returns true if the queue is empty after the flush |
resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) | try: resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) except pythoncom.com_error, details: if details[0] in [winerror.TYPE_E_CANTLOADLIBRARY, winerror.TYPE_E_LIBNOTREGISTERED]: return pythoncom.VT_UNKNOWN, None, None raise | def _ResolveType(typerepr, itypeinfo): # Resolve VT_USERDEFINED (often aliases or typed IDispatches) if type(typerepr)==types.TupleType: indir_vt, subrepr = typerepr if indir_vt == pythoncom.VT_PTR: # If it is a VT_PTR to a VT_USERDEFINED that is an IDispatch/IUnknown, # then it resolves to simply the object. # Otherw... |
oldOut = sys.stdout | def generate_child(self, child, dir): "Generate a single child. May force a few children to be built as we generate deps" self.generate_type = GEN_DEMAND_CHILD oldOut = sys.stdout | |
sys.stdout = self.file | def generate_child(self, child, dir): "Generate a single child. May force a few children to be built as we generate deps" self.generate_type = GEN_DEMAND_CHILD oldOut = sys.stdout |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.