File: compat.py

package info (click to toggle)
django-bitfield 1.9.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 180 kB
  • sloc: python: 931; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import absolute_import

__all__ = ('bitand', 'bitor')


def bitand(a, b):
    return a.bitand(b)


def bitor(a, b):
    return a.bitor(b)


try:
    from django.db.models.expressions import ExpressionNode
    ExpressionNode.BITAND  # noqa
    del ExpressionNode
except ImportError:
    # Django >= 1.8
    pass
except AttributeError:
    # Django < 1.5
    def bitand(a, b):  # NOQA
        return a & b

    def bitor(a, b):  # NOQA
        return a | b