Small enhancement: replaces multiple string.replace(...) by a single

string.translate()


git-svn-id: https://svn.ibp.de/svn/capisuite/trunk/capisuite@399 4ebea2bb-67d4-0310-8558-a5799e421b66
This commit is contained in:
htgoebel 2005-01-07 17:41:15 +00:00
parent 73a70dedc0
commit 62ad80e7cc
1 changed files with 4 additions and 5 deletions

View File

@ -16,6 +16,9 @@ open(headerfilename, 'w') # clear file contents
import SCons.Conftest, string
from types import IntType
transmap = string.maketrans(':./ ', '____')
def _Have(context, key, have):
"""
Slightly modified version of SCons.Conftest._Have which uses
@ -23,11 +26,7 @@ def _Have(context, key, have):
necessary until SCons support a way to actually use this feature.
In addition this writes '#define ... 1'.
"""
key_up = string.upper(key)
key_up = string.replace(key_up, ':', '_')
key_up = string.replace(key_up, '.', '_')
key_up = string.replace(key_up, '/', '_')
key_up = string.replace(key_up, ' ', '_')
key_up = string.translate(string.upper(key), transmap)
havedict[key_up] = have
if headerfilename:
f = open(headerfilename, "a")