[pywin32-bugs] [ pywin32-Patches-3609017 ] Provide enums dynamically
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2013-05-03 13:20:15
|
Patches item #3609017, was opened at 2013-03-25 07:39 Message generated for change (Comment added) made by sschukat You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=3609017&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Stefan Schukat (sschukat) Assigned to: Nobody/Anonymous (nobody) Summary: Provide enums dynamically Initial Comment: In COM enums are transported as integers and hence hard to use for a programmer, which always has to map these numbers to comprehensive names. Since the enums are only available in typelibraries a wrapper had to be generated (makepy, gencache) to use them. There was no way that a enum could be used dynamically the same way a a COM object. The patch provides a way to use enums dynamically without generating a wrapper. So it is easy to use from a programmers viewpoint. The enum implementation used metaclasses so that the representation of the enum is always in a readable form and the enums are provided via members of enum classes. Used typelibraries are scanned inclusive their dependencies. >>> from win32com.client import Enums >>> from win32com.client import Dispatch >>> Word = Dispatch("Word.Application") >>> constants = Enums(Word) >>> constants.CertificateDetail.certdetIssuer <certdetIssuer 2> >>> print constants.CertificateDetail.certdetIssuer certdetIssuer >>> constants.CertificateDetail.certdetIssuer + 2 4 This enums class is used for over a year in our Python distribution and tested against Python 2.7.3 and Python 3.2.3 ---------------------------------------------------------------------- >Comment By: Stefan Schukat (sschukat) Date: 2013-05-03 06:20 Message: Added the patch with pep8 checked source and unit tests. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=3609017&group_id=78018 |