Files
impala/shell/ext-py/bitarray-2.3.0/bitarray/__init__.py
wzhou-code 9e76a8f7c3 IMPALA-10784 (part 3): Prepare to publish impala-shell on PyPi
We are going to publish impala-shell release 4.1.0a1 on PyPi.
This patch upgrades following three python libraries which are used
for generating egg files when building impala-shell tarball.
  upgrade bitarray from 1.2.1 to 2.3.0
  upgrade prettytable from 0.7.1 to 0.7.2
  upgrade thrift_sasl from 0.4.2 to 0.4.3
Updates shell/packaging/requirements.txt for the versions of dependent
Python libraries.

Testing:
 - Ran core tests.
 - Built impala-shell package impala_shell-4.1.0a1.tar.gz, installed
   impala-shell package from local impala_shell-4.1.0a1.tar.gz, verified
   impala-shell was installed in ~/.local/lib/python2.7/site-packages.
   Verified the version of installed impala-shell and dependent Python
   libraries as expected.
 - Set IMPALA_SHELL_HOME as ~/.local/lib/python2.7/site-packages/
   impala_shell, copied over egg files under installed impala-shell
   python package so we can run the end-to-end unit tests against
   the impala-shell installed with the package downloaded from PyPi.
   Passed end-to-end impala-shell unit tests.
 - Verified the impala-shell tarball generated by
   shell/make_shell_tarball.sh.

Change-Id: I378404e2407396d4de3bb0eea4d49a9c5bb4e46a
Reviewed-on: http://gerrit.cloudera.org:8080/17826
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2021-09-28 04:55:57 +00:00

84 lines
2.9 KiB
Python

# Copyright (c) 2008 - 2021, Ilan Schnell; All Rights Reserved
"""
This package defines an object type which can efficiently represent
a bitarray. Bitarrays are sequence types and behave very much like lists.
Please find a description of this package at:
https://github.com/ilanschnell/bitarray
Author: Ilan Schnell
"""
from __future__ import absolute_import
from bitarray._bitarray import (bitarray, decodetree, _sysinfo,
get_default_endian, _set_default_endian,
__version__)
__all__ = ['bitarray', 'frozenbitarray', 'decodetree', '__version__']
class frozenbitarray(bitarray):
"""frozenbitarray(initializer=0, /, endian='big', buffer=None) -> \
frozenbitarray
Return a frozenbitarray object, which is initialized the same way a bitarray
object is initialized. A frozenbitarray is immutable and hashable.
Its contents cannot be altered after it is created; however, it can be used
as a dictionary key.
"""
def __init__(self, *args, **kwargs):
if 'buffer' in kwargs:
if not self.buffer_info()[5]: # not readonly
raise TypeError("cannot import writable buffer into "
"frozenbitarray")
self._freeze()
def __repr__(self):
return 'frozen' + bitarray.__repr__(self)
def __hash__(self):
"Return hash(self)."
if getattr(self, '_hash', None) is None:
# ensure hash is independent of endianness, also the copy will be
# mutable such that .tobytes() can zero out the pad bits
a = bitarray(self, 'big')
self._hash = hash((len(a), a.tobytes()))
return self._hash
# Technically the code below is not necessary, as all these methods will
# raise a TypeError on read-only memory. However, with a different error
# message.
def __delitem__(self, *args, **kwargs):
"" # no docstring
raise TypeError("frozenbitarray is immutable")
append = bytereverse = clear = extend = encode = fill = __delitem__
frombytes = fromfile = insert = invert = pack = pop = __delitem__
remove = reverse = setall = sort = __setitem__ = __delitem__
__iadd__ = __iand__ = __imul__ = __ior__ = __ixor__ = __delitem__
__ilshift__ = __irshift__ = __delitem__
def bits2bytes(__n):
"""bits2bytes(n, /) -> int
Return the number of bytes necessary to store n bits.
"""
import sys
if not isinstance(__n, (int, long) if sys.version_info[0] == 2 else int):
raise TypeError("integer expected")
if __n < 0:
raise ValueError("non-negative integer expected")
return (__n + 7) // 8
def test(verbosity=1, repeat=1):
"""test(verbosity=1, repeat=1) -> TextTestResult
Run self-test, and return unittest.runner.TextTestResult object.
"""
from bitarray import test_bitarray
return test_bitarray.run(verbosity=verbosity, repeat=repeat)