/usr/lib/python2.7/dist-packages/nibabel/environment.py is in python-nibabel 2.0.2-2.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
'''
Settings from the system environment relevant to NIPY
'''
import os
from os.path import join as pjoin
def get_home_dir():
"""Return the closest possible equivalent to a 'home' directory.
The path may not exist; code using this routine should not
expect the directory to exist.
Parameters
----------
None
Returns
-------
home_dir : string
best guess at location of home directory
"""
return os.path.expanduser('~')
def get_nipy_user_dir():
"""Get the NIPY user directory
This uses the logic in `get_home_dir` to find the home directory
and the adds either .nipy or _nipy to the end of the path.
We check first in environment variable ``NIPY_USER_DIR``, otherwise
returning the default of ``<homedir>/.nipy`` (Unix) or
``<homedir>/_nipy`` (Windows)
The path may well not exist; code using this routine should not
expect the directory to exist.
Parameters
----------
None
Returns
-------
nipy_dir : string
path to user's NIPY configuration directory
Examples
--------
>>> pth = get_nipy_user_dir()
"""
try:
return os.path.abspath(os.environ['NIPY_USER_DIR'])
except KeyError:
pass
home_dir = get_home_dir()
if os.name == 'posix':
sdir = '.nipy'
else:
sdir = '_nipy'
return pjoin(home_dir, sdir)
def get_nipy_system_dir():
r''' Get systemwide NIPY configuration file directory
On posix systems this will be ``/etc/nipy``.
On Windows, the directory is less useful, but by default it will be
``C:\etc\nipy``
The path may well not exist; code using this routine should not
expect the directory to exist.
Parameters
----------
None
Returns
-------
nipy_dir : string
path to systemwide NIPY configuration directory
Examples
--------
>>> pth = get_nipy_system_dir()
'''
if os.name == 'nt':
return r'C:\etc\nipy'
if os.name == 'posix':
return '/etc/nipy'
|