blob: 484eec9064657d842f0a39770291f5b3c0243587 [file] [log] [blame]
David Reiddcf62db2013-11-18 13:02:00 -08001# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10# implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14from __future__ import absolute_import, division, print_function
15
Mohammed Attiacd2a1a82014-03-05 21:54:06 +020016import sys
17
David Reiddcf62db2013-11-18 13:02:00 -080018
Paul Kehrer62e50032014-05-03 10:06:57 -050019DeprecatedIn04 = DeprecationWarning
Paul Kehrerdc378d12014-04-02 17:55:46 -050020
21
David Reiddcf62db2013-11-18 13:02:00 -080022def register_interface(iface):
23 def register_decorator(klass):
24 iface.register(klass)
25 return klass
26 return register_decorator
Mohammed Attiacd2a1a82014-03-05 21:54:06 +020027
28
29def bit_length(x):
30 if sys.version_info >= (2, 7):
31 return x.bit_length()
32 else:
33 return len(bin(x)) - (2 + (x <= 0))