/usr/share/pyshared/pymt/resources.py is in python-pymt 0.5.1-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | '''
Resources: Search a file inside a list of paths
'''
__all__ = ('resource_find', 'resource_add_path')
from os.path import join, dirname, exists
import sys
resource_paths = [
'.',
dirname(sys.argv[0]),
]
def resource_find(filename):
'''Search a resource in list of paths.
Use resource_add_path to add a custom path to search.
'''
if exists(filename):
return filename
for path in reversed(resource_paths):
output = join(path, filename)
if exists(output):
return output
return None
def resource_add_path(path):
'''Add a custom path to search in
'''
resource_paths.append(path)
|