target.py 820 Bytes
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2
# (C) 2018 The University of Chicago
# See COPYRIGHT in top-level directory.
3 4
import _pybaketarget
import base64
Matthieu Dorier's avatar
Matthieu Dorier committed
5

6
class BakeTargetID():
Matthieu Dorier's avatar
Matthieu Dorier committed
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    def __init__(self, tid):
        self._tid = tid

    def __str__(self):
        return str(self._tid)

    @staticmethod
    def from_str(string):
        tid = _pybaketarget.target_id_from_string(string)
        if(tid is None):
            return None
        else:
            return BakeTargetID(tid)

class BakeRegionID():

    def __init__(self, rid):
        self._rid = rid
    
    def __str__(self):
        return base64.b64encode(str(self._rid))

    @staticmethod
    def from_str(string):
        rid = _pybaketarget.region_id_from_string(base64.b64decode(string))
        if(rid is None):
            return None
        else:
            return BakeRegionID(rid)