| 16 | return True |
| 17 | |
| 18 | class CodingType(): |
| 19 | def __init__(self, descriptor : str): |
| 20 | self.length = 0 |
| 21 | self.codingType = None |
| 22 | self.parseCodingType(descriptor) |
| 23 | def parseCodingType(self, descriptor : str): |
| 24 | if (descriptor.startswith("f(")): |
| 25 | self.codingType = Coding.FIXED_CODE |
| 26 | self.length = int(descriptor[2:-1]) |
| 27 | elif (descriptor.startswith("u(v)")): |
| 28 | self.codingType = Coding.UNSIGNED_VARIABLE |
| 29 | elif (descriptor.startswith("u(")): |
| 30 | self.codingType = Coding.UNSIGNED_FIXED |
| 31 | self.length = int(descriptor[2:-1]) |
| 32 | elif (descriptor.startswith("ue(v)")): |
| 33 | self.codingType = Coding.UNSIGNED_EXP |
| 34 | elif (descriptor.startswith("se(v)")): |
| 35 | self.codingType = Coding.SIGNED_EXP |
| 36 | else: |
| 37 | raise SyntaxError("Unknown descriptor type " + descriptor) |
| 38 | def __str__(self): |
| 39 | if (self.codingType == Coding.FIXED_CODE): |
| 40 | return f"f({self.length})" |
| 41 | if (self.codingType == Coding.UNSIGNED_VARIABLE): |
| 42 | return "u(v)" |
| 43 | if (self.codingType == Coding.UNSIGNED_FIXED): |
| 44 | return f"u({self.length})" |
| 45 | if (self.codingType == Coding.UNSIGNED_EXP): |
| 46 | return "ue(v)" |
| 47 | if (self.codingType == Coding.SIGNED_EXP): |
| 48 | return "se(v)" |
| 49 | return "Err" |
no outgoing calls
no test coverage detected