コード例 #1
0
    def _repr_pretty_(self, p: pretty.PrettyPrinter, cycle: bool) -> None:
        """Print list of stat entries in IPython.

    Args:
      p: Pretty printer to pass output to.
      cycle: True, if printer detected a cycle.

    Returns:
      Nothing.
    """
        if cycle:
            raise AssertionError('Cycle in a stat entry list')

        if not self:
            p.text('No results.')
            return

        with p.group(0, '', ''):
            p.group_stack[-1].want_break = True

            for path, _ in self._hierarchy['']:
                p.breakable()
                p.text(path)
                self._repr_contents(path, p)
            p.breakable()
コード例 #2
0
ファイル: base.py プロジェクト: AngellusMortis/Purlovia
        def _repr_pretty_(self, p: PrettyPrinter, cycle: bool):
            '''Cleanly wrappable display in Jupyter.'''
            if cycle:
                p.text(self.__class__.__name__ + '(<cyclic>)')
                return

            if self.skip_level_field:
                p.pretty(getattr(self, self.skip_level_field))
                return

            if self.main_field:
                p.pretty(getattr(self, self.main_field))
                return

            if self.string_format:
                p.pretty(self.string_format.format(**self.field_values))
                return

            fields = self.display_fields or self.field_order
            with p.group(4, self.__class__.__name__ + '(', ')'):
                if len(fields) > 1:
                    for idx, name in enumerate(fields):
                        if idx:
                            p.text(',')
                            p.breakable()
                        p.text(name + '=')
                        p.pretty(self.field_values[name])
                else:
                    p.pretty(self.field_values[fields[0]])
コード例 #3
0
    def _repr_pretty_(self, p: pretty.PrettyPrinter, cycle: bool) -> None:
        """Print interface in IPython.

    Args:
      p: Pretty printer to pass output to.
      cycle: True, if printer detected a cycle.

    Returns:
      Nothing.
    """
        del cycle  # Unused.

        iface_data = '{name} (MAC: {mac}):'.format(name=self.name,
                                                   mac=self.mac)

        with p.group(0, iface_data, ''):
            p.group_stack[-1].want_break = True

            with p.group(4, '', ''):
                p.group_stack[-1].want_break = True

                for addr in self.addresses:
                    p.breakable()
                    p.text(str(_NetworkAddressData(addr)))
            p.breakable()
コード例 #4
0
    def _repr_contents(self, root: Text, p: pretty.PrettyPrinter) -> None:
        with p.group(4, '', ''):
            p.group_stack[-1].want_break = True

            for path, stat_entry in self._hierarchy[root]:
                p.breakable()
                p.text(str(_StatEntryData(stat_entry)))
                self._repr_contents(path, p)
コード例 #5
0
        def _repr_pretty_(self, p: PrettyPrinter, cycle: bool):
            '''Cleanly wrappable display in Jupyter.'''
            if cycle:
                p.text(self.__class__.__name__ + '(<cyclic>)')
                return

            with p.group(4, self.__class__.__name__ + '(', ')'):
                for idx, value in enumerate(self.values):
                    if idx:
                        p.text(',')
                        p.breakable()
                    p.pretty(value)
コード例 #6
0
ファイル: coretypes.py プロジェクト: alex4401/Purlovia
        def _repr_pretty_(self, p: PrettyPrinter, cycle: bool):
            '''Cleanly wrappable display in Jupyter.'''
            if cycle:
                p.text(self.__class__.__name__ + '(<cyclic>)')
                return

            with p.group(4, self.__class__.__name__ + '(', ')'):
                p.text(f'count={self.count}, itemType={self.itemType.__name__}')
                for idx, value in enumerate(self.values):
                    p.text(',')
                    p.breakable()
                    p.text(f'0x{idx:04X} ({idx:<4}): ')
                    p.pretty(value)
コード例 #7
0
    def _repr_pretty_(self, p: pretty.PrettyPrinter, cycle: bool) -> None:
        """Print list of interfaces in IPython.

    Args:
      p: Pretty printer to pass output to.
      cycle: True, if printer detected a cycle.

    Returns:
      Nothing.
    """
        if cycle:
            raise AssertionError('Cycle in an interface list')

        if not self:
            p.text('No results.')
            return

        with p.group(0, '', ''):
            p.group_stack[-1].want_break = True

            for iface in self:
                p.breakable()
                p.text(pretty.pretty(_InterfaceData(iface)))
コード例 #8
0
 def _repr_pretty_(self, p: PrettyPrinter, cycle: bool) -> None:
     class_name = self.__class__.__name__
     if cycle:
         p.text(f"{class_name}(...)")
     else:
         with p.group(indent=2, open=f"{class_name}("):
             p.breakable()
             p.text("sliders=")
             p.pretty(self._sliders)
             p.text(",")
             p.breakable()
             p.text("arg_to_symbol=")
             p.pretty(self._arg_to_symbol)
             p.text(",")
         p.breakable()
         p.text(")")
コード例 #9
0
    def _repr_pretty_(self, p: pretty.PrettyPrinter, cycle: bool) -> None:
        """Print list of processes in IPython.

    Args:
      p: Pretty printer to pass output to.
      cycle: True, if printer detected a cycle.

    Returns:
      Nothing.
    """
        if cycle:
            raise AssertionError('Cycle in an process list')

        if not self:
            p.text('No results.')
            return

        header = (
            '{pid:>6s} {user:9s} {ni:>3s} {virt:>5s} {res:>5s} {s:1s} {cpu:4s} '
            '{mem:4s} {cmd}')
        header = header.format(pid='PID',
                               user='******',
                               ni='NI',
                               virt='VIRT',
                               res='RES',
                               s='S',
                               cpu='CPU%',
                               mem='MEM%',
                               cmd='Command')

        with p.group(0, '', ''):
            p.group_stack[-1].want_break = True
            p.breakable()
            p.text(header[:p.max_width])

            for process in self:
                p.breakable()
                p.text(str(_ProcessData(process))[:p.max_width])
            p.breakable()