Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def info(self, colorize=True, final_level=False):
if isinstance(self.value, six.text_type):
if len(self.value) > 25:
s = repr(self.value[:22] + '...')
else:
s = repr(self.value)
return type_string(s, dtype='unicode',
type_color='green',
extra='({})'.format(len(self.value)),
colorize=colorize)
elif isinstance(self.value, six.binary_type):
if len(self.value) > 25:
s = repr(self.value[:22] + b'...')
else:
s = repr(self.value)
return type_string(s, dtype='ascii',
try:
from types import SimpleNamespace
_sns = True
except ImportError:
_sns = False
from deepdish import six
IO_VERSION = 12
DEEPDISH_IO_PREFIX = 'DEEPDISH_IO'
DEEPDISH_IO_VERSION_STR = DEEPDISH_IO_PREFIX + '_VERSION'
DEEPDISH_IO_UNPACK = DEEPDISH_IO_PREFIX + '_DEEPDISH_IO_UNPACK'
DEEPDISH_IO_ROOT_IS_SNS = DEEPDISH_IO_PREFIX + '_ROOT_IS_SNS'
# Types that should be saved as pytables attribute
ATTR_TYPES = (int, float, bool, six.string_types, six.binary_type,
np.int8, np.int16, np.int32, np.int64, np.uint8,
np.uint16, np.uint32, np.uint64, np.float16, np.float32,
np.float64, np.bool_, np.complex64, np.complex128)
if _pandas:
class _HDFStoreWithHandle(pd.io.pytables.HDFStore):
def __init__(self, handle):
self._path = None
self._complevel = None
self._complib = None
self._fletcher32 = False
self._filters = None
self._handle = handle
elif isinstance(level, dict) and _dict_native_ok(level):
# First create a new group
new_group = handler.create_group(group, name,
"dict:{}".format(len(level)))
for k, v in level.items():
if isinstance(k, six.string_types):
_save_level(handler, new_group, v, name=k, filters=filters,
idtable=idtable)
elif (_sns and isinstance(level, SimpleNamespace) and
_dict_native_ok(level.__dict__)):
# Create a new group in same manner as for dict
new_group = handler.create_group(
group, name, "SimpleNamespace:{}".format(len(level.__dict__)))
for k, v in level.__dict__.items():
if isinstance(k, six.string_types):
_save_level(handler, new_group, v, name=k, filters=filters,
idtable=idtable)
elif isinstance(level, list) and len(level) < 256:
# Lists can contain other dictionaries and numpy arrays, so we don't
# want to serialize them. Instead, we will store each entry as i0, i1,
# etc.
new_group = handler.create_group(group, name,
"list:{}".format(len(level)))
for i, entry in enumerate(level):
level_name = 'i{}'.format(i)
_save_level(handler, new_group, entry,
name=level_name, filters=filters, idtable=idtable)
elif isinstance(level, tuple) and len(level) < 256:
def info(self, colorize=True, final_level=False):
if isinstance(self.value, six.text_type):
if len(self.value) > 25:
s = repr(self.value[:22] + '...')
else:
s = repr(self.value)
return type_string(s, dtype='unicode',
type_color='green',
extra='({})'.format(len(self.value)),
colorize=colorize)
elif isinstance(self.value, six.binary_type):
if len(self.value) > 25:
s = repr(self.value[:22] + b'...')
else:
s = repr(self.value)
return type_string(s, dtype='ascii',
type_color='green',
extra='({})'.format(len(self.value)),
colorize=colorize)
elif self.value is None:
return type_string('None', dtype='python',
type_color='blue',
colorize=colorize)
else:
return type_string(repr(self.value)[:20],
dtype=str(np.dtype(type(self.value))),