Package sabx10 :: Package utils :: Module utils
[hide private]
[frames] | no frames]

Source Code for Module sabx10.utils.utils

 1  ############################################################################### 
 2  # 
 3  # sabx10 - an SABX file manipulation library 
 4  # Copyright (C) 2009, 2010 Jay Farrimond (jay@sabikerides.com) 
 5  # 
 6  # This file is part of sabx10. 
 7  # 
 8  # sabx10 is free software: you can redistribute it and/or modify it under the 
 9  # terms of the GNU General Public License as published by the Free Software 
10  # Foundation, either version 3 of the License, or (at your option) any later 
11  # version. 
12  # 
13  # sabx10 is distributed in the hope that it will be useful, but WITHOUT ANY 
14  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
15  # A PARTICULAR PURPOSE.  See the GNU General Public License for more details. 
16  # 
17  # You should have received a copy of the GNU General Public License along with 
18  # sabx10.  If not, see <http://www.gnu.org/licenses/>. 
19  # 
20  ############################################################################### 
21  """ 
22  Utility routines. 
23  """ 
24   
25  import os, sys 
26   
27 -def determine_path():
28 """ 29 Determine the path to the file containing this routine. This is handy for 30 getting the directory a package is located in. Obviously, this works best 31 when all the files for a package are in the same directory and not split 32 into sub-directories. 33 34 This is based on code found in the distutils tutorial at 35 U{http://wiki.python.org/moin/Distutils/Tutorial}. Apparently the tutorial 36 author found it in wxglade.py. 37 38 @return: directory part of path this file is in 39 @rtype: C{string} 40 """ 41 root = __file__ 42 if os.path.islink (root): 43 root = os.path.realpath (root) 44 return os.path.dirname (os.path.abspath (root))
45