mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix %i substitution
This commit is contained in:
parent
440d87d627
commit
62f21113ef
@ -291,7 +291,7 @@ else:
|
|||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
rmap = {
|
rmap = {
|
||||||
'f':path, 'F':path, 'u':'file://'+path, 'U':'file://'+path, '%':'%',
|
'f':path, 'F':path, 'u':'file://'+path, 'U':'file://'+path, '%':'%',
|
||||||
'i':entry.get('Icon', '%i'), 'c':entry.get('Name', ''), 'k':entry.get('desktop_file_path', ''),
|
'c':entry.get('Name', ''), 'k':entry.get('desktop_file_path', ''),
|
||||||
}
|
}
|
||||||
def replace(match):
|
def replace(match):
|
||||||
char = match.group()[-1]
|
char = match.group()[-1]
|
||||||
@ -299,6 +299,14 @@ else:
|
|||||||
return match.group() if repl is None else repl
|
return match.group() if repl is None else repl
|
||||||
sub = re.compile(r'%[fFuUdDnNickvm%]').sub
|
sub = re.compile(r'%[fFuUdDnNickvm%]').sub
|
||||||
cmd = entry['Exec']
|
cmd = entry['Exec']
|
||||||
|
try:
|
||||||
|
idx = cmd.index('%i')
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
icon = entry.get('Icon')
|
||||||
|
repl = ['--icon', icon] if icon else []
|
||||||
|
cmd[idx:idx+1] = repl
|
||||||
return cmd[:1] + [sub(replace, x) for x in cmd[1:]]
|
return cmd[:1] + [sub(replace, x) for x in cmd[1:]]
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user