• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kbandla / dpkt / 5333114825

pending completion
5333114825

Pull #654

github

Pull Request #654: Extend python versions testing runs against

10904 of 10929 relevant lines covered (99.77%)

7.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.86
/dpkt/compat.py
1
from __future__ import absolute_import
8✔
2

3
from struct import pack, unpack
8✔
4
import sys
8✔
5

6
if sys.version_info < (3,):
8✔
7
    compat_ord = ord
×
8
else:
9
    def compat_ord(char):
8✔
10
        return char
8✔
11

12
try:
8✔
13
    from itertools import izip
8✔
14
    compat_izip = izip
×
15
except ImportError:
8✔
16
    compat_izip = zip
8✔
17

18
try:
8✔
19
    from cStringIO import StringIO
8✔
20
except ImportError:
8✔
21
    from io import StringIO
8✔
22

23
try:
8✔
24
    from BytesIO import BytesIO
8✔
25
except ImportError:
8✔
26
    from io import BytesIO
8✔
27

28
if sys.version_info < (3,):
8✔
29
    def iteritems(d, **kw):
×
30
        return d.iteritems(**kw)
×
31

32
    def intround(num):
×
33
        return int(round(num))
×
34

35
else:
36
    def iteritems(d, **kw):
8✔
37
        return iter(d.items(**kw))
8✔
38

39
    # python3 will return an int if you round to 0 decimal places
40
    intround = round
8✔
41

42

43
def ntole(v):
8✔
44
    """convert a 2-byte word from the network byte order (big endian) to little endian;
45
    replaces socket.ntohs() to work on both little and big endian architectures
46
    """
47
    return unpack('<H', pack('!H', v))[0]
8✔
48

49

50
def ntole64(v):
8✔
51
    """
52
    Convert an 8-byte word from network byte order (big endian) to little endian.
53
    """
54
    return unpack('<Q', pack('!Q', v))[0]
8✔
55

56

57
def isstr(s):
8✔
58
    """True if 's' is an instance of basestring in py2, or of str in py3"""
59
    bs = getattr(__builtins__, 'basestring', str)
8✔
60
    return isinstance(s, bs)
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc