20 # |
20 # |
21 # You should have received a copy of the GNU General Public License |
21 # You should have received a copy of the GNU General Public License |
22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 import os, sys |
25 import os |
|
26 import sys |
|
27 |
26 |
28 |
27 def AbsFile(file): |
29 def AbsFile(file): |
28 if isinstance(file, str): |
30 if isinstance(file, str): |
29 file = unicode(file,sys.getfilesystemencoding()) |
31 file = unicode(file, sys.getfilesystemencoding()) |
30 return file |
32 return file |
|
33 |
31 |
34 |
32 def AbsDir(file): |
35 def AbsDir(file): |
33 file = AbsFile(file) |
36 file = AbsFile(file) |
34 return os.path.dirname(os.path.realpath(file)) |
37 return os.path.dirname(os.path.realpath(file)) |
35 |
38 |
|
39 |
36 def AbsNeighbourFile(file, *args): |
40 def AbsNeighbourFile(file, *args): |
37 return os.path.join(AbsDir(file), *args) |
41 return os.path.join(AbsDir(file), *args) |
38 |
42 |
39 |
43 |
40 def AbsParentDir(file, level = 1): |
44 def AbsParentDir(file, level=1): |
41 path = AbsDir(file) |
45 path = AbsDir(file) |
42 for i in range(0, level): |
46 for i in range(0, level): |
43 path = os.path.dirname(path) |
47 path = os.path.dirname(path) |
44 return path |
48 return path |