command handling
svn: r6233
This commit is contained in:
parent
d9277db7ee
commit
0335638bf4
@ -1,3 +1,7 @@
|
||||
2006-03-30 Don Allingham <don@gramps-project.org>
|
||||
* src/Mime/_GnomeMime.py: filter out bad KDE mime type commands
|
||||
* src/Utils.py: clean up launch routine
|
||||
|
||||
2006-03-29 Brian Matherly <pez4brian@users.sourceforge.net>
|
||||
* src/Sort.py: remove use of deprecated functions
|
||||
* src/BaseDoc.py: remove use of deprecated functions
|
||||
|
@ -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:
|
||||
|
29
src/Utils.py
29
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]]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user