Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sjrpc
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
sjrpc
Commits
e387d138
Commit
e387d138
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
indexing in list -l and list -t
parent
ae6ac48e
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
+17
-4
17 additions, 4 deletions
cccli/command/list.py
with
17 additions
and
4 deletions
cccli/command/list.py
+
17
−
4
View file @
e387d138
...
...
@@ -9,6 +9,7 @@ from cccli.exception import *
from
sjrpc.core.exceptions
import
*
from
cccli.printer
import
Printer
,
color
from
cccli.command.command
import
TqlCommand
import
math
class
Command_list
(
TqlCommand
):
'''
List objects
'''
...
...
@@ -35,7 +36,7 @@ class Command_list(TqlCommand):
elif
self
.
options
.
table
:
self
.
list_table
(
objs
)
else
:
self
.
print_objects
(
objs
)
self
.
print_objects
(
objs
,
index
=
self
.
options
.
index
)
def
list_align
(
self
,
objs
):
'''
Listing line aligned
'''
...
...
@@ -47,9 +48,14 @@ class Command_list(TqlCommand):
# build initial print order
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
"
])))
# dislay each object by line
for
o
in
objs
[
"
objects
"
]:
line
=
""
for
(
i
,
o
)
in
enumerate
(
objs
[
"
objects
"
]):
if
self
.
options
.
index
:
line
=
(
"
[%d]
"
%
i
).
ljust
(
indexw
+
4
)
else
:
line
=
""
for
t
in
order
:
line
+=
"
%s%s:%s%s
"
%
(
self
.
tdtc
(
t
),
t
,
...
...
@@ -67,14 +73,21 @@ class Command_list(TqlCommand):
# 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
o
in
objs
[
"
objects
"
]:
for
(
i
,
o
)
in
enumerate
(
objs
[
"
objects
"
]
)
:
for
t
in
order
:
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
"
])
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