How to use the texttable.Texttable.HLINES function in texttable

To help you get started, we’ve selected a few texttable 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 markus-li / pyjuice / pyjuice.py View on Github external
for v in connections_expanded:
        connect_via = 'Not Set'
        identity = 'Not Set'
        groups = 'Not Set'
        if ('connect_via' in v and v['connect_via'] != None):
          connect_via = v[u'connect_via'][u'nickname']
        if ('identity' in v and v['identity'] != None):
          identity = v[u'identity'][u'nickname']
        if ('group_names' in v and len(v['group_names']) > 0 ):
          groups = ', '.join(v['group_names'])
        if v[u'type'] == 2: # is local device
          v[u'address'] = 'N/A'
          v[u'port'] = 0
        result.append([v['nickname'],typenames[v['type']], v['address'], v['port'], connect_via, identity, groups])
      table = Texttable()
      table.set_deco(Texttable.HEADER | Texttable.HLINES)
      table.set_cols_dtype(['t','t', 't', 'i', 't', 't', 't'])
      table.set_cols_align(['l', 'l', 'l', 'c', 'l', 'l', 'l'])
      table.set_cols_width([12, 7, 25, 5, 12, 12, 35])
      print '############################'
      print '#       Connections        #'
      print '############################'
      table.add_rows(result)
      print table.draw()
    if args.connect != None:
      c = get_connection(args.connect)
      if c == None:
        print 'No connection with the name \'%s\' could be found. Exiting...' % args.connect
        exit()
      if c['type'] != 0:
        print 'Can\'t connect to \'%s\'. No support for \'%s\' is implemented yet, only SSH is supported at this time.' % (args.connect, typenames[c['type']])
        exit()
github ITDevLtd / MCVirt / source / mcvirt-daemon / usr / lib / python2.7 / dist-packages / mcvirt / auth / factory.py View on Github external
def list(self):
        """List the Drbd volumes and statuses."""
        # Set permissions as having been checked, as listing VMs
        # does not require permissions
        self.po__get_registered_object('auth').set_permission_asserted()

        # Create table and add headers
        table = Texttable()
        table.set_deco(Texttable.HEADER | Texttable.VLINES | Texttable.HLINES)
        table.header(('Name', 'User Type', 'Groups'))

        # Set column alignment and widths
        table.set_cols_width((15, 10, 40))
        table.set_cols_align(('l', 'l', 'l'))

        for user in self.get_all_users():
            table.add_row((
                user.get_username(),
                user.get_user_type(),
                ', '.join([group.name for group in user.get_groups()])
            ))
        return table.draw()
github foutaise / texttable / texttable.py View on Github external
def __init__(self, max_width=80):
        """Constructor

        - max_width is an integer, specifying the maximum width of the table
        - if set to 0, size is unlimited, therefore cells won't be wrapped
        """

        self.set_max_width(max_width)
        self._precision = 3

        self._deco = Texttable.VLINES | Texttable.HLINES | Texttable.BORDER | \
            Texttable.HEADER
        self.set_chars(['-', '|', '+', '='])
        self.reset()
github khilnani / gists.cli / gists_cli / actions.py View on Github external
def help ():
  log.debug ("Help command.")

  print 'Gists.CLI'
  print ''
  print textwrap.fill('An easy to use CLI to manage your GitHub Gists. Create, edit, append, view, search and backup your Gists.', defaults.max_width)
  print ''
  print 'Author: Nik Khilnani - https://github.com/khilnani/gists.cli'
  print ''
  print "Note - GIST_ID can be a Gist ID or Index ID (of the Gist in the List view)."
  print "Index is 1 based and must be in the format '#N', '%N' , '.N' or ':N'."

  table = Texttable(max_width=defaults.max_width)
  table.set_deco(Texttable.HEADER | Texttable.HLINES)
  table.set_cols_align(["l", "l", "l"])
  table.set_cols_width([8, 45, 37])

  table.header( ["Action","Usage", "Description"] )
  
  table.add_row( _getHelpTableRow("Help", help='Display the help documentation') )

  table.add_row( _getHelpTableRow("Token", 'TOKEN', help='Save your Github  OAuth Token. Will be prefeered over ~/.git-credentials to avoid user/password prompts. Saves to ~/.gists') )

  table.add_row( _getHelpTableRow("List", help='Lists your public and private Gists.') )

  table.add_row( _getHelpTableRow("View", "GIST_ID|'.'INDEX [FILE]", help="Displays contents of a Gist on screen. To view a specific file, specify [FILE]. Instead of the Gist ID, the (1 based) index of the Gist in the List screen can be used. eg. %1, .1, :1 or '#1'") )

  table.add_row( _getHelpTableRow("Download", "GIST_ID|'.'INDEX PATH [FILE]", help="Get or Download the files in a Gist to (1) Current Directory, or (2) Directory with Gist ID as its name. To download a specific file, specify [FILE]. Instead of the Gist ID, the (1 based) index of the Gist in the List screen can be used. eg. %1, .1, :1 or '#1'") )

  table.add_row( _getHelpTableRow("New", '[PUBLIC_BOOL] [DESCRIPTION] [CONTENT|FILE]', help='Create a new Gist. Will prompt for Public/Private, Description etc. if not provided as arguments. Default is Private.') )
github ITDevLtd / MCVirt / source / mcvirt-daemon / usr / lib / python2.7 / dist-packages / mcvirt / auth / group / factory.py View on Github external
def list(self):
        """List the Drbd volumes and statuses."""
        # Set permissions as having been checked, as listing VMs
        # does not require permissions
        self.po__get_registered_object('auth').set_permission_asserted()

        # Create table and add headers
        table = Texttable()
        table.set_deco(Texttable.HEADER | Texttable.VLINES | Texttable.HLINES)
        table.header(('Name', 'Permissions', 'Global users'))

        # Set column alignment and widths
        table.set_cols_width((15, 40, 40))
        table.set_cols_align(('l', 'l', 'l'))

        for group in self.get_all():
            table.add_row((
                group.name,
                ', '.join([str(perm) for perm in group.get_permissions()]),
                ', '.join([user.get_username() for user in group.get_users(virtual_machine=None)])
            ))
        return table.draw()
github quentinhardy / odat / texttable.py View on Github external
def __init__(self, max_width=80):
        """Constructor

        - max_width is an integer, specifying the maximum width of the table
        - if set to 0, size is unlimited, therefore cells won't be wrapped
        """

        if max_width <= 0:
            max_width = False
        self._max_width = max_width
        self._precision = 3

        self._deco = Texttable.VLINES | Texttable.HLINES | Texttable.BORDER | \
            Texttable.HEADER
        self.set_chars(['-', '|', '+', '='])
        self.reset()
github bufordtaylor / python-texttable / texttable.py View on Github external
def __init__(self, max_width=80):
        """Constructor

        - max_width is an integer, specifying the maximum width of the table
        - if set to 0, size is unlimited, therefore cells won't be wrapped
        """

        if max_width <= 0:
            max_width = False
        self._max_width = max_width
        self._precision = 3

        self._deco = Texttable.VLINES | Texttable.HLINES | Texttable.BORDER | \
            Texttable.HEADER
        self.set_chars(['-', '|', '+', '='])
        self.reset()