Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
5117d272
Commit
5117d272
authored
Jan 14, 2018
by
dark-lbp
Committed by
Marcin Bury
Jan 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make print_table auto warp column value (#353)
parent
d7c4ab60
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
__init__.py
routersploit/utils/__init__.py
+13
-2
No files found.
routersploit/utils/__init__.py
View file @
5117d272
...
...
@@ -311,6 +311,7 @@ def print_table(headers, *args, **kwargs):
"""
extra_fill
=
kwargs
.
get
(
"extra_fill"
,
5
)
header_separator
=
kwargs
.
get
(
"header_separator"
,
'-'
)
max_column_length
=
kwargs
.
get
(
"max_column_length"
,
60
)
if
not
all
(
map
(
lambda
x
:
len
(
x
)
==
len
(
headers
),
args
)):
print_error
(
"Headers and table rows tuples should be the same length."
)
...
...
@@ -329,6 +330,9 @@ def print_table(headers, *args, **kwargs):
column
=
[
custom_len
(
arg
[
idx
])
for
arg
in
args
]
column
.
append
(
len
(
header
))
if
max
(
column
)
>
max_column_length
:
current_line_fill
=
max_column_length
+
extra_fill
else
:
current_line_fill
=
max
(
column
)
+
extra_fill
fill
.
append
(
current_line_fill
)
headers_line
=
""
.
join
((
headers_line
,
"{header:<{fill}}"
.
format
(
header
=
header
,
fill
=
current_line_fill
)))
...
...
@@ -340,15 +344,22 @@ def print_table(headers, *args, **kwargs):
print_info
()
print_info
(
headers_line
)
print_info
(
headers_separator_line
)
for
arg
in
args
:
content_line
=
' '
content_line
_data
=
{}
for
idx
,
element
in
enumerate
(
arg
):
content_line_data
[
idx
]
=
str
(
element
)
while
not
all
(
map
(
lambda
x
:
len
(
content_line_data
[
x
])
==
0
,
content_line_data
.
keys
())):
content_line
=
' '
for
idx
in
content_line_data
.
keys
():
element
=
content_line_data
[
idx
][:
max_column_length
]
content_line
=
""
.
join
((
content_line
,
'{:<{}}'
.
format
(
element
,
fill
[
idx
])
))
content_line_data
[
idx
]
=
content_line_data
[
idx
][
max_column_length
:]
print_info
(
content_line
)
print_info
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment