rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
import threading
import pywin.mfc.thread
def SaveModified(self): # Called as the document is closed. If we are about # to prompt for a save, bring the document to the foreground. if self.IsModified(): frame = self.GetFirstView().GetParentFrame() try: frame.MDIActivate() frame.AutoRestore() except: print "Could not bring document to foreground" return self._o...
class FileWatchingThread(threading.Thread):
class FileWatchingThread(pywin.mfc.thread.WinThread):
def SaveModified(self): # Called as the document is closed. If we are about # to prompt for a save, bring the document to the foreground. if self.IsModified(): frame = self.GetFirstView().GetParentFrame() try: frame.MDIActivate() frame.AutoRestore() except: print "Could not bring document to foreground" return self._o...
threading.Thread.__init__(self)
pywin.mfc.thread.WinThread.__init__(self)
def __init__(self, doc): self.doc = doc self.adminEvent = win32event.CreateEvent(None, 0, 0, None) self.stopEvent = win32event.CreateEvent(None, 0, 0, None) self.watchEvent = None threading.Thread.__init__(self)
def stop(self):
def SignalStop(self):
def stop(self): win32event.SetEvent(self.stopEvent)
if refAttr.typekind == pythoncom.TKIND_DISPATCH:
if refAttr.typekind == pythoncom.TKIND_DISPATCH or \ (refAttr.typekind == pythoncom.TKIND_INTERFACE and refAttr[11] & pythoncom.TYPEFLAG_FDISPATCHABLE):
def _Build_CoClassChildren(self, coclass, coclass_info, oleItems, vtableItems): sources = {} interfaces = {} for info, info_type, refType, doc, refAttr, flags in coclass_info:
if infotype == pythoncom.TKIND_DISPATCH:
if infotype == pythoncom.TKIND_DISPATCH or \ (infotype == pythoncom.TKIND_INTERFACE and attr[11] & pythoncom.TYPEFLAG_FDISPATCHABLE):
def _Build_Interface(self, type_info_tuple): info, infotype, doc, attr = type_info_tuple oleItem = vtableItem = None if infotype == pythoncom.TKIND_DISPATCH: oleItem = DispatchItem(info, attr, doc) # If this DISPATCH interface dual, then build that too. if (attr.wTypeFlags & pythoncom.TYPEFLAG_FDUAL):
menuitem_fmt = '9IP2I'
menuitem_fmt = '9iP2i'
def UnpackWMNOTIFY(lparam): format = "iii" buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, idFrom, code = struct.unpack(format, buf) code += 0x4f0000 # hrm - wtf - commctrl uses this, and it works with mfc. *sigh* return hwndFrom, idFrom, code
fMask |= win32con.MMIM_CHECKMARKS
fMask |= win32con.MIIM_CHECKMARKS
def PackMENUITEMINFO(fType=None, fState=None, wID=None, hSubMenu=None, hbmpChecked=None, hbmpUnchecked=None, dwTypeData=None, text=None, hbmpItem=None): # 'extras' are objects the caller must keep a reference to (as their # memory is used) for the lifetime of the INFO item. extras = [] fMask = 0 if fType is None: fType...
cb,
(cb,
def UnpackMENUITEMINFO(s): cb, fMask, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, lptext, cch, hbmpItem = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None if fMask & win32con.MIIM_STATE==0: fState = None if fMask & win32con.MIIM_ID==0: wID = None...
hbmpItem = struct.unpack(menuitem_fmt, s)
hbmpItem) = struct.unpack(menuitem_fmt, s)
def UnpackMENUITEMINFO(s): cb, fMask, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, lptext, cch, hbmpItem = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None if fMask & win32con.MIIM_STATE==0: fState = None if fMask & win32con.MIIM_ID==0: wID = None...
text = PyGetString(lptext, cch)
text = win32gui.PyGetString(lptext, cch)
def UnpackMENUITEMINFO(s): cb, fMask, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, lptext, cch, hbmpItem = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None if fMask & win32con.MIIM_STATE==0: fState = None if fMask & win32con.MIIM_ID==0: wID = None...
return fType, fState, wID, hSubMenu, bmpChecked, bmpUnchecked, \ dwTypeData, text, hbmpItem
return fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, \ dwItemData, text, hbmpItem def EmptyMENUITEMINFO(mask = None, text_buf_size=512): extra = [] if mask is None: mask = win32con.MIIM_BITMAP | win32con.MIIM_CHECKMARKS | \ win32con.MIIM_DATA | win32con.MIIM_FTYPE | \ win32con.MIIM_ID | win32con.MIIM_STATE...
def UnpackMENUITEMINFO(s): cb, fMask, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwItemData, lptext, cch, hbmpItem = struct.unpack(menuitem_fmt, s) assert cb==len(s) if fMask & win32con.MIIM_FTYPE==0: fType = None if fMask & win32con.MIIM_STATE==0: fState = None if fMask & win32con.MIIM_ID==0: wID = None...
item_old = UnpackTVItem(buf_old) item_new = UnpackTVItem(buf_new)
item_old = UnpackTVITEM(buf_old) item_new = UnpackTVITEM(buf_new)
def UnpackTVNOTIFY(lparam): format = "iiii40s40s" buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, id, code, action, buf_old, buf_new \ = struct.unpack(format, buf) item_old = UnpackTVItem(buf_old) item_new = UnpackTVItem(buf_new) return hwndFrom, id, code, action, item_old, item_new
item = UnpackTVItem(buf_item)
item = UnpackTVITEM(buf_item)
def UnpackTVDISPINFO(lparam): format = "iii40s" buf = win32gui.PyMakeBuffer(struct.calcsize(format), lparam) hwndFrom, id, code, buf_item = struct.unpack(format, buf) item = UnpackTVItem(buf_item) return hwndFrom, id, code, item
views[0].SCISetSavePoint()
self._DocumentStateChanged()
def ReloadDocument(self): """Reloads the document from disk. Assumes the file has been saved and user has been asked if necessary - it just does it! """ win32ui.SetStatusText("Reloading document. Please wait...", 1) self.SetModifiedFlag(0) # Loop over all views, saving their state, then reload the document views = se...
if not self.scModuleName:
pretend_ss = 0 if not self.scModuleName and not pretend_ss:
def MakeDocumentWritable(self): if not self.scModuleName: # No Source Control support. win32ui.SetStatusText("Document is read-only, and no source-control system is configured") win32api.MessageBeep() return 0
rc = os.system("cscript testPyScriptlet.js") if rc: print "testPyScriptlet failed - has Scriptlets been installed and 'Testpys.sct' been registered?!!!"
try: win32com.client.Dispatch("TestPys.Scriptlet") rc = os.system("cscript testPyScriptlet.js") except pythoncom.error: print "Can not test 'Scriptlets' - has Scriptlets been installed and 'Testpys.sct' been registered???"
def Prepare(): import win32com, glob files = glob.glob(win32com.__gen_path__+"\\*") print "Deleting %d files from %s" % (len(files),win32com.__gen_path__) for f in files: os.unlink(f) import win32com.client.gencache win32com.client.gencache.__init__() # Reset
frame.SaveBarState("ToolbarDebugging")
def close(self, frameShutdown = 0): # abortClose indicates if we have total shutdown # (ie, main window is dieing) if self.pumping: # Can stop pump here, as it only posts a message, and # returns immediately. if not self.StopDebuggerPump(): # User cancelled close. return 0 # NOTE - from this point on the close can not ...
t,v,tb = None
tb = None
def GetTypeLibsForSpec(arg): """Given an argument on the command line (either a file name or a library description) return a list of actual typelibs to use. """ typelibs = [] try: try: tlb = pythoncom.LoadTypeLib(arg) spec = selecttlb.TypelibSpec(None, 0,0,0) spec.FromTypelib(tlb, arg) typelibs.append((tlb, spec)) exce...
win32ui.PumpWaitingMessages()
def QueueFlush(self, max = sys.maxint): # Returns true if the queue is empty after the flush
if pos>0:
if pos>=0:
def HandleOutput(self,message):
print "Reset called - had %d code blocks" % (len(self.codeBlocks))
def Reset(self): print "Reset called - had %d code blocks" % (len(self.codeBlocks)) # Reset all code-blocks that are persistent, and discard the rest oldCodeBlocks = self.codeBlocks[:] self.codeBlocks = [] for b in oldCodeBlocks: if b.flags & SCRIPTTEXT_ISPERSISTENT: b.beenExecuted = 0 self.codeBlocks.append(b) return ...
val = None
val = ""
def EnumKeys(root): index = 0 ret = [] while 1: try: item = win32api.RegEnumKey(root, index) except win32api.error: break try: # Note this doesn't handle REG_EXPAND_SZ, but the implementation # here doesn't need to - that is handled as the data is read. val = win32api.RegQueryValue(root, item) except win32api.error: va...
key4 = win32api.RegOpenKey(key3, "%s\win32" % (lcid,))
key4 = win32api.RegOpenKey(key3, "%s\\win32" % (lcid,))
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: try: key2 = win32api.RegOpenKey(key, str(iid)) except win32api.error: # A few good reaso...
if doc[1]: print '\t"""' + doc[1] + '"""'
if doc[1]: print '\t' + build._safeQQQ(doc[1])
def WriteClassHeader(self, generator): generator.checkWriteDispatchBaseClass() doc = self.doc print 'class ' + self.python_name + '(DispatchBaseClass):' if doc[1]: print '\t"""' + doc[1] + '"""' try: progId = pythoncom.ProgIDFromCLSID(self.clsid) print "\t# This class is creatable by the name '%s'" % (progId) except py...
if doc[1]: print '\t\"' + doc[1] + '\"'
if doc[1]: print '\t' + build._safeQQQ(doc[1])
def WriteEventSinkClassHeader(self, generator): generator.checkWriteEventBaseClass() doc = self.doc print 'class ' + self.python_name + ':' if doc[1]: print '\t\"' + doc[1] + '\"' try: progId = pythoncom.ProgIDFromCLSID(self.clsid) print "\t# This class is creatable by the name '%s'" % (progId) except pythoncom.com_err...
WinExt_win32com('adsi', libraries="ACTIVEDS ADSIID",
WinExt_win32com('adsi', libraries="ACTIVEDS ADSIID user32 advapi32",
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)
print "\t%s: %s," % (`record.doc[0]`, `str(record.clsid)`)
if str(record.clsid) == pythoncom.IID_NULL: print "\t else: print "\t%s: %s," % (`record.doc[0]`, `str(record.clsid)`)
def do_generate(self): moduleDoc = self.typelib.GetDocumentation(-1) docDesc = "" if moduleDoc[1]: docDesc = moduleDoc[1] self.progress.Starting(docDesc) self.progress.SetDescription("Building definitions from type library...")
data = a, data[1], data[2]
def search(): gc = getGC() if gc is None: log(0, "Can't find the global catalog") return prefs = [(ADS_SEARCHPREF_SEARCH_SCOPE, (ADS_SCOPE_SUBTREE,))] hr, statuses = gc.SetSearchPreference(prefs) log(3, "SetSearchPreference returned %d/%r", hr, statuses) if options.attributes: attributes = options.attributes.split(",...
if not disp.__dict__.get("CLSID"):
if not disp.__class__.__dict__.get("CLSID"):
... def OnVisible(self, visible):
self.extra_assemblies.append(glue.Assembly_Load(name))
self.extra_assemblies.append(glue.Assembly_LoadFrom(name))
def getCORType(self, typestring, really_need_it = 1): # First see if we have cached it. try: # Fastest case since we expect many cache hits. return self.corTypes[typestring] except KeyError: pass if self.extra_assemblies is None: self.extra_assemblies = [] if not self.options.no_python_runtime: try:
if user_sig: if func.varargs or func.kwargs: raise source_error("Dont support variable or kw args with a user-specified signature") arg_types = string.split(str(user_sig), ",") arg_types = map(string.strip, arg_types) arg_types = map(self.compiler.getCORType, arg_types) if (not func.is_instance_method and len(arg_types...
ret_type = find_compiler_directive(func.code, "_com_return_type_") if user_sig or ret_type: if user_sig: if func.varargs or func.kwargs: raise source_error("Dont support variable or kw args with a user-specified signature") arg_types = string.split(str(user_sig), ",") arg_types = map(string.strip, arg_types) arg_types ...
def n_function(self, node): func = node func.is_instance_method = self.cctx is not None and self.fctx is None func.is_ctor = func.is_instance_method and func.name=='__init__'
if type(arg) == IDispatchType:
arg_type = type(arg) if arg_type == IDispatchType:
def _transform_args_(self, args, kwArgs, dispid, lcid, wFlags, serviceProvider): ret = [] for arg in args: if type(arg) == IDispatchType: import win32com.client arg = win32com.client.Dispatch(arg) elif not core_has_unicode and type(arg)==UnicodeType: arg = str(arg) ret.append(arg) return tuple(ret), kwArgs
elif not core_has_unicode and type(arg)==UnicodeType:
elif arg_type == IUnknownType: try: import win32com.client arg = win32com.client.Dispatch(arg.QueryInterface(pythoncom.IID_IDispatch)) except pythoncom.error: pass elif not core_has_unicode and arg_type==UnicodeType:
def _transform_args_(self, args, kwArgs, dispid, lcid, wFlags, serviceProvider): ret = [] for arg in args: if type(arg) == IDispatchType: import win32com.client arg = win32com.client.Dispatch(arg) elif not core_has_unicode and type(arg)==UnicodeType: arg = str(arg) ret.append(arg) return tuple(ret), kwArgs
if os.path.exists(dst): msg = "The file '%s' exists, but can not be replaced " \ "due to insufficient permissions. You must " \ "reinstall this software as an Administrator" \ % dst raise RuntimeError, msg
def install(): import distutils.sysconfig import traceback # Create the .pth file in the site-packages dir, and use only relative paths lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1) # Used to write this directly to sys.prefix - clobber it. if os.path.isfile(os.path.join(sys.prefix, "pywin32.pth")): os.u...
now_status = QueryServiceStatus(serviceName)[1]
now_status = QueryServiceStatus(serviceName, machine)[1]
def WaitForServiceStatus(serviceName, status, waitSecs, machine=None): """Waits for the service to return the specified status. You should have already requested the service to enter that state""" for i in range(waitSecs*4): now_status = QueryServiceStatus(serviceName)[1] if now_status == status: break win32api.Sleep(...
exeName = "PythonService_d.exe"
exeName = "PythonService.exe"
def LocatePythonServiceExe(exeName = None): # Try and find the specified EXE somewhere. If specifically registered, # use it. Otherwise look down sys.path, and the global PATH environment. if exeName is None: if win32service.__file__.find("_d")>=0: exeName = "PythonService_d.exe" else: exeName = "PythonService_d.exe"...
if _PyIDispatchType==type(obj): return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions) elif NeedUnicodeConversions and UnicodeType==type(obj): return str(obj) return obj
return _get_good_single_object_(obj, obUserName, resultCLSID)
def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): if _PyIDispatchType==type(obj): return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions) elif NeedUnicodeConversions and UnicodeType==type(obj): return str(obj) return obj
if obj is None: return None elif type(obj)==TupleType: obUserNameTuple = (obUserName,) * len(obj) resultCLSIDTuple = (resultCLSID,) * len(obj) return tuple(map(self._get_good_object_, obj, obUserNameTuple, resultCLSIDTuple)) else: return self._get_good_single_object_(obj, obUserName, resultCLSID)
return _get_good_object_(obj, obUserName, resultCLSID) def _get_good_single_object_(obj, obUserName=None, resultCLSID=None): if _PyIDispatchType==type(obj): return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions) elif NeedUnicodeConversions and UnicodeType==type(obj): return str(obj) ret...
def _get_good_object_(self, obj, obUserName=None, resultCLSID=None): if obj is None: return None elif type(obj)==TupleType: obUserNameTuple = (obUserName,) * len(obj) resultCLSIDTuple = (resultCLSID,) * len(obj) return tuple(map(self._get_good_object_, obj, obUserNameTuple, resultCLSIDTuple)) else: return self._get_goo...
addPyComCat=not hasattr(sys, 'frozen'),
addPyComCat=None,
def RegisterServer(clsid, pythonInstString=None, desc=None, progID=None, verProgID=None, defIcon=None, threadingModel="both", policy=None, catids=[], other={}, # Default is to register in Python categories when not frozen addPyComCat=not hasattr(sys, 'frozen'), dispatcher = None, clsctx = None, addnPath = None, ): """R...
of Python servers installed on the machine.
of Python servers installed on the machine. If None (the default) then it will be registered when running from python source, but not registered if running in a frozen environment.
def RegisterServer(clsid, pythonInstString=None, desc=None, progID=None, verProgID=None, defIcon=None, threadingModel="both", policy=None, catids=[], other={}, # Default is to register in Python categories when not frozen addPyComCat=not hasattr(sys, 'frozen'), dispatcher = None, clsctx = None, addnPath = None, ): """R...
addPyComCat = not _get(cls, '_reg_disable_pycomcat_', 0)
addPyComCat = not _get(cls, '_reg_disable_pycomcat_', pythoncom.frozen!=0)
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,...
scriptDir = os.path.split(sys.argv[0])[0] if not scriptDir: scriptDir = "."
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,...
addnPath = win32api.GetFullPathName(scriptDir)
if not pythoncom.frozen: scriptDir = os.path.split(sys.argv[0])[0] if not scriptDir: scriptDir = "." addnPath = win32api.GetFullPathName(scriptDir)
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,...
try: win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, 'Component Categories\\%s' % CATID_PythonCOMServer) except win32api.error: try: RegisterPyComCategory() except pythoncom.error: pass
if not pythoncom.frozen: try: win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, 'Component Categories\\%s' % CATID_PythonCOMServer) except win32api.error: try: RegisterPyComCategory() except pythoncom.error: pass
def RegisterPyComCategory(): """ Register the Python COM Server component category. """ regCat = _cat_registrar() regCat.RegisterCategories( [ (CATID_PythonCOMServer, 0x0409, "Python COM Server") ] )
dir_util.mkpath(build_temp, verbose=self.verbose, dry_run=self.dry_run)
self.mkpath(build_temp)
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...
file_util.copy_file(
self.copy_file(
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_lib, "pythonwin"), verbose = self.verbose, dry_run = self.dry_run)
os.path.join(self.build_lib, "pythonwin")) clib_files = (['win32', 'pywintypes.lib'], ['win32com', 'pythoncom.lib']) for clib_file in clib_files: target_dir = os.path.join(self.build_lib, clib_file[0], "libs") if not os.path.exists(target_dir): self.mkpath(target_dir) self.copy_file( os.path.join(self.build_temp, cli...
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...
nativeMethods = []
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
elif line[:2]=="//": rest = line[2:].strip() if rest.startswith("@pyswig"): doc, lineNo = GetComments(line, lineNo, lines) curMethod = doc[8:], [] methods.append(curMethod) elif rest.startswith("@pymeth "): doc, lineNo = GetComments(line, lineNo, lines) nativeMethods.append(line+doc)
else: try: pos = line.index("//") except ValueError: pass
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
if rest.startswith("@"):
rest = line[pos+2:].strip() if rest.startswith("@pymeth"): curMethod = None if rest.startswith("@doc"): pass elif rest.startswith("@pyswig"):
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
if curMethod: curMethod[1].append("// " + doc + '\n') else: extra_tags.append("// " + doc + '\n')
curMethod = doc[8:], [] methods.append(curMethod) elif rest.startswith("@const"): doc, lineNo = GetComments(line, lineNo, lines) else: if rest.startswith("@"): doc, lineNo = GetComments(line, lineNo, lines) if curMethod: curMethod[1].append("// " + doc + '\n') else: extra_tags.append("// " + doc + '\n')
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
assert len(nativeMethods) < max_methods method_num = len(nativeMethods)
method_num = 0
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
outFile.write("\n// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2]))
outFile.write("// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2]))
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
if chunk_number == 0: for meth in nativeMethods: outFile.write(meth) outFile.write("\n")
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
for extra in extra_tags: outFile.write("%s\n" % (extra) )
def make_doc_summary(inFile, outFile): methods = [] nativeMethods = [] modDoc = "" modName = "" lines = inFile.readlines() curMethod = None constants = [] extra_tags = [] lineNo = 0 bInRawBlock = 0 while lineNo < len(lines): line = lines[lineNo] if bInRawBlock and len(line)>2 and line[:2]=="%}": bInRawBlock = 0 if not ...
infos.append( ('Implements'), desc)
infos.append( ('Implements', desc))
def _GetMainInfoTypes(self): pos = self.typelb.GetCurSel() if pos<0: return [] docinfo = self.tlb.GetDocumentation(pos) infos = [('GUID', str(self.attr[0]))] infos.append(('Help File', docinfo[3])) infos.append(('Help Context', str(docinfo[2]))) try: infos.append(('Type Kind', typekindmap[self.tlb.GetTypeInfoType(pos)]...
def convert_optional_data_files(files): ret = [] for file in files: try: temp = convert_data_files([file]) except RuntimeError, details: if not str(details).startswith("No file"): raise print 'NOTE: Optional file %s not found - skipping' % file else: ret.append(temp[0]) return ret
def convert_data_files(files): base_dir = "Lib/site-packages" ret = [] for file in files: file = os.path.normpath(file) if file.find("*") >= 0: flist = FileList() flist.findall(os.path.dirname(file)) flist.include_pattern(os.path.basename(file)) # We never want CVS flist.exclude_pattern(re.compile(".*\\\\CVS\\\\"), is_...
data_files=convert_data_files([ 'pywin32.chm',
data_files=convert_optional_data_files([ 'PyWin32.chm', ]) + convert_data_files([
def convert_data_files(files): base_dir = "Lib/site-packages" ret = [] for file in files: file = os.path.normpath(file) if file.find("*") >= 0: flist = FileList() flist.findall(os.path.dirname(file)) flist.include_pattern(os.path.basename(file)) # We never want CVS flist.exclude_pattern(re.compile(".*\\\\CVS\\\\"), is_...
]) + \
]) +
def convert_data_files(files): base_dir = "Lib/site-packages" ret = [] for file in files: file = os.path.normpath(file) if file.find("*") >= 0: flist = FileList() flist.findall(os.path.dirname(file)) flist.include_pattern(os.path.basename(file)) # We never want CVS flist.exclude_pattern(re.compile(".*\\\\CVS\\\\"), is_...
return self.__dict__[name]
ret = self.__dict__[name] if type(ret)==type(()): ret = list(ret) return ret
def _dynamic_(self, name, lcid, wFlags, args): if wFlags & pythoncom.DISPATCH_METHOD: return apply(getattr(self,name),args)
handle = pythoncom.RegisterActiveObject(ob, iid, 0)
try: handle = pythoncom.RegisterActiveObject(ob, iid, 0) except pythoncom.com_error, details: print "Warning - could not register the object in the ROT:", details handle = None
def Test(): import win32com.server.util, win32com.server.policy
raise error, "Dynamic sequences not working!"
raise error, "Dynamic sequences not working! %r/%r" % (repr(v), repr(client.testSequence))
def Test(): import win32com.server.util, win32com.server.policy
pythoncom.RevokeActiveObject(handle)
if handle is not None: pythoncom.RevokeActiveObject(handle)
def Test(): import win32com.server.util, win32com.server.policy
def OnOpenDocument(self, name): rc = ParentEditorDocument.OnOpenDocument(self, name)
def OnOpenDocument(self, name): rc = ParentEditorDocument.OnOpenDocument(self, name)
self._DocumentStateChanged() return rc
def OnOpenDocument(self, name): rc = ParentEditorDocument.OnOpenDocument(self, name)
def DumpRoot(): "Dumps the root DSE" path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path)
def DumpRoot(): "Dumps the root DSE" path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) for item in rootdse.Get("SupportedLDAPVersion"): print "%s supports ldap version %s" % (path, item) attributes = ["CurrentTime", "defaultNamingContext"] for attr in attributes: val = rootdse.Get(attr) print " %s=%s" %...
for item in rootdse.Get("SupportedLDAPVersion"): print "%s supports ldap version %s" % (path, item) attributes = ["CurrentTime", "defaultNamingContext"] for attr in attributes: val = rootdse.Get(attr) print " %s=%s" % (attr, val)
class ADSIEnumerator: def __init__(self, ob): self._cont_ = ob.QueryInterface(IID_IADsContainer) self._oleobj_ = ADsBuildEnumerator(self._cont_) self.index = -1 def __getitem__(self, index): return self.__GetIndex(index) def __call__(self, index): return self.__GetIndex(index) def __GetIndex(self, index): if type(inde...
def DumpRoot(): "Dumps the root DSE" path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) for item in rootdse.Get("SupportedLDAPVersion"): print "%s supports ldap version %s" % (path, item) attributes = ["CurrentTime", "defaultNamingContext"] for attr in attributes: val = rootdse.Get(attr) print " %s=%s" %...
def _DumpClass(child): attrs = "Abstract lDAPDisplayName schemaIDGUID schemaNamingContext attributeSyntax oMSyntax" _DumpTheseAttributes(child, string.split(attrs)) def _DumpAttribute(child): attrs = "lDAPDisplayName schemaIDGUID adminDescription adminDisplayName rDNAttID defaultHidingValue defaultObjectCategory syste...
class ADSIDispatch(win32com.client.CDispatch): def _wrap_dispatch_(self, ob, userName = None, returnCLSID = None, UnicodeToString = win32com.client.NeedUnicodeConversions): if not userName: userName = "ADSI-object" olerepr = win32com.client.dynamic.MakeOleRepr(ob, None, None) return ADSIDispatch(ob, olerepr, userName, ...
def DumpRoot(): "Dumps the root DSE" path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) for item in rootdse.Get("SupportedLDAPVersion"): print "%s supports ldap version %s" % (path, item) attributes = ["CurrentTime", "defaultNamingContext"] for attr in attributes: val = rootdse.Get(attr) print " %s=%s" %...
def _DumpTheseAttributes(child, attrs): for attr in attrs:
def _NewEnum(self):
def _DumpTheseAttributes(child, attrs): for attr in attrs: try: val = child.Get(attr) except pythoncom.com_error, details: continue # ### (hr, msg, exc, arg) = details if exc and exc[2]: msg = exc[2] val = "<Error: %s>" % (msg,) if verbose_level >= 2: print " %s: %s=%s" % (child.Class, attr, val)
val = child.Get(attr) except pythoncom.com_error, details: continue (hr, msg, exc, arg) = details if exc and exc[2]: msg = exc[2] val = "<Error: %s>" % (msg,) if verbose_level >= 2: print " %s: %s=%s" % (child.Class, attr, val)
return ADSIEnumerator(self) except pythoncom.com_error: return win32com.client.CDispatch._NewEnum(self)
def _DumpTheseAttributes(child, attrs): for attr in attrs: try: val = child.Get(attr) except pythoncom.com_error, details: continue # ### (hr, msg, exc, arg) = details if exc and exc[2]: msg = exc[2] val = "<Error: %s>" % (msg,) if verbose_level >= 2: print " %s: %s=%s" % (child.Class, attr, val)
def DumpSchema(): "Dumps the default DSE schema" path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) name = rootdse.Get("schemaNamingContext") path= "LDAP://" + server + name print "Binding to", path ob = ADsGetObject(path) nclasses = nattr = nsub = nunk = 0
def __getattr__(self, attr): ret = getattr(self._oleobj_, attr, None) if ret is None: ret = win32com.client.CDispatch.__getattr__(self, attr) return ret def QueryInterface(self, iid): ret = self._oleobj_.QueryInterface(iid) return _get_good_ret(ret)
def DumpSchema(): "Dumps the default DSE schema" # Bind to rootDSE to get the schemaNamingContext property. path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) name = rootdse.Get("schemaNamingContext") # Bind to the actual schema container. path= "LDAP://" + server + name print "Binding to", path ob = ADsG...
for child in ob: class_name = child.Class if class_name == "classSchema": _DumpClass(child) nclasses = nclasses + 1 elif class_name == "attributeSchema": _DumpAttribute(child) nattr = nattr + 1 elif class_name == "subSchema": nsub = nsub + 1 else: print "Unknown class:", class_name nunk = nunk + 1 if verbose_level: pr...
_ADsGetObject = ADsGetObject def ADsGetObject(path, iid = pythoncom.IID_IDispatch): ret = _ADsGetObject(path, iid) return _get_good_ret(ret)
def DumpSchema(): "Dumps the default DSE schema" # Bind to rootDSE to get the schemaNamingContext property. path = "LDAP://%srootDSE" % server rootdse = ADsGetObject(path) name = rootdse.Get("schemaNamingContext") # Bind to the actual schema container. path= "LDAP://" + server + name print "Binding to", path ob = ADsG...
def _DumpObject(ob, level = 0): prefix = " " * level print "%s%s object: %s" % (prefix, ob.Class, ob.Name) try: dir_ob = ADsGetObject(ob.ADsPath, IID_IDirectoryObject) except pythoncom.com_error: dir_ob = None if dir_ob is not None: info = dir_ob.GetObjectInformation() print "%s RDN='%s', ObjectDN='%s'" % (prefix, in...
_ADsOpenObject = ADsOpenObject def ADsOpenObject(path, username, password, reserved = 0, iid = pythoncom.IID_IDispatch): ret = _ADsOpenObject(path, username, password, reserved, iid) return _get_good_ret(ret)
def _DumpObject(ob, level = 0): prefix = " " * level print "%s%s object: %s" % (prefix, ob.Class, ob.Name) # Do the directory object thing try: dir_ob = ADsGetObject(ob.ADsPath, IID_IDirectoryObject) except pythoncom.com_error: dir_ob = None if dir_ob is not None: info = dir_ob.GetObjectInformation() print "%s RDN='%s...
sCmd = "copy %s %s > NULL" % (lSrcFiles[i], file)
sCmd = "copy %s %s > NUL" % (lSrcFiles[i], file)
def main(): output = os.path.abspath(sys.argv[1]) target = sys.argv[2] f = open(output + ".hhp", "w") html_files = "" if len(sys.argv) > 2: # sys.argv[3] == html_dir # sys.argv[4:] == html_files (globbed) html_dir = os.path.abspath(sys.argv[3]) lGlobs = sys.argv[4:] lDestFiles, lSrcFiles = handle_globs(lGlobs) # ensu...
print "\t\treturn str(apply( self.__call__, args))"
print "\t\ttry:" print "\t\t\treturn str(apply( self.__call__, args))" print "\t\texcept pythoncom.com_error:" print "\t\t\treturn repr(self)"
print "\tdef __str__(self, *args):"
sources.append(dispItem, flags, dual)
sources.append((dispItem, flags, dual))
def BuildOleItemsFromType(self, look_name = None): oleItems = {} enumItems = {} aliasItems = {} for i in xrange(self.typelib.GetTypeInfoCount()): info = self.typelib.GetTypeInfo(i) infotype = self.typelib.GetTypeInfoType(i) doc = self.typelib.GetDocumentation(i) attr = info.GetTypeAttr() itemClass = None if infotype ==...
interfaces.append(dispItem, flags, dual)
interfaces.append((dispItem, flags, dual))
def BuildOleItemsFromType(self, look_name = None): oleItems = {} enumItems = {} aliasItems = {} for i in xrange(self.typelib.GetTypeInfoCount()): info = self.typelib.GetTypeInfo(i) infotype = self.typelib.GetTypeInfoType(i) doc = self.typelib.GetDocumentation(i) attr = info.GetTypeAttr() itemClass = None if infotype ==...
print ' print '
print ' if self.sourceFilename: print " print '
def do_gen_file_header(self): la = self.typelib.GetLibAttr() moduleDoc = self.typelib.GetDocumentation(-1) docDesc = "" if moduleDoc[1]: docDesc = moduleDoc[1] print '# Created by makepy.py version %s from %s' % (makepy_version,os.path.split(self.sourceFilename)[1]) print '# On date: %s' % time.ctime(time.time())
print 'from types import TupleType' if self.bUnicodeToString: print 'from pywintypes import UnicodeType'
def do_gen_file_header(self): la = self.typelib.GetLibAttr() moduleDoc = self.typelib.GetDocumentation(-1) docDesc = "" if moduleDoc[1]: docDesc = moduleDoc[1] print '# Created by makepy.py version %s from %s' % (makepy_version,os.path.split(self.sourceFilename)[1]) print '# On date: %s' % time.ctime(time.time())
print "_PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]" print print "class DispatchBaseClass:" print '\tdef __init__(self, oobj=None):' print '\t\tif oobj is None:' print '\t\t\toobj = pythoncom.new(self.CLSID)' print '\t\telif type(self) == type(oobj): print '\t\t\toobj = oobj._oleobj_.QueryInterface(se...
print "from win32com.client import DispatchBaseClass"
def checkWriteDispatchBaseClass(self): if not self.bHaveWrittenDispatchBaseClass: print "_PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch]" print print "class DispatchBaseClass:" print '\tdef __init__(self, oobj=None):' print '\t\tif oobj is None:' print '\t\t\toobj = pythoncom.new(self.CLSID)' print '\t\t...
print "import win32com.client"
def checkWriteEventBaseClass(self): # Nota base class as such... if not self.bHaveWrittenEventBaseClass: print "# Little helper to transform event arguments to more usable objects." print "import win32com.client" print "from pywintypes import UnicodeType" print "dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch...
print "\t\treturn win32com.client.Dispatch(arg)"
print "\t\treturn Dispatch(arg)"
print "def transformarg(arg):"
kw = {'output_dir': self.build_temp,
kw = {'output_dir': output_dir,
for undef in ext.undef_macros: macros.append((undef,))
WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h")
WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h"), WinExt_win32com('taskscheduler', libraries='mstask'),
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)
sys.stderr.write("PythonWin %s on %s\n" % (sys.version, sys.platform) ) sys.stderr.write("%s - see 'Help/About Pythonwin' for further copyright information.\n" % (win32ui.copyright,) )
suffix = "" if win32ui.debug: suffix = ", debug build" sys.stderr.write("PythonWin %s on %s%s.\n" % (sys.version, sys.platform, suffix) ) sys.stderr.write("%s - see 'Help/About PythonWin' for further copyright information.\n" % (win32ui.copyright,) )
def Init(self): self.oldStdOut = self.oldStdErr = None
winout.flags.WQ_NONE, 1, None, makeDoc, makeFrame, InteractiveView )
winout.flags.WQ_LINE, 1, None, makeDoc, makeFrame, InteractiveView )
def __init__(self, makeDoc = None, makeFrame = None): self.IsFinalDestroy = 0 winout.WindowOutput.__init__(self, sectionProfile, sectionProfile, \ winout.flags.WQ_NONE, 1, None, makeDoc, makeFrame, InteractiveView ) self.Create()
tlb = pythoncom.LoadRegTypeLib(tlb_guid, tlb_major, tlb_minor, lcid)
tlb = pythoncom.LoadRegTypeLib(tlb_guid, tlb_major, tlb_minor)
def _build_typeinfos_(self): # Can only ever be one for now. tlb_guid = getattr(self._obj_, '_typelib_guid_', None) if tlb_guid is None: return [] tlb_major, tlb_minor = getattr(self._obj_, '_typelib_version_', (1,0)) tlb = pythoncom.LoadRegTypeLib(tlb_guid, tlb_major, tlb_minor, lcid) typecomp = tlb.GetTypeComp() # No...
if not self.bIsDispatch:
if not self.bIsDispatch and not self.type_attr.typekind == pythoncom.TKIND_DISPATCH:
def WriteClass(self, generator): wTypeFlags = self.type_attr.wTypeFlags if not self.bIsDispatch: return # This is pretty screwey - now we have vtable support we # should probably rethink this (ie, maybe write both sides for sinks, etc) if self.bIsSink: self.WriteEventSinkClassHeader(generator) self.WriteCallbackClassBo...
regexGrepResult=re.compile("^\\([a-zA-Z]:[^(]*\\)(\\([0-9]+\\))")
regexGrep=re.compile(r"^([a-zA-Z]:[^(]*)\(([0-9]+)\)")
def __radd__(self, other): if type(other) == type(self) or type(other) == type([]): return other.dirs + self.dirs
if regexGrepResult.match(line) > 0:
regexGrepResult = regexGrep.match(line) if regexGrepResult:
def OnLDblClick(self,params): line = self.GetLine() if regexGrepResult.match(line) > 0: fname = regexGrepResult.group(1) line = string.atoi(regexGrepResult.group(2)) scriptutils.JumpToDocument(fname, line) return 0 # dont pass on return 1 # pass it on by default.
if regexGrepResult.match(line) > 0:
regexGrepResult = regexGrep.match(line) if regexGrepResult:
def OnRClick(self, params): menu = win32ui.CreatePopupMenu() flags=win32con.MF_STRING|win32con.MF_ENABLED lineno = self._obj_.LineFromChar(-1) #selection or current line line = self._obj_.GetLine(lineno) if regexGrepResult.match(line) > 0: self.fnm = regexGrepResult.group(1) self.lnnum = string.atoi(regexGrepResult.gro...
return prTable.get(pt)
return prTable.get(pt, hex(pt))
def GetPropTagName(pt): if not prTable: for name, value in mapitags.__dict__.items(): if name[:3] == 'PR_': prTable[value] = name return prTable.get(pt)
prop = mapitags.PROP_TAG( mapitags.PT_UNICODE, mapitags.PROP_ID(propIds[0]))
prop = mapitags.PROP_TAG( mapitags.PT_UNSPECIFIED, mapitags.PROP_ID(propIds[0]))
def GetProperties(obj, propList): """Given a MAPI object and a list of properties, return a list of property values. Allows a single property to be passed, and the result is a single object. Each request property can be an integer or a string. Of a string, it is automatically converted to an integer via the GetIdsFr...
prop = mapitags.PROP_TAG( mapitags.PT_UNICODE, mapitags.PROP_ID(propIds[0]))
if val == (1==1) or val == (1==0): type_tag = mapitags.PT_BOOLEAN else: type_tag = _MapiTypeMap.get(type(val)) if type_tag is None: raise ValueError, "Don't know what to do with '%r' ('%s')" % (val, type(val)) prop = mapitags.PROP_TAG( type_tag, mapitags.PROP_ID(propIds[0]))
def SetPropertyValue(obj, prop, val): if type(prop)!=IntType: props = ( (mapi.PS_PUBLIC_STRINGS, prop), ) propIds = obj.GetIDsFromNames(props, mapi.MAPI_CREATE) prop = mapitags.PROP_TAG( mapitags.PT_UNICODE, mapitags.PROP_ID(propIds[0])) if val is None: # Delete the property obj.DeleteProps((prop,)) else: obj.SetProps(...
obj.SetProps(((prop,val),),0)
obj.SetProps(((prop,val),))
def SetPropertyValue(obj, prop, val): if type(prop)!=IntType: props = ( (mapi.PS_PUBLIC_STRINGS, prop), ) propIds = obj.GetIDsFromNames(props, mapi.MAPI_CREATE) prop = mapitags.PROP_TAG( mapitags.PT_UNICODE, mapitags.PROP_ID(propIds[0])) if val is None: # Delete the property obj.DeleteProps((prop,)) else: obj.SetProps(...
print "Could not add module %s - %s: %s" % (name, sys.exc_info()[0],sys.exc_info()[1])
print "Could not add module %s - %s: %s" % (info, sys.exc_info()[0],sys.exc_info()[1])
def Rebuild(verbose = 1): """Rebuild the cache indexes from the file system. """ clsidToTypelib.clear() infos = GetGeneratedInfos() if verbose and len(infos): # Dont bother reporting this when directory is empty! print "Rebuilding cache of generated files for COM support..." for info in infos: iid, lcid, major, minor =...
print '\t\tif not self._olecp:'
print '\t\tif self._olecp is not None:'
print '\tdef close(self):'
print '\t\tcp.Unadvise(cookie)'
print '\t\t\tcp.Unadvise(cookie)'
print '\tdef close(self):'
extra = '_d.lib'
extra = '_d' if self.mingw32: prefix = 'lib' extra = extra + '.a'
def build_extension(self, ext): # some source files are compiled for different extensions # with special defines. So we cannot use a shared # directory for objects, we must use special ones. old_temp = self.build_temp try: self.build_temp = os.path.join(self.build_temp, ext.name)