MCPcopy
hub / github.com/beetbox/beets / lslimit

Function lslimit

beetsplug/limit.py:31–50  ·  view source on GitHub ↗

Query command with head/tail.

(lib, opts, args)

Source from the content-addressed store, hash-verified

29
30
31def lslimit(lib, opts, args):
32 """Query command with head/tail."""
33
34 if (opts.head is not None) and (opts.tail is not None):
35 raise ValueError("Only use one of --head and --tail")
36 if (opts.head or opts.tail or 0) < 0:
37 raise ValueError("Limit value must be non-negative")
38
39 if opts.album:
40 objs = lib.albums(args)
41 else:
42 objs = lib.items(args)
43
44 if opts.head is not None:
45 objs = islice(objs, opts.head)
46 elif opts.tail is not None:
47 objs = deque(objs, opts.tail)
48
49 for obj in objs:
50 print_(format(obj))
51
52
53lslimit_cmd = Subcommand("lslimit", help="query with optional head or tail")

Callers

nothing calls this directly

Calls 3

print_Function · 0.90
albumsMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected