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
03f5d3bc
Commit
03f5d3bc
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_align
parent
4217d216
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cccli/command/list.py
+34
-2
34 additions, 2 deletions
cccli/command/list.py
with
34 additions
and
2 deletions
cccli/command/list.py
+
34
−
2
View file @
03f5d3bc
...
...
@@ -52,6 +52,7 @@ class Command_list(TqlCommand):
def
list_align
(
self
,
objs
):
'''
Listing line aligned
'''
term_height
,
term_width
=
self
.
printer
.
get_term_size
()
# get max size by tag
tags
=
dict
()
for
o
in
objs
[
"
objects
"
]:
...
...
@@ -61,18 +62,49 @@ class Command_list(TqlCommand):
order
=
[
t
for
t
in
objs
.
get
(
"
order
"
,
[])
if
t
in
tags
]
order
.
extend
(
sorted
(
set
(
tags
.
keys
())
-
set
(
order
)))
# compute index width
indexw
=
int
(
math
.
log10
(
len
(
objs
[
"
objects
"
])))
indexw
=
int
(
math
.
log10
(
len
(
objs
[
"
objects
"
])))
+
1
# dislay each object by line
for
(
i
,
o
)
in
enumerate
(
objs
[
"
objects
"
]):
line_pos
=
0
num_pos
=
0
# tag position on the line
pos
=
dict
()
if
self
.
options
.
index
:
line
=
(
"
[%d]
"
%
i
).
ljust
(
indexw
+
4
)
line
=
(
"
[%d]
"
%
i
).
ljust
(
indexw
+
3
)
line_pos
=
len
(
line
)
else
:
line
=
""
# variable for create a newline
new_line
=
False
first_line
=
True
for
t
in
order
:
# if tag doesn't fit into the space left, newline
if
line_pos
+
len
(
t
)
+
len
(
"
:
"
)
+
tags
[
t
]
+
len
(
"
"
)
>=
term_width
or
new_line
:
line
+=
os
.
linesep
line_pos
=
0
num_pos
=
0
new_line
=
False
first_line
=
False
line
+=
"
%s%s:%s%s
"
%
(
self
.
tdtc
(
t
),
t
,
self
.
tdc
(
t
),
self
.
tdr
(
t
,
o
.
get
(
t
,
u
""
)).
ljust
(
tags
[
t
]))
pos
[
num_pos
]
=
line_pos
line_pos
+=
len
(
t
)
+
len
(
"
:
"
)
+
tags
[
t
]
+
len
(
"
"
)
num_pos
+=
1
# align the next tag on the tag above and right
tmp_pos
=
num_pos
found_pos
=
False
while
tmp_pos
in
pos
:
# if the tag position above is greater than the line position, add space to align the next tag
if
pos
[
tmp_pos
]
>
line_pos
:
line
+=
"
"
*
(
pos
[
tmp_pos
]
-
line_pos
)
line_pos
=
pos
[
tmp_pos
]
found_pos
=
True
break
else
:
tmp_pos
+=
1
new_line
=
not
found_pos
and
not
first_line
self
.
printer
.
out
(
"
%s%s
"
%
(
line
,
color
[
"
reset
"
]))
def
list_table
(
self
,
objs
):
...
...
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