-
-
Notifications
You must be signed in to change notification settings - Fork 102
[Issue #390]added the client._generate._get_known_symbols #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
81b3d18
added the client._generate._get_known_symbols
muddi900 860332f
fixed the autopep formating from ide and made typing anotiations coma…
muddi900 df02c66
reverted gitignore as per request and added two space for comments
muddi900 bd27115
removed gitignore
muddi900 a4e1c50
removed custom location
muddi900 6dd9915
fixed weird spacing issue
muddi900 898b542
autopep format removal
muddi900 c85fcac
spacing issue fixed again
muddi900 5a81cab
added space for generics
muddi900 450bc19
.vscode removed
muddi900 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
import sys | ||
import shutil | ||
|
||
def get_next_cache_dir(): | ||
work_dir = os.getcwd() | ||
try: | ||
# change working directory to avoid import from local folder | ||
# during installation process | ||
os.chdir(os.path.dirname(sys.executable)) | ||
import comtypes.client | ||
return comtypes.client._code_cache._find_gen_dir() | ||
except ImportError: | ||
return None | ||
finally: | ||
os.chdir(work_dir) | ||
|
||
|
||
def _remove(directory): | ||
shutil.rmtree(directory) | ||
print('Removed directory "%s"' % directory) | ||
|
||
|
||
def remove_directory(directory, silent): | ||
if directory: | ||
if silent: | ||
_remove(directory) | ||
else: | ||
try: | ||
confirm = raw_input('Remove comtypes cache directories? (y/n): ') | ||
except NameError: | ||
confirm = input('Remove comtypes cache directories? (y/n): ') | ||
if confirm.lower() == 'y': | ||
_remove(directory) | ||
else: | ||
print('Directory "%s" NOT removed' % directory) | ||
return False | ||
return True | ||
|
||
|
||
if len(sys.argv) > 1 and "-y" in sys.argv[1:]: | ||
silent = True | ||
else: | ||
silent = False | ||
|
||
|
||
# First iteration may get folder with restricted rights. | ||
# Second iteration always gets temp cache folder (writable for all). | ||
directory = get_next_cache_dir() | ||
removed = remove_directory(directory, silent) | ||
|
||
if removed: | ||
directory = get_next_cache_dir() | ||
|
||
# do not request the second confirmation | ||
# if the first folder was already removed | ||
remove_directory(directory, silent=removed) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
from ctypes import * | ||
import sys | ||
|
||
if sys.version_info >= (2, 6): | ||
def binary(obj): | ||
return bytes(obj) | ||
else: | ||
def binary(obj): | ||
return buffer(obj) | ||
|
||
if sys.version_info >= (3, 0): | ||
text_type = str | ||
base_text_type = str | ||
else: | ||
text_type = unicode | ||
base_text_type = basestring | ||
|
||
BYTE = c_byte | ||
WORD = c_ushort | ||
DWORD = c_ulong | ||
|
||
_ole32 = oledll.ole32 | ||
|
||
_StringFromCLSID = _ole32.StringFromCLSID | ||
_CoTaskMemFree = windll.ole32.CoTaskMemFree | ||
_ProgIDFromCLSID = _ole32.ProgIDFromCLSID | ||
_CLSIDFromString = _ole32.CLSIDFromString | ||
_CLSIDFromProgID = _ole32.CLSIDFromProgID | ||
_CoCreateGuid = _ole32.CoCreateGuid | ||
|
||
# Note: Comparing GUID instances by comparing their buffers | ||
# is slightly faster than using ole32.IsEqualGUID. | ||
|
||
class GUID(Structure): | ||
_fields_ = [("Data1", DWORD), | ||
("Data2", WORD), | ||
("Data3", WORD), | ||
("Data4", BYTE * 8)] | ||
|
||
def __init__(self, name=None): | ||
if name is not None: | ||
_CLSIDFromString(text_type(name), byref(self)) | ||
|
||
def __repr__(self): | ||
return 'GUID("%s")' % text_type(self) | ||
|
||
def __unicode__(self): | ||
p = c_wchar_p() | ||
_StringFromCLSID(byref(self), byref(p)) | ||
result = p.value | ||
_CoTaskMemFree(p) | ||
return result | ||
__str__ = __unicode__ | ||
|
||
def __cmp__(self, other): | ||
if isinstance(other, GUID): | ||
return cmp(binary(self), binary(other)) | ||
return -1 | ||
|
||
def __bool__(self): | ||
return self != GUID_null | ||
|
||
def __eq__(self, other): | ||
return isinstance(other, GUID) and \ | ||
binary(self) == binary(other) | ||
|
||
def __hash__(self): | ||
# We make GUID instances hashable, although they are mutable. | ||
return hash(binary(self)) | ||
|
||
def copy(self): | ||
return GUID(text_type(self)) | ||
|
||
@classmethod | ||
def from_progid(cls, progid): | ||
"""Get guid from progid, ... | ||
""" | ||
if hasattr(progid, "_reg_clsid_"): | ||
progid = progid._reg_clsid_ | ||
if isinstance(progid, cls): | ||
return progid | ||
elif isinstance(progid, base_text_type): | ||
if progid.startswith("{"): | ||
return cls(progid) | ||
inst = cls() | ||
_CLSIDFromProgID(text_type(progid), byref(inst)) | ||
return inst | ||
else: | ||
raise TypeError("Cannot construct guid from %r" % progid) | ||
|
||
def as_progid(self): | ||
"Convert a GUID into a progid" | ||
progid = c_wchar_p() | ||
_ProgIDFromCLSID(byref(self), byref(progid)) | ||
result = progid.value | ||
_CoTaskMemFree(progid) | ||
return result | ||
|
||
@classmethod | ||
def create_new(cls): | ||
"Create a brand new guid" | ||
guid = cls() | ||
_CoCreateGuid(byref(guid)) | ||
return guid | ||
|
||
|
||
GUID_null = GUID() | ||
|
||
__all__ = ["GUID"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍