How to use the deepdish.io.ls.DictNode function in deepdish

To help you get started, we’ve selected a few deepdish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uchicago-cs / deepdish / deepdish / io / ls.py View on Github external
def _tree_level(level, raw=False, settings={}):
    if isinstance(level, tables.Group):
        if _sns and (level._v_title.startswith('SimpleNamespace:') or
                     DEEPDISH_IO_ROOT_IS_SNS in level._v_attrs):
            node = SimpleNamespaceNode()
        else:
            node = DictNode()

        for grp in level:
            node.add(grp._v_name, _tree_level(grp, raw=raw, settings=settings))

        for name in level._v_attrs._f_list():
            v = level._v_attrs[name]
            if name == DEEPDISH_IO_VERSION_STR:
                node.header['dd_io_version'] = v

            if name == DEEPDISH_IO_UNPACK:
                node.header['dd_io_unpack'] = v

            if name.startswith(DEEPDISH_IO_PREFIX):
                continue

            if isinstance(v, np.ndarray):
github uchicago-cs / deepdish / deepdish / io / ls.py View on Github external
omitted = N-2 * ABRIDGE_SHOW_EACH_SIDE
                    info = paint('{} omitted ({} in total)'.format(omitted, N),
                                 'darkgray', colorize=colorize)
                    print_row('...', info,
                              level=level,
                              parent=parent,
                              unpack=self.header.get('dd_io_unpack'),
                              colorize=colorize, file=file,
                              key_color='darkgray',
                              settings=settings)
                    continue
                v = self.children[k]
                final = level+1 == max_level

                if (not settings.get('leaves-only') or
                        not isinstance(v, DictNode)):
                    print_row(k,
                              v.info(colorize=colorize, final_level=final),
                              level=level,
                              parent=parent,
                              unpack=self.header.get('dd_io_unpack'),
                              colorize=colorize, file=file,
                              settings=settings)
                v.print(level=level+1, parent='{}{}/'.format(parent, k),
                        colorize=colorize, max_level=max_level, file=file,
                        settings=settings)
github uchicago-cs / deepdish / deepdish / io / ls.py View on Github external
def print(self, level=0, parent='/', colorize=True, max_level=None,
              file=sys.stdout):
        if level == 0 and not self.header.get('dd_io_unpack'):
            print_row('', self.info(colorize=colorize,
                                    final_level=(0 == max_level)),
                      level=level, parent=parent, unpack=False,
                      colorize=colorize, file=file)
        DictNode.print(self, level, parent, colorize, max_level, file)
github uchicago-cs / deepdish / deepdish / io / ls.py View on Github external
v.print(level=level+1, parent='{}{}/'.format(parent, k),
                        colorize=colorize, max_level=max_level, file=file,
                        settings=settings)

    def info(self, colorize=True, final_level=False):
        return container_info('dict', size=len(self.children),
                              colorize=colorize,
                              type_color='purple',
                              final_level=final_level)

    def __repr__(self):
        s = ['{}={}'.format(k, repr(v)) for k, v in self.children.items()]
        return 'DictNode({})'.format(', '.join(s))


class SimpleNamespaceNode(DictNode):
    def info(self, colorize=True, final_level=False):
        return container_info('SimpleNamespace', size=len(self.children),
                              colorize=colorize,
                              type_color='purple',
                              final_level=final_level)

    def print(self, level=0, parent='/', colorize=True, max_level=None,
              file=sys.stdout):
        if level == 0 and not self.header.get('dd_io_unpack'):
            print_row('', self.info(colorize=colorize,
                                    final_level=(0 == max_level)),
                      level=level, parent=parent, unpack=False,
                      colorize=colorize, file=file)
        DictNode.print(self, level, parent, colorize, max_level, file)

    def __repr__(self):