posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          texttable - module for creating simple ASCII tables

          Posted on 2007-09-10 23:40 ZelluX 閱讀(509) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Scripting
          http://jefke.free.fr/soft/texttable/
          dl:  http://jefke.free.fr/soft/texttable/texttable.py
          NAME
              texttable - module for creating simple ASCII tables
          FILE
              /usr/lib/python2.3/site-packages/texttable.py
          DESCRIPTION
              Example:
                  table = Texttable()
                  table.header(["Name", "Age"])
                  table.set_cols_align(["l", "r"])
                  table.add_row(["Xavier\nHuon", 32])
                  table.add_row(["Baptiste\nClement", 1])
                  table.draw()
              Result:
                  +----------+-----+
                  |   Name   | Age |
                  +==========+=====+
                  | Xavier   |  32 |
                  | Huon     |     |
                  +----------+-----+
                  | Baptiste |   1 |
                  | Clement  |     |
                  +----------+-----+
          CLASSES
              exceptions.Exception
                  ArraySizeError
              Texttable
              class ArraySizeError(exceptions.Exception)
               |  Exception raised when specified rows don't fit the required size
               |
               |  Methods defined here:
               |
               |  __init__(self, msg)
               |
               |  __str__(self)
               |
               |  ----------------------------------------------------------------------
               |  Methods inherited from exceptions.Exception:
               |
               |  __getitem__(...)
              class Texttable
               |  Methods defined here:
               |
               |  __init__(self, max_width=80)
               |      Constructor
               |      - max_width is an integer, specifying the maximum width of the t
          able
               |      - if set to 0, size is unlimited, therefore cells won't be wrapp
          ed
               |
               |  add_row(self, array)
               |      Add a row in the rows stack
               |
               |      Cells can contain newlines.
               |
               |  draw(self)
               |      Draw the table
               |
               |  header(self, array)
               |      Specify the header of the table
               |
               |  reset(self)
               |      Reset the instance:
               |      - reset rows and header
               |
               |  set_chars(self, array)
               |      Set the characters used to draw lines between rows and
               |      columns.
               |
               |      The array should contain 4 fields:
               |
               |          [horizontal, vertical, corner, header]
               |
               |      Default is set to:
               |
               |          ['-', '|', '+', '=']
               |
               |  set_cols_align(self, array)
               |      Set the desired columns alignment
               |
               |      The elements of the array should be either "l", "c" or "r"
               |       - "l": column flushed left
               |       - "c": column centered
               |       - "r": column flushed right
               |
               |  set_cols_width(self, array)
               |      Set the desired columns width
               |
               |      The elements of the array should be integers, specifying the
               |      width of each column. For example:
               |
               |           [10, 20, 5]
               |
               |  set_deco(self, deco)
               |      Set the table decoration. 'deco' can be a combinaison of:
               |
               |      Texttable.BORDER: Border around the table
               |      Texttable.HEADER: Horizontal line below the header
               |      Texttable.HLINES: Horizontal lines between rows
               |      Texttable.VLINES: Vertical lines between columns
               |
               |      Example:
               |
               |          Texttable.BORDER | Texttable.HEADER
               |
               |      All of them are enabled by default.
               |
               |  --------------------------------------------------------------------
          --
               |  Data and other attributes defined here:
               |
               |  BORDER = 1
               |
               |  HEADER = 4
               |
               |  HLINES = 8
               |
               |  VLINES = 16
          DATA
              __all__ = ['Texttable', 'ArraySizeError']
              __author__ = 'Gerome Fournier <jefke(at)free.fr>'
              __credits__ = 'Jeff Kowalczyk:\n    - textwrap improved import\n    - ..
          .
              __license__ = 'GPL'
              __revision__ = '$Id: texttable.py,v 1.3 2003/10/05 13:53:39 jef Exp je..
          .
              __version__ = '0.3'
          VERSION
              0.3
          AUTHOR
              Gerome Fournier <jefke(at)free.fr>
          CREDITS
              Jeff Kowalczyk:
                  - textwrap improved import
                  - comment concerning header output
          主站蜘蛛池模板: 新蔡县| 长岭县| 淮南市| 静海县| 沁水县| 佛山市| 山东| 四子王旗| 崇左市| 泌阳县| 三亚市| 靖西县| 四川省| 雷州市| 谢通门县| 尉犁县| 霍林郭勒市| 瑞金市| 临泉县| 宁安市| 舟曲县| 景宁| 常宁市| 永康市| 榆林市| 阿鲁科尔沁旗| 澎湖县| 文登市| 高阳县| 苍南县| 天津市| 洛宁县| 岳普湖县| 红河县| 新闻| 扎赉特旗| 新乡市| 固始县| 许昌市| 宁强县| 保山市|