Skip to content

.addcolumn is not working as expected #14

@ManuelZ

Description

@ManuelZ

ANSITable.addcolumn() does this:

self.columns.append(Column(name, **kwargs))

But it doesn't do the additional step found in the ANSITable's __init__ method of assigning self to c.table:

c = Column(c)
c.table = self
self.columns.append(c)

Due to that, I'm getting an error like this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "...\Lib\site-packages\ansitable\table.py", line 828, in print  
    print(str(self), file=file)
          ^^^^^^^^^
  File "...\Lib\site-packages\ansitable\table.py", line 865, in __str__    text += self._row()  # add the headers
            ^^^^^^^^^^^
  File "...\Lib\site-packages\ansitable\table.py", line 782, in _row   
    text += c._formatcolumn(
            ^^^^^^^^^^^^^^^^
  File "...\Lib\site-packages\ansitable\table.py", line 248, in _formatcolumn
    gap1 = _spaces(gap + self.table.colsep)
                         ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'colsep'
from ansitable import ANSITable
table = ANSITable()
table.addcolumn("")
table.row("a")
table.print()

ansitable 0.11.4

Maybe I'm not using it as it was expected to be used?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions