Welcome to mirror list, hosted at ThFree Co, Russian Federation.

findourfile.py « utils « mcf « modules « python « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c70ff0dd706d34bfb549e0569c83730d3b8e319 (plain)
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
'''
This utility allows a python system to find a file in it's
directory.  To do this, you need to pass it a function object from
a module in the correct directory.  I know there must be a better
way to do this, but I haven't seen it yet.  Incidentally, the
current directory should be _different_ from the module in which
the function is contained, otherwise this function will go off into
the root directory.

Currently this has to be called with the current directory a directory
other than the directory we're trying to find... need a better solution
for this kind of thing... a python registry would be great :)

NOTE: as of Python 1.5, this module should be obsolete!  As soon as I
have verified that all of my code is fixed, it will be moved to the unused
directories.
'''
import os,sys

def findourfile(function, filename):
	'''
	Given the function, return a path to the a file in the
	same directory with 'filename'.  We also let the caller
	know if the file already exists.
	'''
	ourfilename = os.path.split(function.func_code.co_filename)[0]+os.sep+filename
	exists = os.path.exists(ourfilename)
	return (exists,ourfilename)