2495 |
2495 |
2496 |
2496 |
2497 RESOURCE_HIGH: int = 3 |
2497 RESOURCE_HIGH: int = 3 |
2498 RESOURCE_MEDIUM: int = 2 |
2498 RESOURCE_MEDIUM: int = 2 |
2499 RESOURCE_LOW: int = 1 |
2499 RESOURCE_LOW: int = 1 |
2500 RESOURCE_DEFAULT: int = 0 |
|
2501 |
2500 |
2502 RESOURCE_MAPPING: Dict[bytes, int] = { |
2501 RESOURCE_MAPPING: Dict[bytes, int] = { |
2503 b'default': RESOURCE_DEFAULT, |
|
2504 b'low': RESOURCE_LOW, |
2502 b'low': RESOURCE_LOW, |
2505 b'medium': RESOURCE_MEDIUM, |
2503 b'medium': RESOURCE_MEDIUM, |
2506 b'high': RESOURCE_HIGH, |
2504 b'high': RESOURCE_HIGH, |
2507 } |
2505 } |
2508 |
2506 |
2513 ui: "uimod.ui", dimension: Optional[bytes] = None |
2511 ui: "uimod.ui", dimension: Optional[bytes] = None |
2514 ) -> int: |
2512 ) -> int: |
2515 """return the resource profile for a dimension |
2513 """return the resource profile for a dimension |
2516 |
2514 |
2517 If no dimension is specified, the generic value is returned""" |
2515 If no dimension is specified, the generic value is returned""" |
2518 generic_name = ui.config(b'usage', b'resources') |
2516 |
2519 value = RESOURCE_MAPPING.get(generic_name, RESOURCE_DEFAULT) |
2517 def config(section, name): |
2520 if value == RESOURCE_DEFAULT: |
2518 value_name = ui.config(section, name, default=b'default') |
2521 value = DEFAULT_RESOURCE |
2519 return RESOURCE_MAPPING.get(value_name) |
|
2520 |
2522 if dimension is not None: |
2521 if dimension is not None: |
2523 sub_name = ui.config(b'usage', b'resources.%s' % dimension) |
2522 value = config(b'usage', b'resources.%s' % dimension) |
2524 sub_value = RESOURCE_MAPPING.get(sub_name, RESOURCE_DEFAULT) |
2523 if value is not None: |
2525 if sub_value != RESOURCE_DEFAULT: |
2524 return value |
2526 value = sub_value |
2525 value = config(b'usage', b'resources') |
2527 return value |
2526 if value is not None: |
|
2527 return value |
|
2528 return DEFAULT_RESOURCE |