2
# This file is part of Checkbox.
4
# Copyright 2008 Canonical Ltd.
6
# Checkbox is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License version 3,
8
# as published by the Free Software Foundation.
11
# Checkbox is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
19
from struct import calcsize
24
for value in reversed(key.split()):
25
value = int(value, 16)
30
def get_bitcount(bitmask):
39
def test_bit(bit, bitmask, bits=None):
41
bits = calcsize("l") * 8
43
long = int(bit / bits)
44
if long >= len(bitmask):
46
return (bitmask[long] >> offset) & 1