1
2
3
4
5
6
7
8
9
10
11
12
13
14 """
15 Miscilaneous functions.
16 """
17
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
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