Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-cli
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
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
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
Mirror
cc-cli
Commits
4217d216
Commit
4217d216
authored
13 years ago
by
Gaëtan Déléaz
Committed by
Seblu
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Modify the display list_table
parent
ae12b0ea
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
cccli/command/list.py
+41
-15
41 additions, 15 deletions
cccli/command/list.py
with
41 additions
and
15 deletions
cccli/command/list.py
+
41
−
15
View file @
4217d216
...
...
@@ -77,32 +77,58 @@ class Command_list(TqlCommand):
def
list_table
(
self
,
objs
):
'''
Listing table style
'''
term_height
,
term_width
=
self
.
printer
.
get_term_size
()
# get max size by tag
tags
=
dict
()
for
o
in
objs
[
"
objects
"
]:
for
(
t
,
v
)
in
o
.
items
():
tags
[
t
]
=
max
(
len
(
self
.
tdr
(
t
,
v
)),
tags
.
get
(
t
,
len
(
t
)))
size_id
=
tags
[
"
id
"
]
+
len
(
"
"
)
# compute index width
indexw
=
max
(
int
(
math
.
log10
(
len
(
objs
[
"
objects
"
]))
+
1
),
len
(
"
index
"
))
if
size_id
+
indexw
>=
term_width
:
raise
cmdError
(
"
term width is too small
"
)
# build initial print order
order
=
[
t
for
t
in
objs
.
get
(
"
order
"
,
[])
if
t
in
tags
]
order
.
extend
(
sorted
(
set
(
tags
.
keys
())
-
set
(
order
)))
if
self
.
options
.
index
:
# compute index width
indexw
=
max
(
int
(
math
.
log10
(
len
(
objs
[
"
objects
"
]))
+
1
),
len
(
"
index
"
))
# print index title
self
.
printer
.
out
(
"
index
"
,
nl
=
""
)
# print tag title in order
for
t
in
order
:
self
.
printer
.
out
(
self
.
tdtc
(
t
),
nl
=
""
)
self
.
printer
.
out
(
t
.
ljust
(
tags
[
t
]),
nl
=
"
"
)
self
.
printer
.
out
(
color
[
"
reset
"
])
# print tags in order
for
(
i
,
o
)
in
enumerate
(
objs
[
"
objects
"
]):
# remove id of order
order
=
order
[
1
:]
# print tag table by title group
while
order
:
tag_index
=
0
line_pos
=
0
if
self
.
options
.
index
:
# print index title
self
.
printer
.
out
(
"
index
"
,
nl
=
""
)
line_pos
=
indexw
# print id title
self
.
printer
.
out
(
self
.
tdtc
(
"
id
"
)
+
"
id
"
.
ljust
(
tags
[
"
id
"
]),
nl
=
"
"
)
line_pos
+=
size_id
# print tags title section in order
for
t
in
order
:
# if the tag don't fit in space left, stop the title loop
if
line_pos
+
tags
[
t
]
+
len
(
"
"
)
>
term_width
and
tag_index
!=
0
:
break
self
.
printer
.
out
(
self
.
tdtc
(
t
)
+
t
.
ljust
(
tags
[
t
]),
nl
=
"
"
)
line_pos
+=
tags
[
t
]
+
len
(
"
"
)
tag_index
+=
1
self
.
printer
.
out
(
color
[
"
reset
"
])
# print tags corresponding to the title
for
(
i
,
o
)
in
enumerate
(
objs
[
"
objects
"
]):
line_pos
=
0
if
self
.
options
.
index
:
self
.
printer
.
out
((
"
%d
"
%
i
).
ljust
(
indexw
),
nl
=
""
)
self
.
printer
.
out
(
self
.
tdc
(
t
),
nl
=
""
)
self
.
printer
.
out
(
self
.
tdr
(
t
,
o
.
get
(
t
,
u
""
)).
ljust
(
tags
[
t
])
,
nl
=
"
"
)
self
.
printer
.
out
(
color
[
"
reset
"
])
line_pos
+=
indexw
# print id value
self
.
printer
.
out
(
self
.
tdc
(
"
id
"
)
+
self
.
tdr
(
"
id
"
,
o
.
get
(
"
id
"
,
u
""
)).
ljust
(
tags
[
"
id
"
]),
nl
=
"
"
)
line_pos
+=
size_id
# print tag value
for
t
in
order
[:
tag_index
]:
self
.
printer
.
out
(
self
.
tdc
(
t
),
nl
=
""
)
buf
,
line_pos
=
self
.
_format_indent_text
(
self
.
tdr
(
t
,
o
.
get
(
t
,
u
""
)).
ljust
(
tags
[
t
])
+
"
"
,
line_pos
,
size_id
,
term_width
)
self
.
printer
.
out
(
buf
,
nl
=
""
)
self
.
printer
.
out
(
color
[
"
reset
"
])
order
=
order
[
tag_index
:]
def
list_vertical
(
self
,
objs
):
'''
Vertical display
'''
...
...
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