1
2
3
4
5
6
7
8
9
10
11
12 """
13 Miscelaneous functions for packages.
14 """
15
16 import inspect
17 import os
18
20 """
21 Return first docs strings from objects item.
22
23 @param obj: Object to introspection.
24 Item may be modules, classes, functions.
25 @type obj: object
26 @note: Get docs for all objects, include imported.
27 @return: First docs strings from objects item.
28 @rtype: string
29 """
30 d='\n'.join([name + ' - ' + str(inspect.getdoc(value)).split('\n')[0]
31 for name, value in inspect.getmembers(obj,
32 lambda m: inspect.ismodule(m) or inspect.isclass(m) or
33 inspect.isfunction(m)) ])
34 return d
35
37 """
38 Combine sPath to each path from relative path list.
39
40 @param sPath: List with item[0] = base path.
41 It's list will be extended.
42 B{[in/out]} parametr.
43 @type sPath: list
44 @param lRelPaths: Arguments list of relative paths.
45 @type lRelPaths: *string
46 @return: Combined C{sPath} to each path from relative path list in the
47 B{sPath}.
48 @rtype: None
49 """
50 sPath.extend([os.path.join(sPath[0], item) for item in lRelPaths])
51
53 """
54 If path C{path} end with C{arch} file then remove this file and return
55 path without C{arch}.
56
57 For define archive test ends of path and if it equal arch then archive is defined.
58
59 For example if C{path = 'c:/lib/pack.zip'} then return C{'c:/lib'}.
60
61 @param path: Path.
62 @type path: str
63 @param arch: Archive type.
64 @type arch: str = {'.zip'}
65 @return: Path without archive at end.
66 @rtype: str
67 """
68 if path.endswith(arch):
69 path = os.path.dirname(path)
70 return path
71