Robpol86 / terminaltables

Project no longer maintained.
https://github.com/matthewdeanmartin/terminaltables
MIT License
689 stars 70 forks source link

[WIP] - Added ability to cancel vertical or horizontal alignment #40

Closed liiight closed 7 years ago

liiight commented 7 years ago

With regard to https://github.com/Flexget/Flexget/issues/1584, our usage of PorcelainTable requires the ability to disable all table alignments.

To Do:

Robpol86 commented 7 years ago

Can you provide a repr() of the output before and after your change? I'm not sure I 100% understand. Does your change change this:

>>> for line in PorcelainTable(table_data).table.splitlines(): repr(line)
... 
"' Heading1     | Heading2     '"
"' row1 column1 | row1 column2 '"
"' row2 column1 | row2 column2 '"
"' row3 column1 | row3 column2 '"

to this:

>>> for line in PorcelainTable(table_data).table.splitlines(): repr(line)
... 
"'Heading1     | Heading2'"
"'row1 column1 | row1 column2'"
"'row2 column1 | row2 column2'"
"'row3 column1 | row3 column2'"
codecov-io commented 7 years ago

Current coverage is 99.15% (diff: 83.33%)

Merging #40 into master will decrease coverage by 0.84%

@@           master        #40   diff @@
========================================
  Files           8          8          
  Lines         466        472     +6   
  Methods         0          0          
  Messages        0          0          
  Branches       77         79     +2   
========================================
+ Hits          466        468     +2   
- Misses          0          1     +1   
- Partials        0          3     +3   

Powered by Codecov. Last update ae22aaa...d25eaf9

liiight commented 7 years ago

Base:

 Platform | Years     | Notes                    
 Mk5      | 2007-2009 | The Golf Mk5 Variant was 
          |           | introduced in 2007.      
 MKVI     | 2009-2013 | Might actually be Mk5. 
table.horizontal_align = False
Platform|Years|Notes
Mk5|2007-2009|The Golf Mk5 Variant was
||introduced in 2007.
MKVI|2009-2013|Might actually be Mk5.
table.vertical_align = False
Platform|Years|Notes
Mk5|2007-2009|The Golf Mk5 Variant was\nintroduced in 2007.
MKVI|2009-2013|Might actually be Mk5.
Robpol86 commented 7 years ago

I'm not sure if this would really be in scope of terminaltables. It's not really a table anymore, more like pipe delimited lines. What benefit would terminaltables provide over just ['|'.join(row) for row in table_data]?

liiight commented 7 years ago

I understand this maybe too much of a private case and would understand if you reject this. For me, it's way more elegant to let terminaltable handle it by setting two flags than to have another code path.

Robpol86 commented 7 years ago

Yea I think this would be too specific for terminaltables :( thanks for the pull request anyway, always glad to review this kind of stuff!

liiight commented 7 years ago

No problem. While we're at it, how you feel about a csv table?

Robpol86 commented 7 years ago

To have it output something like:

Platform,Years,Notes
Mk5,2007-2009,The Golf Mk5 Variant was\nintroduced in 2007.
MKVI,2009-2013,Might actually be Mk5.

?

If so I think it too is out of scope. termintaltables is more for horizontal text alignment. If it's not padding cells it's basically just joining cells with a lot of function call overhead.

liiight commented 7 years ago

Yeah, guess you're right. Thanks for considering anyway.