Portable Python script across Python version

dict no longer have the `has_key` method in Python3. Instead, one can
use the `in` keyword which already works in Python2.

llvm-svn: 349447
This commit is contained in:
Serge Guelton 2018-12-18 08:22:47 +00:00
parent bbb461f758
commit 366c089bb3
2 changed files with 3 additions and 3 deletions
clang
docs/tools
tools/scan-view/share

View File

@ -180,9 +180,9 @@ def read_options(header):
'std::vector<std::string>',
'std::vector<IncludeCategory>',
'std::vector<RawStringFormat>']:
if enums.has_key(option.type):
if option.type in enums:
option.enum = enums[option.type]
elif nested_structs.has_key(option.type):
elif option.type in nested_structs:
option.nested_struct = nested_structs[option.type]
else:
raise Exception('Unknown type: %s' % option.type)

View File

@ -189,7 +189,7 @@ else:
return _controllers[controller_name].open
except KeyError:
if _controllers.has_key('xdg-open'):
if 'xdg-open' in _controllers:
return _controllers['xdg-open'].open
else:
return webbrowser.open