我们从Python开源项目中,提取了以下26个代码示例,用于说明如何使用pythoncom.Missing()。
def WriteCallbackClassBody(self, generator): stream = generator.file print >> stream, "\t# Event Handlers" print >> stream, "\t# If you create handlers, they should have the following prototypes:" for name, entry in self.propMapGet.items() + self.propMapPut.items() + self.mapFuncs.items(): fdesc = entry.desc methName = MakeEventMethodName(entry.names[0]) print >> stream, '#\tdef ' + methName + '(self' + build.BuildCallList(fdesc, entry.names, "defaultNamedOptArg", "defaultNamedNotOptArg","defaultUnnamedArg", "pythoncom.Missing", is_comment = True) + '):' if entry.doc and entry.doc[1]: print >> stream, '#\t\t' + build._makeDocString(entry.doc[1]) print >> stream self.bWritten = 1
def OnFireWithNamedParams(self, no, a_bool, out1, out2): # This test exists mainly to help with an old bug, where named # params would come in reverse. Missing = pythoncom.Missing if no is not Missing: # We know our impl called 'OnFire' with the same ID assert no in self.fireds assert no+1==out1, "expecting 'out1' param to be ID+1" assert no+2==out2, "expecting 'out2' param to be ID+2" # The middle must be a boolean. assert a_bool is Missing or type(a_bool)==bool, "middle param not a bool" return out1+2, out2+2
def GetSS(): ss=win32com.client.Dispatch("SourceSafe") # SS seems a bit wierd. It defaults the arguments as empty strings, but # then complains when they are used - so we pass "Missing" ss.Open(pythoncom.Missing, pythoncom.Missing, pythoncom.Missing) return ss
def CheckoutFile(fileName): global g_sourceSafe import pythoncom ok = 0 # Assumes the fileName has a complete path, # and that the INI file can be found in that path # (or a parent path if a ni style package) try: import win32com.client, win32com.client.gencache mod = win32com.client.gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', 0, 5, 0) if mod is None: win32ui.MessageBox("VSS does not appear to be installed. The TypeInfo can not be created") return ok rc = FindVssProjectInfo(fileName) if rc is None: return project, vssFname, database = rc if g_sourceSafe is None: g_sourceSafe=win32com.client.Dispatch("SourceSafe") # SS seems a bit wierd. It defaults the arguments as empty strings, but # then complains when they are used - so we pass "Missing" if not database: database = pythoncom.Missing g_sourceSafe.Open(database, pythoncom.Missing, pythoncom.Missing) item = g_sourceSafe.VSSItem("$/%s/%s" % (project, vssFname)) item.Checkout(None, fileName) ok = 1 except pythoncom.com_error, exc: win32ui.MessageBox(exc.strerror, "Error checking out file") except: typ, val, tb = sys.exc_info() traceback.print_exc() win32ui.MessageBox("%s - %s" % (str(typ), str(val)),"Error checking out file") tb = None # Cleanup a cycle return ok
def CheckoutFile(fileName): global g_sourceSafe import pythoncom ok = 0 # Assumes the fileName has a complete path, # and that the INI file can be found in that path # (or a parent path if a ni style package) try: import win32com.client, win32com.client.gencache mod = win32com.client.gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', 0, 5, 0) if mod is None: win32ui.MessageBox("VSS does not appear to be installed. The TypeInfo can not be created") return ok rc = FindVssProjectInfo(fileName) if rc is None: return project, vssFname, database = rc if g_sourceSafe is None: g_sourceSafe=win32com.client.Dispatch("SourceSafe") # SS seems a bit wierd. It defaults the arguments as empty strings, but # then complains when they are used - so we pass "Missing" if not database: database = pythoncom.Missing g_sourceSafe.Open(database, pythoncom.Missing, pythoncom.Missing) item = g_sourceSafe.VSSItem("$/%s/%s" % (project, vssFname)) item.Checkout(None, fileName) ok = 1 except pythoncom.com_error as exc: win32ui.MessageBox(exc.strerror, "Error checking out file") except: typ, val, tb = sys.exc_info() traceback.print_exc() win32ui.MessageBox("%s - %s" % (str(typ), str(val)),"Error checking out file") tb = None # Cleanup a cycle return ok
def WriteCallbackClassBody(self, generator): stream = generator.file print("\t# Event Handlers", file=stream) print("\t# If you create handlers, they should have the following prototypes:", file=stream) for name, entry in list(self.propMapGet.items()) + list(self.propMapPut.items()) + list(self.mapFuncs.items()): fdesc = entry.desc methName = MakeEventMethodName(entry.names[0]) print('#\tdef ' + methName + '(self' + build.BuildCallList(fdesc, entry.names, "defaultNamedOptArg", "defaultNamedNotOptArg","defaultUnnamedArg", "pythoncom.Missing", is_comment = True) + '):', file=stream) if entry.doc and entry.doc[1]: print('#\t\t' + build._makeDocString(entry.doc[1]), file=stream) print(file=stream) self.bWritten = 1
def Read(self, Buffer=pythoncom.Missing, NumberOfBytes=defaultNamedNotOptArg): 'Read' return self._ApplyTypes_(2, 1, (3, 0), ((16396, 2), (3, 1)), 'Read', None,Buffer , NumberOfBytes)
def CommitAndSave(self, ErrorText=pythoncom.Missing): 'CommitAndSave' return self._ApplyTypes_(5, 1, (12, 0), ((16392, 2),), 'CommitAndSave', None,ErrorText ) # Result is of type ISpeechGrammarRule
def GetXMLErrorInfo(self, LineNumber=pythoncom.Missing, ScriptLine=pythoncom.Missing, Source=pythoncom.Missing, Description=pythoncom.Missing , ResultCode=pythoncom.Missing): 'GetXMLErrorInfo' return self._ApplyTypes_(11, 1, (11, 0), ((16387, 2), (16392, 2), (16392, 2), (16392, 2), (16387, 2)), 'GetXMLErrorInfo', None,LineNumber , ScriptLine, Source, Description, ResultCode)
def GetLocalCopy(self, bstrResourceUri=defaultNamedNotOptArg, pbstrLocalPath=pythoncom.Missing, pbstrMIMEType=pythoncom.Missing, pbstrRedirectUrl=pythoncom.Missing): return self._ApplyTypes_(2, 1, (24, 0), ((8, 1), (16392, 2), (16392, 2), (16392, 2)), 'GetLocalCopy', None,bstrResourceUri , pbstrLocalPath, pbstrMIMEType, pbstrRedirectUrl)
def LoadResource(self, bstrResourceUri=defaultNamedNotOptArg, fAlwaysReload=defaultNamedNotOptArg, pStream=pythoncom.Missing, pbstrMIMEType=pythoncom.Missing , pfModified=pythoncom.Missing, pbstrRedirectUrl=pythoncom.Missing): return self._ApplyTypes_(1, 1, (24, 0), ((8, 1), (11, 1), (16397, 2), (16392, 2), (16395, 2), (16392, 2)), 'LoadResource', None,bstrResourceUri , fAlwaysReload, pStream, pbstrMIMEType, pfModified, pbstrRedirectUrl )
def do_gen_file_header(self): la = self.typelib.GetLibAttr() moduleDoc = self.typelib.GetDocumentation(-1) docDesc = "" if moduleDoc[1]: docDesc = moduleDoc[1] # Reset all the 'per file' state self.bHaveWrittenDispatchBaseClass = 0 self.bHaveWrittenCoClassBaseClass = 0 self.bHaveWrittenEventBaseClass = 0 # You must provide a file correctly configured for writing unicode. # We assert this is it may indicate somewhere in pywin32 that needs # upgrading. assert self.file.encoding, self.file encoding = self.file.encoding # or "mbcs" print >> self.file, '# -*- coding: %s -*-' % (encoding,) print >> self.file, '# Created by makepy.py version %s' % (makepy_version,) print >> self.file, '# By python version %s' % \ (sys.version.replace("\n", "-"),) if self.sourceFilename: print >> self.file, "# From type library '%s'" % (os.path.split(self.sourceFilename)[1],) print >> self.file, '# On %s' % time.ctime(time.time()) print >> self.file, build._makeDocString(docDesc) print >> self.file, 'makepy_version =', repr(makepy_version) print >> self.file, 'python_version = 0x%x' % (sys.hexversion,) print >> self.file print >> self.file, 'import win32com.client.CLSIDToClass, pythoncom, pywintypes' print >> self.file, 'import win32com.client.util' print >> self.file, 'from pywintypes import IID' print >> self.file, 'from win32com.client import Dispatch' print >> self.file print >> self.file, '# The following 3 lines may need tweaking for the particular server' print >> self.file, '# Candidates are pythoncom.Missing, .Empty and .ArgNotFound' print >> self.file, 'defaultNamedOptArg=pythoncom.Empty' print >> self.file, 'defaultNamedNotOptArg=pythoncom.Empty' print >> self.file, 'defaultUnnamedArg=pythoncom.Empty' print >> self.file print >> self.file, 'CLSID = ' + repr(la[0]) print >> self.file, 'MajorVersion = ' + str(la[3]) print >> self.file, 'MinorVersion = ' + str(la[4]) print >> self.file, 'LibraryFlags = ' + str(la[5]) print >> self.file, 'LCID = ' + hex(la[1]) print >> self.file
def do_gen_file_header(self): la = self.typelib.GetLibAttr() moduleDoc = self.typelib.GetDocumentation(-1) docDesc = "" if moduleDoc[1]: docDesc = moduleDoc[1] # Reset all the 'per file' state self.bHaveWrittenDispatchBaseClass = 0 self.bHaveWrittenCoClassBaseClass = 0 self.bHaveWrittenEventBaseClass = 0 # You must provide a file correctly configured for writing unicode. # We assert this is it may indicate somewhere in pywin32 that needs # upgrading. assert self.file.encoding, self.file encoding = self.file.encoding # or "mbcs" print('# -*- coding: %s -*-' % (encoding,), file=self.file) print('# Created by makepy.py version %s' % (makepy_version,), file=self.file) print('# By python version %s' % \ (sys.version.replace("\n", "-"),), file=self.file) if self.sourceFilename: print("# From type library '%s'" % (os.path.split(self.sourceFilename)[1],), file=self.file) print('# On %s' % time.ctime(time.time()), file=self.file) print(build._makeDocString(docDesc), file=self.file) print('makepy_version =', repr(makepy_version), file=self.file) print('python_version = 0x%x' % (sys.hexversion,), file=self.file) print(file=self.file) print('import win32com.client.CLSIDToClass, pythoncom, pywintypes', file=self.file) print('import win32com.client.util', file=self.file) print('from pywintypes import IID', file=self.file) print('from win32com.client import Dispatch', file=self.file) print(file=self.file) print('# The following 3 lines may need tweaking for the particular server', file=self.file) print('# Candidates are pythoncom.Missing, .Empty and .ArgNotFound', file=self.file) print('defaultNamedOptArg=pythoncom.Empty', file=self.file) print('defaultNamedNotOptArg=pythoncom.Empty', file=self.file) print('defaultUnnamedArg=pythoncom.Empty', file=self.file) print(file=self.file) print('CLSID = ' + repr(la[0]), file=self.file) print('MajorVersion = ' + str(la[3]), file=self.file) print('MinorVersion = ' + str(la[4]), file=self.file) print('LibraryFlags = ' + str(la[5]), file=self.file) print('LCID = ' + hex(la[1]), file=self.file) print(file=self.file)