9 return s.replace('\\', '\\\\').replace('"', '\\"')
11 def iconpath_for_mime(mime):
12 BASE = "/usr/share/rox/ROX/MIME"
13 (main, sub) = mime.split('/')
14 path = os.path.join(BASE, main+'-'+sub+'.png')
15 if not os.path.exists(path):
16 path = os.path.join(BASE, main+'-x-generic.png')
20 opt_fullpath = any(flag in sys.argv for flag in ['-f', '--fullpath-label'])
25 item = sys.stdin.readline()
28 item = item.rstrip('\n')
29 mime_type, filepath = item.split('\t', 1)
30 filepath = filepath.rstrip(os.path.sep)
32 if os.path.exists(filepath):
36 label = os.path.basename(filepath)
38 iconpath = iconpath_for_mime(mime_type)
40 # this method seems sparsely supported by applications
41 # they register their commands wrong.
43 #app = item.last_application()
44 #(cmd, _, _) = item.get_application_info(app)
45 #command_str = "%s %s" % (cmd, filepath)
49 print "prog \"%s\" \"%s\" %s %s" % (esc(label), esc(iconpath), cmd, esc(filepath))