3 # cmd_list.py - list command
5 # Copyright (C) 2003, Xiph.org Foundation
7 # This file is part of positron.
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of a BSD-style license (see the COPYING file in the
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
15 # or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17 """positron list:\tLists entries in the database
21 Lists entries in the audio database
23 positron list <database1> <database2> ...
25 Lists all entries from a particular database. Valid database names
26 are: audio, pcaudio, unidedhisi, idedhisi, failedhisi
29 from neuros
import Neuros
30 import neuros
as neuros_module
34 def display_field(field
):
39 for item
in field
[1:]:
42 def display_audio_record(neuros
, record
):
43 print "Title: %s" % (record
[0],)
44 print "Artist: %-30s\tAlbum: %-30s" % (record
[2], record
[3])
45 print "Genre: %-12s Time: %4ds Size: %5dkB" % (record
[4], record
[6],
48 print "Recording Source: %s" % (record
[5],)
50 if len(record
[1]) > 0:
52 display_field(record
[1])
54 print "Filename: %s" % (neuros
.neurospath_to_hostpath(record
[8]),)
57 def run(config
, neuros
, args
):
64 display_record
= display_audio_record
66 print "Listing database \"%s\" unsupported at this time."
70 database
= neuros
.open_db(arg
)
71 print "===== Database \"%s\" =====" % (arg
,)
74 records
= database
.get_records()
76 for record
in records
:
78 display_record(neuros
, record
)
82 except neuros_module
.Error
, e
: