/usr/bin/hachoir-metadata-gtk is in python-hachoir-metadata 1.3.3-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/usr/bin/python
import sys, pygtk, os
pygtk.require('2.0')
import gtk
from hachoir_core.cmd_line import unicodeFilename
from hachoir_parser import createParser
from hachoir_metadata import extractMetadata
from hachoir_metadata.metadata import MultipleMetadata
class Gui:
def __init__(self):
self.main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.main_window.set_border_width(5)
self.main_window.connect("destroy", self._destroy)
self.main_vbox = gtk.VBox()
self.select_hbox = gtk.HBox()
self.select_button = gtk.Button("Select")
self.select_button.connect("clicked", self._select_clicked)
self.select_hbox.pack_start(self.select_button, False)
self.file_combo = gtk.combo_box_new_text()
self.file_combo.connect("changed", self._file_combo_changed)
self.select_hbox.pack_start(self.file_combo)
self.main_vbox.pack_start(self.select_hbox, False)
self.metadata_table = gtk.Table(1, 1)
self.metadata_table.attach(gtk.Label("Select a file to view metadata information..."), 0, 1, 0, 1)
self.main_vbox.pack_start(self.metadata_table)
self.main_window.add(self.main_vbox)
self.main_window.show_all()
def add_file(self, filename):
self.file_combo.append_text(filename)
def _select_clicked(self, widget):
file_chooser = gtk.FileChooserDialog("Ouvrir..", None,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
file_chooser.set_default_response(gtk.RESPONSE_OK)
file_chooser.show()
reponse = file_chooser.run()
if reponse == gtk.RESPONSE_OK:
selected_file = file_chooser.get_filename()
self.add_file(selected_file)
file_chooser.destroy()
def _file_combo_changed(self, widget):
self.main_vbox.remove(self.metadata_table)
real_filename = self.file_combo.get_active_text()
filename = unicodeFilename(real_filename)
parser = createParser(filename, real_filename=real_filename)
metadata = extractMetadata(parser)
self.metadata_table = gtk.Table(1, 2)
self.main_vbox.pack_start(self.metadata_table)
if metadata is None:
self.metadata_table.attach(gtk.Label("Unknown file format"), 0, 1, 0, 1)
else:
total = 1
for data in sorted(metadata):
if not data.values:
continue
title = data.description
for item in data.values:
self.metadata_table.resize(total, 2)
value = item.text
self.metadata_table.attach(gtk.Label(title + ":"), 0, 1, total-1, total)
self.metadata_table.attach(gtk.Label(value), 1, 2, total-1, total)
total += 1
self.metadata_table.show_all()
def _destroy(self, widget, data=None):
gtk.main_quit()
def main(self):
has_file = False
for arg in sys.argv[1:]:
if os.path.isdir(arg):
for file in os.listdir(arg):
path = os.path.join(arg, file)
if os.path.isfile(path):
self.add_file(path)
has_file = True
elif os.path.isfile(arg):
self.add_file(arg)
has_file = True
if has_file:
self.file_combo.set_active(0)
gtk.main()
if __name__ == "__main__":
Gui().main()
|