예제 #1
0
파일: device.py 프로젝트: be9/mix-machine
 def _chr(num):
   """Int -> Char"""
   res = charset.chr(num)
   if res is not None:
     return res
   else:
     raise InvaliCharCodeError(num)
예제 #2
0
 def _chr(num):
     """Int -> Char"""
     res = charset.chr(num)
     if res is not None:
         return res
     else:
         raise InvaliCharCodeError(num)
예제 #3
0
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
예제 #4
0
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