
| Current Path : /var/www/web-klick.de/dsh/50_dev2017/1330__canpy/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/50_dev2017/1330__canpy/readable.py |
# -*- coding: utf-8 -*-
import os
import re
import sys
import time
import random
#************************************************************************
class Translate (object):
def __init__ (self):
pass
#*************************************************************************
def hex_to_irev (self,s):
bin_str = bin(int(s,16))[2:][::-1] + "0000000"
bin_str = bin_str[0:len(bin_str)/8*8]
return(int(bin_str,2))
#*************************************************************************
def irev_to_hex (self,i):
bin_str = bin(i)[2:][::-1] + "0000000"
bin_str = bin_str[0:len(bin_str)/8*8:]
bin_str = hex(int(bin_str,2))[2:]
return(re.sub(r"[Ll]$","",bin_str))
#*************************************************************************
def make_cmat (self,communication_matrix):
cmat = {}
for msg in communication_matrix:
cmat[self.hex_to_irev(msg)] = communication_matrix[msg][1::2]
return(cmat)