Package XPyLIB :: Module misc
[hide private]
[frames] | no frames]

Source Code for Module XPyLIB.misc

 1  #!/usr/bin/env python
 
 2  # -*- coding: utf-8 -*-
 
 3  #--------------------------------------------------------------------
 
 4  # Filname: @FileName@
 
 5  # Author: @Author@
 
 6  # Created: @Date@
 
 7  # ID: $Id: XPyLIB.misc-pysrc.html 24 2008-12-01 17:51:12Z alex $
 
 8  # URL: $URL: file:///myfiles/svn_/XPyLIB/trunc/doc/html/XPyLIB.misc-pysrc.html $
 
 9  # Copyright: @Copyright@
 
10  # License: BSD
 
11  #--------------------------------------------------------------------
 
12  
 
13  
 
14  """
 
15  Miscilaneous functions.
 
16  """ 
17  
 
18 -def getConfigParserOptions(sec, cp, raw=0):
19 """ 20 Return readed options and it's values in dictionary. 21 22 If such section is absent then return empty dict. 23 24 @param sec: Section name. 25 @type sec: str 26 @param cp: Config parser instance. 27 @type cp: ConfigParser 28 @param raw: Raw mode for get in ConfigParser. 29 @type raw: int = {0} 30 @return: Dictionary with options and values. 31 @rtype: dict 32 """ 33 r = {} 34 if cp.has_section(sec): 35 r = dict( (n, cp.get(sec,n,raw)) for n in cp.options(sec) ) 36 return r
37
38 -def resolveName(name):
39 """ 40 Resolve a dotted name to a global object. 41 42 @param name: Dotted name for resolve. 43 @type name: str 44 @return: resolved and if need imported object. 45 @rtype: object 46 """ 47 name = name.split('.') 48 used = name.pop(0) 49 found = __import__(used) 50 for n in name: 51 used = used + '.' + n 52 try: 53 found = getattr(found, n) 54 except AttributeError: 55 __import__(used) 56 found = getattr(found, n) 57 return found
58