Commit ffd7ff55 authored by Guillaume Seguin's avatar Guillaume Seguin

Improve lookup of files

parent 0d7a7228
import os import os, sys
import gettext import gettext
# Set up Internationalization using gettext # Set up Internationalization using gettext
...@@ -16,17 +16,21 @@ def imagefile(filename): ...@@ -16,17 +16,21 @@ def imagefile(filename):
candidate = os.path.join(prefix, filename) candidate = os.path.join(prefix, filename)
if os.path.exists(candidate): if os.path.exists(candidate):
return candidate return candidate
local_candidate = os.path.join(os.path.dirname(__file__), "images", filename) local_candidate = os.path.join(os.path.dirname(sys.argv[0]), "images", filename)
if os.path.exists(local_candidate): if os.path.exists(local_candidate):
return local_candidate return local_candidate
else: else:
return os.path.join(os.path.split(os.path.split(__file__)[0])[0], "images", filename) return os.path.join("images", filename)
def lookup_file(filename, prefixes): def lookup_file(filename, prefixes):
for prefix in prefixes: for prefix in prefixes:
candidate = os.path.join(prefix, filename) candidate = os.path.join(prefix, filename)
if os.path.exists(candidate): if os.path.exists(candidate):
return candidate return candidate
local_candidate = os.path.join(os.path.dirname(sys.argv[0]), filename)
if os.path.exists(local_candidate):
return local_candidate
else:
return filename return filename
def pixmapfile(filename): def pixmapfile(filename):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment