diff --git a/ChangeLog b/ChangeLog index c64e1031a..22a0245d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-03-30 Don Allingham + * src/Mime/_GnomeMime.py: filter out bad KDE mime type commands + * src/Utils.py: clean up launch routine + 2006-03-29 Brian Matherly * src/Sort.py: remove use of deprecated functions * src/BaseDoc.py: remove use of deprecated functions diff --git a/src/Mime/_GnomeMime.py b/src/Mime/_GnomeMime.py index 2127565e3..736371c35 100644 --- a/src/Mime/_GnomeMime.py +++ b/src/Mime/_GnomeMime.py @@ -38,13 +38,27 @@ def get_application(type): try: applist = mime_get_short_list_applications(type) if applist: - prog = mime_get_default_application(type) - return (prog[2],prog[1]) + applist = [mime_get_default_application(type)] + applist + for prog in applist: + if _is_good_command(prog[2]): + return (prog[2],prog[1]) + else: + return None else: return None except: return None +def _is_good_command(cmd): + """ + We don't know what to do with certain substitution values. + If we find one, skip the command. + """ + for sub in [ "%m", "%i", "%c" ]: + if cmd.find(sub) != -1: + return False + return True + def get_description(type): """Returns the description of the specfied mime type""" try: diff --git a/src/Utils.py b/src/Utils.py index 62406e60a..8e856bb76 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -1294,14 +1294,12 @@ class ProgressMeter: def launch(prog_str,path): subval = { - '%i' : None, - '%F' : (True,path), - '%f' : (True,path), - '%u' : (True,path), - '%U' : (True,path), - '%n' : (True,path), - '%N' : (True,path), - '"%c"' : (False,'"%s"' % path), + '%F' : path, + '%f' : path, + '%u' : path, + '%U' : path, + '%n' : path, + '%N' : path, } prog_data = prog_str.split() @@ -1311,15 +1309,12 @@ def launch(prog_str,path): if len(prog_data) > 1: for item in prog_data: - value = subval.get(item,item) - if not value: - continue - if type(value) == tuple: - if value[0]: - need_path = False - prog_list.append(value[1]) - elif value[0] != '%': - prog_list.append(value) + if subval.has_key(item): + need_path = False + value = subval[item] + else: + value = item + prog_list.append(value) else: prog_list = [prog_data[0]]