1 #Copyright (c) 2008 Vincent Povirk
3 #Permission is hereby granted, free of charge, to any person
4 #obtaining a copy of this software and associated documentation
5 #files (the "Software"), to deal in the Software without
6 #restriction, including without limitation the rights to use,
7 #copy, modify, merge, publish, distribute, sublicense, and/or sell
8 #copies of the Software, and to permit persons to whom the
9 #Software is furnished to do so, subject to the following
12 #The above copyright notice and this permission notice shall be
13 #included in all copies or substantial portions of the Software.
15 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 #OTHER DEALINGS IN THE SOFTWARE.
25 winlitecfg module - allows configuration before the bindings are first imported.
27 To use ANSI, call set_ansi() before importing other modules:
36 class CfgTooLateError(Exception):
39 # ANSI/Unicode setting
44 """set_unicode - Call before importing other modules to prefer W-suffixed objects
47 winlitecfg.set_unicode()
52 raise CfgTooLateError("Call winlitecfg.set_unicode() before importing other modules")
56 """set_ansi - Call before importing other modules to prefer A-suffixed objects
64 raise CfgTooLateError("Call winlitecfg.set_ansi() before importing other modules")
67 if ctypes
.windll
.kernel32
.GetTempPathW(0, 0) == 0 and ctypes
.GetLastError() == 120: # 120 == ERROR_CALL_NOT_IMPLEMENTED
72 def create_aw_aliases(module_dict
):
73 """create_aw_aliases(globals())
75 If nameA and nameW exists but name does not, set name to equal nameA or
76 nameW depending on whether ANSI or Unicode is being used.
83 for name
in module_dict
.keys():
84 if name
.endswith(aw
) and name
[:-1]+not_aw
in module_dict
and name
[:-1] not in module_dict
:
85 module_dict
[name
[:-1]] = module_dict
[name
]
88 def get_aw_symbols(globals, module
, names
):
92 globals[name
] = getattr(module
, name
+aw
)
94 #FIXME: define WINVER, _WIN32_IE, _WIN32_WINDOWS, and _WIN32_WINNT