diff options
Diffstat (limited to 'bitbake/lib/bb/utils.py')
| -rw-r--r-- | bitbake/lib/bb/utils.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 83304e4a01..eee97276a2 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
| @@ -371,46 +371,6 @@ def simple_exec(code, context): | |||
| 371 | def better_eval(source, locals): | 371 | def better_eval(source, locals): |
| 372 | return eval(source, _context, locals) | 372 | return eval(source, _context, locals) |
| 373 | 373 | ||
| 374 | def Enum(*names): | ||
| 375 | """ | ||
| 376 | A simple class to give Enum support | ||
| 377 | """ | ||
| 378 | |||
| 379 | assert names, "Empty enums are not supported" | ||
| 380 | |||
| 381 | class EnumClass(object): | ||
| 382 | __slots__ = names | ||
| 383 | def __iter__(self): return iter(constants) | ||
| 384 | def __len__(self): return len(constants) | ||
| 385 | def __getitem__(self, i): return constants[i] | ||
| 386 | def __repr__(self): return 'Enum' + str(names) | ||
| 387 | def __str__(self): return 'enum ' + str(constants) | ||
| 388 | |||
| 389 | class EnumValue(object): | ||
| 390 | __slots__ = ('__value') | ||
| 391 | def __init__(self, value): self.__value = value | ||
| 392 | Value = property(lambda self: self.__value) | ||
| 393 | EnumType = property(lambda self: EnumType) | ||
| 394 | def __hash__(self): return hash(self.__value) | ||
| 395 | def __cmp__(self, other): | ||
| 396 | # C fans might want to remove the following assertion | ||
| 397 | # to make all enums comparable by ordinal value {;)) | ||
| 398 | assert self.EnumType is other.EnumType, "Only values from the same enum are comparable" | ||
| 399 | return cmp(self.__value, other.__value) | ||
| 400 | def __invert__(self): return constants[maximum - self.__value] | ||
| 401 | def __nonzero__(self): return bool(self.__value) | ||
| 402 | def __repr__(self): return str(names[self.__value]) | ||
| 403 | |||
| 404 | maximum = len(names) - 1 | ||
| 405 | constants = [None] * len(names) | ||
| 406 | for i, each in enumerate(names): | ||
| 407 | val = EnumValue(i) | ||
| 408 | setattr(EnumClass, each, val) | ||
| 409 | constants[i] = val | ||
| 410 | constants = tuple(constants) | ||
| 411 | EnumType = EnumClass() | ||
| 412 | return EnumType | ||
| 413 | |||
| 414 | def lockfile(name): | 374 | def lockfile(name): |
| 415 | """ | 375 | """ |
| 416 | Use the file fn as a lock file, return when the lock has been acquired. | 376 | Use the file fn as a lock file, return when the lock has been acquired. |
