File: utils.py

package info (click to toggle)
pykdumpfile 0.5.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 300 kB
  • sloc: python: 2,607; ansic: 447; makefile: 17
file content (19 lines) | stat: -rw-r--r-- 354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'''addrxlat.utils
'''

import sys

if sys.version_info[0] == 3:
    from .defs_py3 import *
else:
    from .defs_py2 import *

def to_bytes(s):
    if isinstance(s, binary_type):
        return s
    return unicode_type(s).encode("utf-8")

def to_unicode(s):
    if isinstance(s, unicode_type):
        return s
    return binary_type(s).decode("utf-8")