comparison upreckon/config.py @ 156:2db236d25ecd

Improved the nativization of absolute paths by config.nativize_path
author Oleg Oshmyan <chortos@inbox.lv>
date Sat, 04 Jun 2011 01:31:55 +0100
parents 7951219d9866
children 43e1f2d5d5a4
comparison
equal deleted inserted replaced
155:f8041e1e4d0d 156:2db236d25ecd
90 if comp == '..': 90 if comp == '..':
91 comps[i] = os.path.pardir 91 comps[i] = os.path.pardir
92 elif comp == '.': 92 elif comp == '.':
93 comps[i] = os.path.curdir 93 comps[i] = os.path.curdir
94 native_path = os.path.join(*comps) 94 native_path = os.path.join(*comps)
95 if posixpath.isabs(portable_path) and not os.path.isabs(native_path):
96 abspath = os.path.abspath(native_path)
97 parent = os.path.dirname(abspath)
98 while parent != abspath:
99 abspath, parent = parent, os.path.dirname(parent)
100 native_path = os.path.join(parent, native_path)
101 elif not posixpath.isabs(portable_path) and os.path.isabs(native_path):
102 native_path = os.path.sep + native_path
95 if posixpath.isabs(portable_path) != os.path.isabs(native_path): 103 if posixpath.isabs(portable_path) != os.path.isabs(native_path):
96 native_path = os.path.sep + native_path 104 raise ValueError('cannot make native path relative/absolute')
97 if posixpath.isabs(portable_path) != os.path.isabs(native_path):
98 raise ValueError('cannot make native path relative/absolute')
99 return native_path 105 return native_path
100 106
101 def load_problem(problem_name): 107 def load_problem(problem_name):
102 global builtins 108 global builtins
103 try: 109 try: