def _chr(num): """Int -> Char""" res = charset.chr(num) if res is not None: return res else: raise InvaliCharCodeError(num)
def word2str(word, type = WORD, content_type = BASIC): if content_type == REGJ or type == STR: line = "" # rJ hasn't sign, text hasn't sign else: line = "+" if word[0] == 1 else "-" if type == WORD: for byte in range(1 if content_type == BASIC else 4, 6): line += " %02i" % word[byte] if content_type == REGJ: line = line[1:] # remove first space elif type == INT: line += str(int(word[1 if content_type == BASIC else 4:5])) elif type == STR: for byte in range(1 if content_type == BASIC else 4, 6): line += charset.chr(word[byte], "?") return line
def word2str(word, type=WORD, content_type=BASIC): if content_type == REGJ or type == STR: line = "" # rJ hasn't sign, text hasn't sign else: line = "+" if word[0] == 1 else "-" if type == WORD: for byte in xrange(1 if content_type == BASIC else 4, 6): line += " %02i" % word[byte] if content_type == REGJ: line = line[1:] # remove first space elif type == INT: line += str(int(word[1 if content_type == BASIC else 4:5])) elif type == STR: for byte in xrange(1 if content_type == BASIC else 4, 6): line += charset.chr(word[byte], "?") return line