Passed
Push — master ( 25a700...042c2b )
by Vinicius
01:48 queued 17s
created

build.utils.int_dpid()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
"""Utils module."""
2
3 1
from .settings import COOKIE_PREFIX
4
5
6 1
def int_dpid(dpid):
7
    """Convert a str dpid to an int."""
8 1
    dpid = int(dpid.replace(":", ""), 16)
9 1
    return dpid
10
11
12 1
def get_cookie(dpid):
13
    """Return the cookie integer given a dpid."""
14
    return (0x0000FFFFFFFFFFFF & int(int_dpid(dpid))) | (COOKIE_PREFIX << 56)
15