Skip to content

Commit b778e42

Browse files
committed
dump.py: Added verbose option (-V|--verbose)
1 parent 4267a3e commit b778e42

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

AndroidViewClient/examples/dump.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
from com.dtmilano.android.viewclient import ViewClient
3030

31+
VERBOSE = 'verbose'
3132
UNIQUE_ID = 'uniqueId'
3233
POSITION = 'position'
3334
CONTENT_DESCRIPTION = 'content-description'
@@ -39,19 +40,24 @@
3940
}
4041

4142
def usage():
42-
print >> sys.stderr, 'usage: dump.py [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
43-
(UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
43+
print >> sys.stderr, 'usage: dump.py [-V|--%s] [-u|--%s] [-x|--%s] [-d|--%s] [-c|--%s] [serialno]' % \
44+
(VERBOSE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER)
4445
sys.exit(1)
4546

4647
try:
47-
opts, args = getopt.getopt(sys.argv[1:], 'uxdc',
48-
[UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
48+
opts, args = getopt.getopt(sys.argv[1:], 'Vuxdc',
49+
[VERBOSE, UNIQUE_ID, POSITION, CONTENT_DESCRIPTION, CENTER])
4950
except getopt.GetoptError, e:
5051
print >>sys.stderr, 'ERROR:', str(e)
5152
usage()
5253

54+
verbose = True
5355
transform = ViewClient.TRAVERSE_CIT
5456
for o, a in opts:
55-
transform = MAP[o.strip('-')]
57+
o = o.strip('-')
58+
if o in ['V', VERBOSE]:
59+
verbose = True
60+
continue
61+
transform = MAP[o]
5662

57-
ViewClient(*ViewClient.connectToDeviceOrExit()).traverse(transform=transform)
63+
ViewClient(*ViewClient.connectToDeviceOrExit(verbose=verbose)).traverse(transform=transform)

0 commit comments

Comments
 (0)