Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
CLSIDToClass.py58 linesDownload Raw Back to client
1"""Manages a dictionary of CLSID strings to Python classes.2 3Primary use of this module is to allow modules generated by4makepy.py to share classes.  @makepy@ automatically generates code5which interacts with this module.  You should never need to reference6this module directly.7 8This module only provides support for modules which have been previously9been imported.  The gencache module provides some support for loading modules10on demand - once done, this module supports it...11 12As an example, the MSACCESS.TLB type library makes reference to the13CLSID of the Database object, as defined in DAO3032.DLL.  This14allows code using the MSAccess wrapper to natively use Databases.15 16This obviously applies to all cooperating objects, not just DAO and17Access.18"""19mapCLSIDToClass = {}20 21 22def RegisterCLSID(clsid, pythonClass):23    """Register a class that wraps a CLSID24 25    This function allows a CLSID to be globally associated with a class.26    Certain module will automatically convert an IDispatch object to an27    instance of the associated class.28    """29 30    mapCLSIDToClass[str(clsid)] = pythonClass31 32 33def RegisterCLSIDsFromDict(dict):34    """Register a dictionary of CLSID's and classes.35 36    This module performs the same function as @RegisterCLSID@, but for37    an entire dictionary of associations.38 39    Typically called by makepy generated modules at import time.40    """41    mapCLSIDToClass.update(dict)42 43 44def GetClass(clsid):45    """Given a CLSID, return the globally associated class.46 47    clsid -- a string CLSID representation to check.48    """49    return mapCLSIDToClass[clsid]50 51 52def HasClass(clsid):53    """Determines if the CLSID has an associated class.54 55    clsid -- the string CLSID to check56    """57    return clsid in mapCLSIDToClass58 
codekingpro/portable-devtools · Team Ai