1
2 r"""
3 :Copyright:
4
5 Copyright 2014 - 2016
6 Andr\xe9 Malo or his licensors, as applicable
7
8 :License:
9
10 Licensed under the Apache License, Version 2.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21
22 ================
23 Misc Utilities
24 ================
25
26 Misc utilities.
27 """
28 if __doc__:
29
30 __doc__ = __doc__.encode('ascii').decode('unicode_escape')
31 __author__ = r"Andr\xe9 Malo".encode('ascii').decode('unicode_escape')
32 __docformat__ = "restructuredtext en"
33
34
35 try:
36 unicode
37 except NameError:
38
39 unicode = str
40 else:
41 unicode = unicode
42
43 try:
44 bytes
45 except NameError:
46
47 bytes = str
48 else:
49 bytes = bytes
50
51 py2 = bytes is str
52
53
55 """
56 Determine all public names in space
57
58 If the space contains an ``__all__`` sequence, a copy is returned (as a
59 list). Otherwise, all symbol names not starting with an underscore are
60 listed.
61
62 :Parameters:
63 `space` : ``dict``
64 Name space to inspect
65
66 :Return: List of public names
67 :Rtype: ``list``
68 """
69 if '__all__' in space:
70 return list(space['__all__'])
71 return [key for key in space.keys() if not key.startswith('_')]
72