Changeset 5072 for anuga_core/source/anuga/utilities/system_tools.py
- Timestamp:
- Feb 26, 2008, 9:06:19 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/system_tools.py
r5048 r5072 203 203 204 204 return crcval 205 206 def get_pathname_from_package(package): 207 """Get pathname of given package (provided as string) 208 209 This is useful for reading files residing in the same directory as 210 a particular module. Typically, this is required in unit tests depending 211 on external files. 212 213 The given module must start from a directory on the pythonpath 214 and be importable using the import statement. 215 216 Example 217 path = get_pathname_from_package('anuga.utilities') 218 219 """ 220 221 exec('import %s as x' %package) 222 223 path = x.__path__[0] 224 225 return path 226 227 # Alternative approach that has been used at times 228 #try: 229 # # When unit test is run from current dir 230 # p1 = read_polygon('mainland_only.csv') 231 #except: 232 # # When unit test is run from ANUGA root dir 233 # from os.path import join, split 234 # dir, tail = split(__file__) 235 # path = join(dir, 'mainland_only.csv') 236 # p1 = read_polygon(path) 237 238 239 240
Note: See TracChangeset
for help on using the changeset viewer.