File: tools.py

package info (click to toggle)
python-btsocket 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 232 kB
  • sloc: python: 1,687; sh: 20; makefile: 6
file content (18 lines) | stat: -rw-r--r-- 586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Location for tools/functions to be used across various files"""
import logging


def create_module_logger(module_name):
    """helper function to create logger in modules"""
    logger = logging.getLogger(module_name)
    strm_hndlr = logging.StreamHandler()
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    strm_hndlr.setFormatter(formatter)
    logger.addHandler(strm_hndlr)
    return logger


def format_pkt(data):
    """Put data packets in a human readable format"""
    return ', '.join([f'{bite:#04x}' for bite in data])