Browse Source

nilmtool list: remove old -p parameter

tags/nilmdb-1.5.2
Jim Paris 8 years ago
parent
commit
43b740ecaa
2 changed files with 13 additions and 39 deletions
  1. +2
    -16
      nilmdb/cmdline/list.py
  2. +11
    -23
      tests/test_cmdline.py

+ 2
- 16
nilmdb/cmdline/list.py View File

@@ -10,18 +10,14 @@ def setup(self, sub):
formatter_class = def_form,
description="""
List streams available in the database,
optionally filtering by layout or path. Wildcards
optionally filtering by path. Wildcards
are accepted.
""")
cmd.set_defaults(verify = cmd_list_verify,
handler = cmd_list)

group = cmd.add_argument_group("Stream filtering")
group.add_argument("-p", "--path", metavar="PATH", default="*",
help="Match only this path (-p can be omitted)",
).completer = self.complete.path
group.add_argument("path_positional", default="*",
nargs="?", help=argparse.SUPPRESS,
group.add_argument("path", metavar="PATH", default="*", nargs='?',
).completer = self.complete.path
group.add_argument("-l", "--layout", default="*",
help="Match only this stream layout",
@@ -53,16 +49,6 @@ def setup(self, sub):
return cmd

def cmd_list_verify(self):
# A hidden "path_positional" argument lets the user leave off the
# "-p" when specifying the path. Handle it here.
got_opt = self.args.path != "*"
got_pos = self.args.path_positional != "*"
if got_pos:
if got_opt:
self.parser.error("too many paths specified")
else:
self.args.path = self.args.path_positional

if self.args.start is not None and self.args.end is not None:
if self.args.start >= self.args.end:
self.parser.error("start must precede end")


+ 11
- 23
tests/test_cmdline.py View File

@@ -307,15 +307,9 @@ class TestCmdline(object):

# Match just one type or one path. Also check
# that --path is optional
self.ok("list --path /newton/raw")
self.match("/newton/raw uint16_6\n")

self.ok("list /newton/raw")
self.match("/newton/raw uint16_6\n")

self.fail("list -p /newton/raw /newton/raw")
self.contain("too many paths")

self.ok("list --layout uint16_6")
self.match("/newton/raw uint16_6\n")

@@ -324,15 +318,9 @@ class TestCmdline(object):
self.match("/newton/raw uint16_6\n"
"/newton/zzz/rawnotch uint16_9\n")

self.ok("list --path *zzz* --layout uint16*")
self.match("/newton/zzz/rawnotch uint16_9\n")

self.ok("list *zzz* --layout uint16*")
self.match("/newton/zzz/rawnotch uint16_9\n")

self.ok("list --path *zzz* --layout float32*")
self.match("")

# reversed range
self.fail("list /newton/prep --start 2020-01-01 --end 2000-01-01")
self.contain("start must precede end")
@@ -497,28 +485,28 @@ class TestCmdline(object):
self.ok("list --detail")
lines_(self.captured, 8)

self.ok("list --detail --path *prep")
self.ok("list --detail *prep")
lines_(self.captured, 4)

self.ok("list --detail --path *prep --start='23 Mar 2012 10:02'")
self.ok("list --detail *prep --start='23 Mar 2012 10:02'")
lines_(self.captured, 3)

self.ok("list --detail --path *prep --start='23 Mar 2012 10:05'")
self.ok("list --detail *prep --start='23 Mar 2012 10:05'")
lines_(self.captured, 2)

self.ok("list --detail --path *prep --start='23 Mar 2012 10:05:15'")
self.ok("list --detail *prep --start='23 Mar 2012 10:05:15'")
lines_(self.captured, 2)
self.contain("10:05:15.000")

self.ok("list --detail --path *prep --start='23 Mar 2012 10:05:15.50'")
self.ok("list --detail *prep --start='23 Mar 2012 10:05:15.50'")
lines_(self.captured, 2)
self.contain("10:05:15.500")

self.ok("list --detail --path *prep --start='23 Mar 2012 19:05:15.50'")
self.ok("list --detail *prep --start='23 Mar 2012 19:05:15.50'")
lines_(self.captured, 2)
self.contain("no intervals")

self.ok("list --detail --path *prep --start='23 Mar 2012 10:05:15.50'"
self.ok("list --detail *prep --start='23 Mar 2012 10:05:15.50'"
+ " --end='23 Mar 2012 10:05:15.51'")
lines_(self.captured, 2)
self.contain("10:05:15.500")
@@ -527,15 +515,15 @@ class TestCmdline(object):
lines_(self.captured, 8)

# Verify the "raw timestamp" output
self.ok("list --detail --path *prep --timestamp-raw "
self.ok("list --detail *prep --timestamp-raw "
"--start='23 Mar 2012 10:05:15.50'")
lines_(self.captured, 2)
self.contain("[ 1332497115500000 -> 1332497160000000 ]")

# bad time
self.fail("list --detail --path *prep -T --start='9332497115.612'")
self.fail("list --detail *prep -T --start='9332497115.612'")
# good time
self.ok("list --detail --path *prep -T --start='1332497115.612'")
self.ok("list --detail *prep -T --start='1332497115.612'")
lines_(self.captured, 2)
self.contain("[ 1332497115612000 -> 1332497160000000 ]")

@@ -786,7 +774,7 @@ class TestCmdline(object):
self.ok("list")
self.contain(path)
# Make sure it was created empty
self.ok("list --detail --path " + path)
self.ok("list --detail " + path)
self.contain("(no intervals)")

def test_12_unicode(self):


Loading…
Cancel
Save