Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python-cliff
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenStack
python
python-cliff
Commits
76b5df66
Commit
76b5df66
authored
1 year ago
by
Zuul
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Autofit table output if stdout is a tty"
parents
a3920dd0
e02f89cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cliff/formatters/table.py
+10
-1
10 additions, 1 deletion
cliff/formatters/table.py
with
10 additions
and
1 deletion
cliff/formatters/table.py
+
10
−
1
View file @
76b5df66
...
...
@@ -13,6 +13,7 @@
"""
Output formatters using prettytable.
"""
import
os
import
sys
import
prettytable
...
...
@@ -32,6 +33,14 @@ def _format_row(row):
return
new_row
def
_do_fit
(
fit_width
):
if
os
.
name
==
'
nt
'
:
# NOTE(pas-ha) the isatty is not reliable enough on Windows,
# so do not try to auto-fit
return
fit_width
return
sys
.
stdout
.
isatty
()
or
fit_width
class
TableFormatter
(
base
.
ListFormatter
,
base
.
SingleFormatter
):
ALIGNMENTS
=
{
...
...
@@ -177,7 +186,7 @@ class TableFormatter(base.ListFormatter, base.SingleFormatter):
"""
if
max_width
>
0
:
term_width
=
max_width
elif
not
fit_width
:
elif
not
_do_fit
(
fit_width
)
:
# Fitting is disabled
return
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment