| OLD | NEW |
| 1 """engine.SCons.Variables.EnumVariable | 1 """engine.SCons.Variables.EnumVariable |
| 2 | 2 |
| 3 This file defines the option type for SCons allowing only specified | 3 This file defines the option type for SCons allowing only specified |
| 4 input-values. | 4 input-values. |
| 5 | 5 |
| 6 Usage example: | 6 Usage example: |
| 7 | 7 |
| 8 opts = Variables() | 8 opts = Variables() |
| 9 opts.Add(EnumVariable('debug', 'debug output and symbols', 'no', | 9 opts.Add(EnumVariable('debug', 'debug output and symbols', 'no', |
| 10 allowed_values=('yes', 'no', 'full'), | 10 allowed_values=('yes', 'no', 'full'), |
| 11 map={}, ignorecase=2)) | 11 map={}, ignorecase=2)) |
| 12 ... | 12 ... |
| 13 if env['debug'] == 'full': | 13 if env['debug'] == 'full': |
| 14 ... | 14 ... |
| 15 """ | 15 """ |
| 16 | 16 |
| 17 # | 17 # |
| 18 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundat
ion | 18 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons F
oundation |
| 19 # | 19 # |
| 20 # Permission is hereby granted, free of charge, to any person obtaining | 20 # Permission is hereby granted, free of charge, to any person obtaining |
| 21 # a copy of this software and associated documentation files (the | 21 # a copy of this software and associated documentation files (the |
| 22 # "Software"), to deal in the Software without restriction, including | 22 # "Software"), to deal in the Software without restriction, including |
| 23 # without limitation the rights to use, copy, modify, merge, publish, | 23 # without limitation the rights to use, copy, modify, merge, publish, |
| 24 # distribute, sublicense, and/or sell copies of the Software, and to | 24 # distribute, sublicense, and/or sell copies of the Software, and to |
| 25 # permit persons to whom the Software is furnished to do so, subject to | 25 # permit persons to whom the Software is furnished to do so, subject to |
| 26 # the following conditions: | 26 # the following conditions: |
| 27 # | 27 # |
| 28 # The above copyright notice and this permission notice shall be included | 28 # The above copyright notice and this permission notice shall be included |
| 29 # in all copies or substantial portions of the Software. | 29 # in all copies or substantial portions of the Software. |
| 30 # | 30 # |
| 31 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | 31 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY |
| 32 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | 32 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
| 33 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | 33 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 34 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | 34 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 35 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | 35 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 36 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 36 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 37 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 37 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 38 # | 38 # |
| 39 | 39 |
| 40 __revision__ = "src/engine/SCons/Variables/EnumVariable.py 3842 2008/12/20 22:59
:52 scons" | 40 __revision__ = "src/engine/SCons/Variables/EnumVariable.py 3897 2009/01/13 06:45
:54 scons" |
| 41 | 41 |
| 42 __all__ = ['EnumVariable',] | 42 __all__ = ['EnumVariable',] |
| 43 | 43 |
| 44 import string | 44 import string |
| 45 | 45 |
| 46 import SCons.Errors | 46 import SCons.Errors |
| 47 | 47 |
| 48 def _validator(key, val, env, vals): | 48 def _validator(key, val, env, vals): |
| 49 if not val in vals: | 49 if not val in vals: |
| 50 raise SCons.Errors.UserError( | 50 raise SCons.Errors.UserError( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if ignorecase == 2: | 92 if ignorecase == 2: |
| 93 converter = lambda val, map=map: \ | 93 converter = lambda val, map=map: \ |
| 94 string.lower(map.get(string.lower(val), val)) | 94 string.lower(map.get(string.lower(val), val)) |
| 95 elif ignorecase == 1: | 95 elif ignorecase == 1: |
| 96 converter = lambda val, map=map: \ | 96 converter = lambda val, map=map: \ |
| 97 map.get(string.lower(val), val) | 97 map.get(string.lower(val), val) |
| 98 else: | 98 else: |
| 99 converter = lambda val, map=map: \ | 99 converter = lambda val, map=map: \ |
| 100 map.get(val, val) | 100 map.get(val, val) |
| 101 return (key, help, default, validator, converter) | 101 return (key, help, default, validator, converter) |
| OLD | NEW |