1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-02 03:12:34 +01:00

Skeleton job execution

This commit is contained in:
Sergei Trofimov
2017-03-09 14:44:26 +00:00
parent 6eb5c3681d
commit 011fd684bd
14 changed files with 714 additions and 92 deletions

View File

@@ -29,6 +29,7 @@ import os
import re
import math
import shlex
import string
from bisect import insort
from collections import defaultdict, MutableMapping
from copy import copy
@@ -475,3 +476,69 @@ class obj_dict(MutableMapping):
return self.__dict__['dict'][name]
else:
raise AttributeError("No such attribute: " + name)
class level(object):
"""
A level has a name and behaves like a string when printed,
however it also has a numeric value which is used in comparisons.
"""
def __init__(self, name, value):
self.name = name
self.value = value
def __str__(self):
return self.name
def __repr__(self):
return '{}({})'.format(self.name, self.value)
def __cmp__(self, other):
if isinstance(other, level):
return cmp(self.value, other.value)
else:
return cmp(self.value, other)
def __eq__(self, other):
if isinstance(other, level):
return self.value == other.value
else:
return self.value == other
def __ne__(self, other):
if isinstance(other, level):
return self.value != other.value
else:
return self.value != other
def enum(args, start=0):
"""
Creates a class with attributes named by the first argument.
Each attribute is a ``level`` so they behave is integers in comparisons.
The value of the first attribute is specified by the second argument
(``0`` if not specified).
::
MyEnum = enum(['A', 'B', 'C'])
is equivalent of::
class MyEnum(object):
A = 0
B = 1
C = 2
"""
class Enum(object):
pass
for i, v in enumerate(args, start):
name = string.upper(identifier(v))
setattr(Enum, name, level(v, i))
return Enum