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
747dfb55
Commit
747dfb55
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
list now use TqlCommand
parent
077105e1
No related branches found
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
+23
-29
23 additions, 29 deletions
cccli/command/list.py
with
23 additions
and
29 deletions
cccli/command/list.py
+
23
−
29
View file @
747dfb55
...
...
@@ -8,29 +8,22 @@ CloudControl list command
from
cccli.exception
import
*
from
sjrpc.core.exceptions
import
*
from
cccli.printer
import
Printer
,
color
from
cccli.command.command
import
Option
Command
from
cccli.command.command
import
Tql
Command
class
Command_list
(
Option
Command
):
class
Command_list
(
Tql
Command
):
'''
List objects
'''
def
__init__
(
self
,
cli
,
argv0
):
Option
Command
.
__init__
(
self
,
cli
,
argv0
)
Tql
Command
.
__init__
(
self
,
cli
,
argv0
)
self
.
set_usage
(
"
%prog [options] [tql]
"
)
self
.
add_option
(
"
-t
"
,
action
=
"
store_true
"
,
dest
=
"
table
"
,
help
=
"
column aligment display
"
)
self
.
add_option
(
"
-l
"
,
action
=
"
store_true
"
,
dest
=
"
align
"
,
help
=
"
line aligment display
"
)
self
.
add_option
(
"
-n
"
,
"
--no-tagdisplay
"
,
action
=
"
store_false
"
,
dest
=
"
tagdisplay
"
,
default
=
True
,
help
=
"
No tag display system
"
)
self
.
remove_option
(
"
-s
"
)
def
__call__
(
self
,
argv
):
self
.
parse_args
(
argv
)
if
self
.
options
.
tagdisplay
:
self
.
td
=
self
.
cli
.
tagdisplay
.
resolve
self
.
tc
=
self
.
cli
.
tagdisplay
.
color
else
:
self
.
td
=
lambda
tagname
,
tagvalue
:
unicode
(
tagvalue
)
self
.
tc
=
lambda
tagname
:
color
[
"
reset
"
]
if
len
(
self
.
args
)
==
0
:
self
.
args
.
append
(
""
)
try
:
...
...
@@ -49,13 +42,13 @@ class Command_list(OptionCommand):
def
_trivial_list
(
self
,
objs
):
'''
Trivial listing of tag
'''
for
o
in
objs
:
id
=
self
.
td
(
"
id
"
,
o
.
pop
(
"
id
"
))
tags
=
"
"
.
join
([
"
%s%s:%s%s
"
%
(
color
[
"
reset
"
]
,
id
=
self
.
td
r
(
"
id
"
,
o
.
pop
(
"
id
"
))
tags
=
"
"
.
join
([
"
%s%s:%s%s
"
%
(
self
.
tdtc
(
t
)
,
t
,
self
.
tc
(
t
),
self
.
td
(
t
,
v
))
self
.
t
d
c
(
t
),
self
.
td
r
(
t
,
v
))
for
(
t
,
v
)
in
o
.
items
()
])
self
.
printer
.
out
(
"
%sid
:
%s%s %s%s
"
%
(
color
[
"
reset
"
]
,
self
.
tc
(
"
id
"
),
id
,
tags
,
color
[
"
reset
"
]))
self
.
printer
.
out
(
"
%sid
=
%s%s %s%s
"
%
(
self
.
tdtc
(
"
id
"
)
,
self
.
t
d
c
(
"
id
"
),
id
,
tags
,
color
[
"
reset
"
]))
def
_list_align
(
self
,
objs
):
'''
Listing line aligned
'''
...
...
@@ -63,21 +56,21 @@ class Command_list(OptionCommand):
tags
=
dict
()
for
o
in
objs
:
for
t
,
v
in
o
.
items
():
tags
[
t
]
=
max
(
len
(
self
.
td
(
t
,
v
)),
tags
.
get
(
t
,
len
(
t
)))
tags
[
t
]
=
max
(
len
(
self
.
td
r
(
t
,
v
)),
tags
.
get
(
t
,
len
(
t
)))
# extract id size
idsize
=
tags
.
pop
(
"
id
"
)
# dislay each object by line
for
o
in
objs
:
# show id tag
line
=
"
%sid
:
%s%s
"
%
(
color
[
"
reset
"
]
,
self
.
tc
(
"
id
"
),
self
.
td
(
"
id
"
,
o
.
pop
(
"
id
"
)).
ljust
(
idsize
+
2
))
line
=
"
%sid
=
%s%s
"
%
(
self
.
tdtc
(
"
id
"
)
,
self
.
t
d
c
(
"
id
"
),
self
.
td
r
(
"
id
"
,
o
.
pop
(
"
id
"
)).
ljust
(
idsize
+
2
))
# show others tags
for
tagname
in
sorted
(
tags
.
keys
()):
line
+=
"
%s%s:%s%s
"
%
(
color
[
"
reset
"
]
,
line
+=
"
%s%s:%s%s
"
%
(
self
.
tdtc
(
tagname
)
,
tagname
,
self
.
tc
(
tagname
),
self
.
td
(
tagname
,
o
.
get
(
tagname
,
u
""
)).
ljust
(
tags
[
tagname
]
+
1
))
self
.
t
d
c
(
tagname
),
self
.
td
r
(
tagname
,
o
.
get
(
tagname
,
u
""
)).
ljust
(
tags
[
tagname
]
+
1
))
self
.
printer
.
out
(
"
%s%s
"
%
(
line
,
color
[
"
reset
"
]))
def
_list_table
(
self
,
objs
):
...
...
@@ -86,23 +79,24 @@ class Command_list(OptionCommand):
tags
=
dict
()
for
o
in
objs
:
for
t
,
v
in
o
.
items
():
tags
[
t
]
=
max
(
len
(
self
.
td
(
t
,
v
)),
tags
.
get
(
t
,
len
(
t
)))
tags
[
t
]
=
max
(
len
(
self
.
td
r
(
t
,
v
)),
tags
.
get
(
t
,
len
(
t
)))
# extract id size
idsize
=
tags
.
pop
(
"
id
"
)
# print id title
self
.
printer
.
out
(
color
[
"
reset
"
]
,
nl
=
""
)
self
.
printer
.
out
(
self
.
tdtc
(
"
id
"
)
,
nl
=
""
)
self
.
printer
.
out
(
"
id
"
.
ljust
(
idsize
+
1
),
nl
=
"
"
)
# print others titles
for
t
,
v
in
tags
.
items
():
self
.
printer
.
out
(
self
.
tdtc
(
t
),
nl
=
""
)
self
.
printer
.
out
(
t
.
ljust
(
v
),
nl
=
"
"
)
self
.
printer
.
out
(
color
[
"
reset
"
])
# print obj
for
obj
in
objs
:
# print id first
self
.
printer
.
out
(
self
.
tc
(
"
id
"
),
nl
=
""
)
self
.
printer
.
out
(
self
.
td
(
"
id
"
,
obj
.
pop
(
"
id
"
)).
ljust
(
idsize
+
1
),
nl
=
"
"
)
self
.
printer
.
out
(
self
.
t
d
c
(
"
id
"
),
nl
=
""
)
self
.
printer
.
out
(
self
.
td
r
(
"
id
"
,
obj
.
pop
(
"
id
"
)).
ljust
(
idsize
+
1
),
nl
=
"
"
)
# print others tags
for
(
t
,
v
)
in
tags
.
items
():
self
.
printer
.
out
(
self
.
tc
(
t
),
nl
=
""
)
self
.
printer
.
out
(
self
.
td
(
t
,
obj
.
get
(
t
,
u
""
)).
ljust
(
v
)
,
nl
=
"
"
)
self
.
printer
.
out
(
self
.
t
d
c
(
t
),
nl
=
""
)
self
.
printer
.
out
(
self
.
td
r
(
t
,
obj
.
get
(
t
,
u
""
)).
ljust
(
v
)
,
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