Recognizes if input is ogg or not.
[xiph/unicode.git] / positron / positron / cmd_list.py
blob98f0aa027f76144952699f49e9146c4e49a66113
1 # -*- Mode: python -*-
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
11 # distribution).
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
19 positron list
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
27 """
29 from neuros import Neuros
30 import neuros as neuros_module
31 import util
34 def display_field(field):
35 if len(field) == 0:
36 print "None",
37 else:
38 print field[0],
39 for item in field[1:]:
40 print ",", item,
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],
46 record[7])
47 if record[5] != None:
48 print "Recording Source: %s" % (record[5],)
50 if len(record[1]) > 0:
51 print "Playlist: ",
52 display_field(record[1])
54 print "Filename: %s" % (neuros.neurospath_to_hostpath(record[8]),)
57 def run(config, neuros, args):
58 if len(args) == 0:
59 args = ["audio"]
61 for arg in args:
63 if arg == "audio":
64 display_record = display_audio_record
65 else:
66 print "Listing database \"%s\" unsupported at this time."
67 continue
69 try:
70 database = neuros.open_db(arg)
71 print "===== Database \"%s\" =====" % (arg,)
74 records = database.get_records()
76 for record in records:
77 if record != None:
78 display_record(neuros, record)
79 print
81 neuros.close_db(arg)
82 except neuros_module.Error, e:
83 print "Error:", e